| 1 | package spnegoscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/ |
| 2 | |
| 3 | import ( |
| 4 | "bytesscip-go gomod github.com/golang/go/src go1.12 bytes/" |
| 5 | "encoding/asn1scip-go gomod github.com/golang/go/src go1.12 `encoding/asn1`/" |
| 6 | "encoding/hexscip-go gomod github.com/golang/go/src go1.12 `encoding/hex`/" |
| 7 | "reflectscip-go gomod github.com/golang/go/src go1.12 reflect/" |
| 8 | |
| 9 | "testingscip-go gomod github.com/golang/go/src go1.12 testing/" |
| 10 | ) |
| 11 | |
| 12 | var testEncodeNegTokenInitscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testEncodeNegTokenInit. = []struct { |
| 13 | Typesscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testEncodeNegTokenInit:Types. []asn1scip-go gomod github.com/golang/go/src go1.12 `encoding/asn1`/.ObjectIdentifierscip-go gomod github.com/golang/go/src go1.12 `encoding/asn1`/ObjectIdentifier# |
| 14 | Tokenscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testEncodeNegTokenInit:Token. string |
| 15 | Expectedscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testEncodeNegTokenInit:Expected. string |
| 16 | }{ |
| 17 | { |
| 18 | []asn1scip-go gomod github.com/golang/go/src go1.12 `encoding/asn1`/.ObjectIdentifierscip-go gomod github.com/golang/go/src go1.12 `encoding/asn1`/ObjectIdentifier#{NlmpOidscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/NlmpOid.}, |
| 19 | "4e544c4d5353500001000000978208e2000000000000000000000000000000000a005a290000000f", |
| 20 | "604806062b0601050502a03e303ca00e300c060a2b06010401823702020aa22a04284e544c4d5353500001000000978208e2000000000000000000000000000000000a005a290000000f", |
| 21 | }, |
| 22 | } |
| 23 | |
| 24 | func TestEncodeNegTokenInitscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/TestEncodeNegTokenInit().(t *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 25 | for i, e := range testEncodeNegTokenInitscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testEncodeNegTokenInit. { |
| 26 | tok, err := hexscip-go gomod github.com/golang/go/src go1.12 `encoding/hex`/.DecodeStringscip-go gomod github.com/golang/go/src go1.12 `encoding/hex`/DecodeString().(e.Tokenscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testEncodeNegTokenInit:Token.) |
| 27 | if err != nil { |
| 28 | t.Fatalscip-go gomod github.com/golang/go/src go1.12 testing/common#Fatal().(err) |
| 29 | } |
| 30 | expected, err := hexscip-go gomod github.com/golang/go/src go1.12 `encoding/hex`/.DecodeStringscip-go gomod github.com/golang/go/src go1.12 `encoding/hex`/DecodeString().(e.Expectedscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testEncodeNegTokenInit:Expected.) |
| 31 | if err != nil { |
| 32 | t.Fatalscip-go gomod github.com/golang/go/src go1.12 testing/common#Fatal().(err) |
| 33 | } |
| 34 | ret, err := EncodeNegTokenInitscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/EncodeNegTokenInit().(e.Typesscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testEncodeNegTokenInit:Types., tok) |
| 35 | if err != nil { |
| 36 | t.Errorfscip-go gomod github.com/golang/go/src go1.12 testing/common#Errorf().("%d: %v\n", i, err) |
| 37 | } |
| 38 | if !bytesscip-go gomod github.com/golang/go/src go1.12 bytes/.Equalscip-go gomod github.com/golang/go/src go1.12 bytes/Equal().(ret, expected) { |
| 39 | t.Errorfscip-go gomod github.com/golang/go/src go1.12 testing/common#Errorf().("%d: fail\n", i) |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | var testDecodeNegTokenRespscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testDecodeNegTokenResp. = []struct { |
| 45 | Inputscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testDecodeNegTokenResp:Input. string |
| 46 | ExpectedResponseTokenscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testDecodeNegTokenResp:ExpectedResponseToken. string |
| 47 | Expectedscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testDecodeNegTokenResp:Expected. *NegTokenRespscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/NegTokenResp# |
| 48 | }{ |
| 49 | { |
| 50 | "a181ca3081c7a0030a0101a10c060a2b06010401823702020aa281b10481ae4e544c4d5353500002000000100010003800000035828962a9d9c92cf4152e98000000000000000066006600480000000601b01d0f000000460041004b004500520055004e00450001001000460041004b004500520055004e00450002001000460041004b004500520055004e00450003001c00660061006b006500720075006e0065002e006c006f00630061006c0004000a006c006f00630061006c00070008000076b91516c2d10100000000", |
| 51 | "4e544c4d5353500002000000100010003800000035828962a9d9c92cf4152e98000000000000000066006600480000000601b01d0f000000460041004b004500520055004e00450001001000460041004b004500520055004e00450002001000460041004b004500520055004e00450003001c00660061006b006500720075006e0065002e006c006f00630061006c0004000a006c006f00630061006c00070008000076b91516c2d10100000000", |
| 52 | &NegTokenRespscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/NegTokenResp#{ |
| 53 | NegStatescip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/NegTokenResp#NegState.: 1, |
| 54 | SupportedMechscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/NegTokenResp#SupportedMech.: NlmpOidscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/NlmpOid., |
| 55 | MechListMICscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/NegTokenResp#MechListMIC.: nil, |
| 56 | }, |
| 57 | }, |
| 58 | { |
| 59 | "a1073005a0030a0100", |
| 60 | "", |
| 61 | &NegTokenRespscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/NegTokenResp#{ |
| 62 | NegStatescip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/NegTokenResp#NegState.: 0, |
| 63 | }, |
| 64 | }, |
| 65 | { |
| 66 | "a182000b30820007a08200030a0100", // ber encoding (see https://github.com/hirochachacha/go-smb2/pull/34) |
| 67 | "", |
| 68 | &NegTokenRespscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/NegTokenResp#{ |
| 69 | NegStatescip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/NegTokenResp#NegState.: 0, |
| 70 | }, |
| 71 | }, |
| 72 | } |
| 73 | |
| 74 | func TestDecodeNegTokenRespscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/TestDecodeNegTokenResp().(t *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 75 | for i, e := range testDecodeNegTokenRespscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testDecodeNegTokenResp. { |
| 76 | input, err := hexscip-go gomod github.com/golang/go/src go1.12 `encoding/hex`/.DecodeStringscip-go gomod github.com/golang/go/src go1.12 `encoding/hex`/DecodeString().(e.Inputscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testDecodeNegTokenResp:Input.) |
| 77 | if err != nil { |
| 78 | t.Fatalscip-go gomod github.com/golang/go/src go1.12 testing/common#Fatal().(err) |
| 79 | } |
| 80 | responseToken, err := hexscip-go gomod github.com/golang/go/src go1.12 `encoding/hex`/.DecodeStringscip-go gomod github.com/golang/go/src go1.12 `encoding/hex`/DecodeString().(e.ExpectedResponseTokenscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testDecodeNegTokenResp:ExpectedResponseToken.) |
| 81 | if err != nil { |
| 82 | t.Fatalscip-go gomod github.com/golang/go/src go1.12 testing/common#Fatal().(err) |
| 83 | } |
| 84 | if len(responseToken) > 0 { |
| 85 | e.Expectedscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testDecodeNegTokenResp:Expected..ResponseTokenscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/NegTokenResp#ResponseToken. = responseToken |
| 86 | } |
| 87 | |
| 88 | ret, err := DecodeNegTokenRespscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/DecodeNegTokenResp().(input) |
| 89 | if err != nil { |
| 90 | t.Errorfscip-go gomod github.com/golang/go/src go1.12 testing/common#Errorf().("%d: %v\n", i, err) |
| 91 | continue |
| 92 | } |
| 93 | if !reflectscip-go gomod github.com/golang/go/src go1.12 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.12 reflect/DeepEqual().(ret, e.Expectedscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testDecodeNegTokenResp:Expected.) { |
| 94 | t.Errorfscip-go gomod github.com/golang/go/src go1.12 testing/common#Errorf().("%d: fail, expected %v, got %v\n", i, e.Expectedscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testDecodeNegTokenResp:Expected., ret) |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | var testEncodeNegTokenRespscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testEncodeNegTokenResp. = []struct { |
| 100 | Typescip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testEncodeNegTokenResp:Type. asn1scip-go gomod github.com/golang/go/src go1.12 `encoding/asn1`/.ObjectIdentifierscip-go gomod github.com/golang/go/src go1.12 `encoding/asn1`/ObjectIdentifier# |
| 101 | Tokenscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testEncodeNegTokenResp:Token. string |
| 102 | MechListMICscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testEncodeNegTokenResp:MechListMIC. string |
| 103 | Expectedscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testEncodeNegTokenResp:Expected. string |
| 104 | }{ |
| 105 | { |
| 106 | nil, |
| 107 | "4e544c4d535350000300000018001800ac0000000e010e01c4000000200020005800000026002600780000000e000e009e00000010001000d2010000158288620a005a290000000f3e3d42661105d1439dee00f836cad4fa4d006900630072006f0073006f00660074004100630063006f0075006e0074006800690072006f00650069006b006f0040006f00750074006c006f006f006b002e006a00700048004f004d0045002d0050004300000000000000000000000000000000000000000000000000bf302e94f761de33288f11866a37b29c01010000000000000076b91516c2d1012753c10d333a7b100000000001001000460041004b004500520055004e00450002001000460041004b004500520055004e00450003001c00660061006b006500720075006e0065002e006c006f00630061006c0004000a006c006f00630061006c00070008000076b91516c2d10106000400020000000800300030000000000000000100000000200000052b42bd2cfdf105bc038de93d80375c47f43366bb9376579cf2e7ffcfd06aaf0a001000000000000000000000000000000000000900200063006900660073002f003100390032002e003100360038002e0030002e003700000000000000000000000000849ee9fcd70ea92c0c4f60e0dfaaf6d2", |
| 108 | "0100000069e24981b5dac33f00000000", |
| 109 | "a182020730820203a0030a0101a28201e6048201e24e544c4d535350000300000018001800ac0000000e010e01c4000000200020005800000026002600780000000e000e009e00000010001000d2010000158288620a005a290000000f3e3d42661105d1439dee00f836cad4fa4d006900630072006f0073006f00660074004100630063006f0075006e0074006800690072006f00650069006b006f0040006f00750074006c006f006f006b002e006a00700048004f004d0045002d0050004300000000000000000000000000000000000000000000000000bf302e94f761de33288f11866a37b29c01010000000000000076b91516c2d1012753c10d333a7b100000000001001000460041004b004500520055004e00450002001000460041004b004500520055004e00450003001c00660061006b006500720075006e0065002e006c006f00630061006c0004000a006c006f00630061006c00070008000076b91516c2d10106000400020000000800300030000000000000000100000000200000052b42bd2cfdf105bc038de93d80375c47f43366bb9376579cf2e7ffcfd06aaf0a001000000000000000000000000000000000000900200063006900660073002f003100390032002e003100360038002e0030002e003700000000000000000000000000849ee9fcd70ea92c0c4f60e0dfaaf6d2a31204100100000069e24981b5dac33f00000000", |
| 110 | }, |
| 111 | } |
| 112 | |
| 113 | func TestEncodeNegTokenRespscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/TestEncodeNegTokenResp().(t *testingscip-go gomod github.com/golang/go/src go1.12 testing/.Tscip-go gomod github.com/golang/go/src go1.12 testing/T#) { |
| 114 | for i, e := range testEncodeNegTokenRespscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testEncodeNegTokenResp. { |
| 115 | token, err := hexscip-go gomod github.com/golang/go/src go1.12 `encoding/hex`/.DecodeStringscip-go gomod github.com/golang/go/src go1.12 `encoding/hex`/DecodeString().(e.Tokenscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testEncodeNegTokenResp:Token.) |
| 116 | if err != nil { |
| 117 | t.Fatalscip-go gomod github.com/golang/go/src go1.12 testing/common#Fatal().(err) |
| 118 | } |
| 119 | mechListMIC, err := hexscip-go gomod github.com/golang/go/src go1.12 `encoding/hex`/.DecodeStringscip-go gomod github.com/golang/go/src go1.12 `encoding/hex`/DecodeString().(e.MechListMICscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testEncodeNegTokenResp:MechListMIC.) |
| 120 | if err != nil { |
| 121 | t.Fatalscip-go gomod github.com/golang/go/src go1.12 testing/common#Fatal().(err) |
| 122 | } |
| 123 | expected, err := hexscip-go gomod github.com/golang/go/src go1.12 `encoding/hex`/.DecodeStringscip-go gomod github.com/golang/go/src go1.12 `encoding/hex`/DecodeString().(e.Expectedscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testEncodeNegTokenResp:Expected.) |
| 124 | if err != nil { |
| 125 | t.Fatalscip-go gomod github.com/golang/go/src go1.12 testing/common#Fatal().(err) |
| 126 | } |
| 127 | |
| 128 | ret, err := EncodeNegTokenRespscip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/EncodeNegTokenResp().(1, e.Typescip-go gomod github.com/hirochachacha/go-smb2 . `github.com/hirochachacha/go-smb2/internal/spnego`/testEncodeNegTokenResp:Type., token, mechListMIC) |
| 129 | if err != nil { |
| 130 | t.Errorfscip-go gomod github.com/golang/go/src go1.12 testing/common#Errorf().("%d: %v\n", i, err) |
| 131 | } |
| 132 | if !bytesscip-go gomod github.com/golang/go/src go1.12 bytes/.Equalscip-go gomod github.com/golang/go/src go1.12 bytes/Equal().(ret, expected) { |
| 133 | t.Errorfscip-go gomod github.com/golang/go/src go1.12 testing/common#Errorf().("%d: fail\n", i) |
| 134 | } |
| 135 | } |
| 136 | } |