Skip to content

Commit 06c63b3

Browse files
Add test
1 parent 7b7557c commit 06c63b3

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

x509ext/sid_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package x509ext_test
33
import (
44
"crypto/x509"
55
"crypto/x509/pkix"
6+
"encoding/base64"
67
"testing"
78

89
"github.com/RedTeamPentesting/adauth/x509ext"
@@ -31,3 +32,26 @@ func TestSID(t *testing.T) {
3132
t.Fatalf("parsed SID %s instead of %s", parsedSID, sid)
3233
}
3334
}
35+
36+
func TestParseSID(t *testing.T) {
37+
expectedSID := "S-1-5-21-3562467320-83266577-1006951523-1141"
38+
39+
testExtensionData, err := base64.StdEncoding.DecodeString(
40+
"MD6gPAYKKwYBBAGCNxkCAaAuBCxTLTEtNS0yMS0zNTYyNDY3MzIwLTgzMjY2NTc3LTEwMDY5NTE1MjMtMTE0MQ==",
41+
)
42+
if err != nil {
43+
t.Fatalf("decode test extension: %v", err)
44+
}
45+
46+
sid, err := x509ext.SIDFromExtension(pkix.Extension{
47+
Id: x509ext.NTDSCASecurityExtOID,
48+
Value: testExtensionData,
49+
})
50+
if err != nil {
51+
t.Fatalf("SIDFromExtension: %v", err)
52+
}
53+
54+
if sid != expectedSID {
55+
t.Fatalf("extracted SID is %q instead of %q", sid, expectedSID)
56+
}
57+
}

0 commit comments

Comments
 (0)