-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create a NarrativeTable struct (broken)
- Loading branch information
Showing
5 changed files
with
137 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package control | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/jbowtie/gokogiri/xml" | ||
"github.com/opencontrol/fedramp-templater/opencontrols" | ||
) | ||
|
||
type NarrativeTable struct { | ||
tbl table | ||
} | ||
|
||
func NewNarrativeTable(root xml.Node) NarrativeTable { | ||
tbl := table{Root: root} | ||
return NarrativeTable{tbl} | ||
} | ||
|
||
func (t *NarrativeTable) SectionRows() ([]xml.Node, error) { | ||
// skip the header row | ||
return t.tbl.searchSubtree(`.//w:tr[position() > 1]`) | ||
} | ||
|
||
func (t *NarrativeTable) Fill(openControlData opencontrols.Data) (err error) { | ||
control, err := t.tbl.controlName() | ||
if err != nil { | ||
return | ||
} | ||
// TODO remove hard-coding | ||
sectionKey := "b" | ||
|
||
narrative := openControlData.GetNarrative(control, sectionKey) | ||
fmt.Println(narrative) | ||
|
||
// TODO fill it in | ||
|
||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package control_test | ||
|
||
import ( | ||
. "github.com/opencontrol/fedramp-templater/control" | ||
"github.com/opencontrol/fedramp-templater/fixtures" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("NarrativeTable", func() { | ||
Describe("SectionRows", func() { | ||
It("returns the correct number for a singular narrative", func() { | ||
doc := fixtures.LoadSSP("FedRAMP_ac-2-1_v2.1.docx") | ||
defer doc.Close() | ||
root, err := doc.NarrativeTable("AC-2 (1)") | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
table := NewNarrativeTable(root) | ||
sections, err := table.SectionRows() | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(len(sections)).To(Equal(1)) | ||
}) | ||
|
||
It("returns the correct number for multiple narrative sections", func() { | ||
doc := fixtures.LoadSSP("FedRAMP_ac-2_v2.1.docx") | ||
defer doc.Close() | ||
root, err := doc.NarrativeTable("AC-2") | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
table := NewNarrativeTable(root) | ||
sections, err := table.SectionRows() | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(len(sections)).To(Equal(11)) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters