|
|
@@ -47,3 +47,39 @@ func TestMarshal(t *testing.T) {
|
|
|
t.Fatalf("Error parsing marshaled bytes: %v", err)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func TestLoad(t *testing.T) {
|
|
|
+ t.Parallel()
|
|
|
+ kt, err := Load("test/testdata/testuser1.testtab")
|
|
|
+ if err != nil {
|
|
|
+ t.Fatalf("could not load keytab: %v", err)
|
|
|
+ }
|
|
|
+ assert.Equal(t, uint8(2), kt.version, "keytab version not as expected")
|
|
|
+ assert.Equal(t, 12, len(kt.Entries), "keytab entry count not as expected: %+v", *kt)
|
|
|
+ for _, e := range kt.Entries {
|
|
|
+ if e.Principal.Realm != "TEST.GOKRB5" {
|
|
|
+ t.Error("principal realm not as expected")
|
|
|
+ }
|
|
|
+ if e.Principal.NameType != int32(1) {
|
|
|
+ t.Error("name type not as expected")
|
|
|
+ }
|
|
|
+ if e.Principal.NumComponents != int16(1) {
|
|
|
+ t.Error("number of component not as expected")
|
|
|
+ }
|
|
|
+ if len(e.Principal.Components) != 1 {
|
|
|
+ t.Error("number of component not as expected")
|
|
|
+ }
|
|
|
+ if e.Principal.Components[0] != "testuser1" {
|
|
|
+ t.Error("principal components not as expected")
|
|
|
+ }
|
|
|
+ if e.Timestamp.IsZero() {
|
|
|
+ t.Error("entry timestamp incorrect")
|
|
|
+ }
|
|
|
+ if e.KVNO == uint32(0) {
|
|
|
+ t.Error("entry kvno not as expected")
|
|
|
+ }
|
|
|
+ if e.KVNO8 == uint8(0) {
|
|
|
+ t.Error("entry kvno8 not as expected")
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|