-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: allocate struct properly in decoders to prevent re-use of underlying map * test: add tests for property assertions
- Loading branch information
Showing
4 changed files
with
47 additions
and
3 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,12 @@ import ( | |
"github.com/stretchr/testify/require" | ||
) | ||
|
||
type PropertyAssertion struct { | ||
ObjectID string | ||
Property string | ||
ExpectedValue any | ||
} | ||
|
||
var ( | ||
ingestRelationshipAssertionCriteria = []graph.Criteria{ | ||
//// DOMAINS | ||
|
@@ -252,6 +258,19 @@ var ( | |
query.Kind(query.End(), ad.Domain), | ||
query.Equals(query.EndProperty(common.ObjectID.String()), "S-1-5-21-3130019616-2776909439-2417379446")), | ||
} | ||
|
||
propertyAssertionCriteria = []PropertyAssertion{ | ||
{ | ||
ObjectID: "TESTLAB.LOCAL-S-1-5-32-550", | ||
Property: common.Name.String(), | ||
ExpectedValue: "PRINT [email protected]", | ||
}, | ||
{ | ||
ObjectID: "S-1-5-21-3130019616-2776909439-2417379446-521", | ||
Property: common.Name.String(), | ||
ExpectedValue: "READ-ONLY DOMAIN [email protected]", | ||
}, | ||
} | ||
) | ||
|
||
func FormatQueryComponent(criteria graph.Criteria) string { | ||
|
@@ -280,3 +299,15 @@ func IngestAssertionsv6(testCtrl test.Controller, tx graph.Transaction) { | |
require.Nilf(testCtrl, err, "Unable to find an expected relationship: %s", FormatQueryComponent(assertionCriteria)) | ||
} | ||
} | ||
|
||
func PropertyAssertions(testCtrl test.Controller, tx graph.Transaction) { | ||
for _, assertionCriteria := range propertyAssertionCriteria { | ||
node, err := tx.Nodes().Filterf(func() graph.Criteria { | ||
return query.Equals(query.NodeProperty(common.ObjectID.String()), assertionCriteria.ObjectID) | ||
}).First() | ||
require.Nilf(testCtrl, err, "Unable to find expected node %s", assertionCriteria.ObjectID) | ||
prop := node.Properties.Get(assertionCriteria.Property).Any() | ||
require.Equal(testCtrl, assertionCriteria.ExpectedValue, prop) | ||
require.Nilf(testCtrl, err, "Unable to find an expected relationship: %s", FormatQueryComponent(assertionCriteria)) | ||
} | ||
} |