Skip to content
This repository has been archived by the owner on Aug 20, 2021. It is now read-only.

Add multiple component definitons for DTR, Engine #73

Merged
merged 4 commits into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 49 additions & 8 deletions impl/impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,60 @@ const (
)

func TestGenerateImplementation(t *testing.T) {

ucpCompID := "(component ID: cpe:2.3:a:docker:ucp:3.2.0:*:*:*:*:*:*:*)"
dtrCompID := "(component ID: cpe:2.3:a:docker:dtr:2.7.0:*:*:*:*:*:*:*)"
engineCompID := "(component ID: cpe:2.3:a:docker:engine-enterprise:18.09:*:*:*:*:*:*:*)"
components := []string{"CompA", "CompB", "CompC"}
controls := []string{"ac-2", "ac-2.2", "ac-4"}
comps := []component{
{
id: getComponentID(ucpCompID),
name: "UCP",
compNameIndex: 17,
uuidIndex: 18,
narrativeIndex: 19,
definition: make(cdMap),
},
{
id: getComponentID(dtrCompID),
name: "DTR",
compNameIndex: 20,
uuidIndex: 21,
narrativeIndex: 22,
definition: make(cdMap),
},
{
id: getComponentID(engineCompID),
name: "Engine",
compNameIndex: 14,
uuidIndex: 15,
narrativeIndex: 16,
definition: make(cdMap),
},
}
controls := []string{"ac-2", "ac-2.2", "ac-4", "bc-1.1", "hk-1.2", "as-3.2", "af-1.23", "ar-5.2", "fp-8.5"}
ComponentDetails := [][]string{
[]string{controls[0], fmt.Sprintf("%s|%s", components[0], components[1]), "2-Narrative", "123|321"},
[]string{controls[1], fmt.Sprintf("%s|%s", components[0], components[1]), "2.2-Narrative", "456|654"},
[]string{controls[2], "CompC", "4-Narrative", "789|987"},
[]string{controls[0], fmt.Sprintf("%s|%s", components[0], components[1]), "3-Narrative", "123|321"},
[]string{controls[1], fmt.Sprintf("%s|%s", components[0], components[1]), "3.4-Narrative", "567|1231"},
[]string{controls[2], "CompC", "5-Narrative", "789|987"},
[]string{controls[0], fmt.Sprintf("%s|%s", components[0], components[1]), "4-Narrative", "123|321"},
[]string{controls[1], fmt.Sprintf("%s|%s", components[0], components[1]), "4.1-Narrative", "111|222"},
[]string{controls[2], "CompC", "6-Narrative", "789|987"},
}
csvs := make([][]string, totalControlsInExcel)
for i := range csvs {
csvs[i] = make([]string, 20)
csvs[i] = make([]string, 25)
}
for i, x := range ComponentDetails {
csvs[i+rowIndex][controlIndex] = x[0]
csvs[i+rowIndex][componentConfigIndex] = x[1]
csvs[i+rowIndex][narrativeIndex] = x[2]
csvs[i+rowIndex][uuidIndex] = x[3]

for _, comp := range comps {
for i, x := range ComponentDetails {
csvs[i+rowIndex][controlIndex] = x[0]
csvs[i+rowIndex][comp.compNameIndex] = x[1]
csvs[i+rowIndex][comp.narrativeIndex] = x[2]
csvs[i+rowIndex][comp.uuidIndex] = x[3]
}
}

p := profile.Profile{
Expand Down Expand Up @@ -81,6 +118,10 @@ func TestGenerateImplementation(t *testing.T) {
},
}
i := GenerateImplementation(csvs, &p, &NISTCatalog{"NISTSP80053"})

if len(i.ComponentDefinitions) != len(comps) {
t.Error("mismatch number of component definitions")
}
if len(i.ComponentDefinitions[0].ComponentConfigurations) != len(components) {
t.Error("mismatch number of components")
}
Expand Down
Loading