Skip to content

Commit

Permalink
test: added test for #83
Browse files Browse the repository at this point in the history
  • Loading branch information
xntrik committed Mar 29, 2023
1 parent f54bcba commit 698e4cc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
29 changes: 29 additions & 0 deletions pkg/spec/parser_threatmodel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,35 @@ func TestParseHCLFileWithIncludingRemote(t *testing.T) {

}

func TestParseHCLFileWithIncludingRemoteGit(t *testing.T) {
defaultCfg := &ThreatmodelSpecConfig{}
defaultCfg.setDefaults()
tmParser := NewThreatmodelParser(defaultCfg)

err := tmParser.ParseFile("./testdata/including/corp-app-remote2.hcl", false)

if err != nil {
t.Errorf("Error parsing legit TM file: %s", err)
}

foundOverwrittenIa := false

for _, tm := range tmParser.GetWrapped().Threatmodels {
if tm.Name == "Tower of London" {
for _, ia := range tm.InformationAssets {
if strings.Contains(ia.Name, "crown jewels") {
foundOverwrittenIa = true
}
}
}
}

if !foundOverwrittenIa {
t.Errorf("We didn't find an IA that should have been overwritten")
}

}

func TestParseHCLFileWithIncludingTooMany(t *testing.T) {
defaultCfg := &ThreatmodelSpecConfig{}
defaultCfg.setDefaults()
Expand Down
6 changes: 6 additions & 0 deletions pkg/spec/testdata/including/corp-app-remote2.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
spec_version = "0.1.6"

threatmodel "Tower of London" {
author = "@xntrik"
including = "github.com/xntrik/hcltm|pkg/spec/testdata/including/shared/tower.hcl"
}

0 comments on commit 698e4cc

Please sign in to comment.