Skip to content

Commit

Permalink
chore: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
rvazarkar committed Oct 22, 2024
1 parent 5fa7d4f commit f457d1e
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 1 deletion.
1 change: 0 additions & 1 deletion cmd/api/src/daemons/datapipe/convertors.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ func convertDomainData(domain ein.Domain, converted *ConvertedData) {
domainTrustData := ein.ParseDomainTrusts(domain)
converted.RelProps = append(converted.RelProps, domainTrustData.TrustRelationships...)
converted.NodeProps = append(converted.NodeProps, domainTrustData.ExtraNodeProps...)

}

func convertGPOData(gpo ein.GPO, converted *ConvertedData) {
Expand Down
72 changes: 72 additions & 0 deletions packages/go/ein/ad_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package ein_test

import (
"github.com/specterops/bloodhound/ein"
"github.com/specterops/bloodhound/graphschema/ad"
"github.com/stretchr/testify/assert"
"testing"
)

func TestConvertObjectToNode_DomainInvalidProperties(t *testing.T) {
baseItem := ein.IngestBase{
ObjectIdentifier: "ABC123",
Properties: map[string]any{
"machineaccountquota": "1",
"minpwdlength": "1",
"pwdproperties": "1",
"pwdhistorylength": "1",
"lockoutthreshold": "1",
"expirepasswordsonsmartcardonlyaccounts": "false",
},
Aces: nil,
IsDeleted: false,
IsACLProtected: false,
ContainedBy: ein.TypedPrincipal{},
}

result := ein.ConvertObjectToNode(baseItem, ad.Domain)
props := result.PropertyMap
assert.Contains(t, props, "machineaccountquota")
assert.Contains(t, props, "minpwdlength")
assert.Contains(t, props, "pwdproperties")
assert.Contains(t, props, "pwdhistorylength")
assert.Contains(t, props, "lockoutthreshold")
assert.Contains(t, props, "expirepasswordsonsmartcardonlyaccounts")
assert.Equal(t, 1, props["machineaccountquota"])
assert.Equal(t, 1, props["minpwdlength"])
assert.Equal(t, 1, props["pwdproperties"])
assert.Equal(t, 1, props["pwdhistorylength"])
assert.Equal(t, 1, props["lockoutthreshold"])
assert.Equal(t, false, props["expirepasswordsonsmartcardonlyaccounts"])

baseItem = ein.IngestBase{
ObjectIdentifier: "ABC123",
Properties: map[string]any{
"machineaccountquota": 1,
"minpwdlength": 1,
"pwdproperties": 1,
"pwdhistorylength": 1,
"lockoutthreshold": 1,
"expirepasswordsonsmartcardonlyaccounts": false,
},
Aces: nil,
IsDeleted: false,
IsACLProtected: false,
ContainedBy: ein.TypedPrincipal{},
}

result = ein.ConvertObjectToNode(baseItem, ad.Domain)
props = result.PropertyMap
assert.Contains(t, props, "machineaccountquota")
assert.Contains(t, props, "minpwdlength")
assert.Contains(t, props, "pwdproperties")
assert.Contains(t, props, "pwdhistorylength")
assert.Contains(t, props, "lockoutthreshold")
assert.Contains(t, props, "expirepasswordsonsmartcardonlyaccounts")
assert.Equal(t, 1, props["machineaccountquota"])
assert.Equal(t, 1, props["minpwdlength"])
assert.Equal(t, 1, props["pwdproperties"])
assert.Equal(t, 1, props["pwdhistorylength"])
assert.Equal(t, 1, props["lockoutthreshold"])
assert.Equal(t, false, props["expirepasswordsonsmartcardonlyaccounts"])
}

0 comments on commit f457d1e

Please sign in to comment.