@@ -9,37 +9,15 @@ import (
9
9
10
10
"github.com/lightninglabs/aperture/auth"
11
11
"github.com/lightninglabs/aperture/lsat"
12
- "gopkg.in/macaroon.v2"
13
12
)
14
13
15
- // createDummyMacHex creates a valid macaroon with dummy content for our tests.
16
- func createDummyMacHex (preimage string ) string {
17
- dummyMac , err := macaroon .New (
18
- []byte ("aabbccddeeff00112233445566778899" ), []byte ("AA==" ),
19
- "aperture" , macaroon .LatestVersion ,
20
- )
21
- if err != nil {
22
- panic (err )
23
- }
24
- preimageCaveat := lsat.Caveat {Condition : lsat .PreimageKey , Value : preimage }
25
- err = lsat .AddFirstPartyCaveats (dummyMac , preimageCaveat )
26
- if err != nil {
27
- panic (err )
28
- }
29
- macBytes , err := dummyMac .MarshalBinary ()
30
- if err != nil {
31
- panic (err )
32
- }
33
- return hex .EncodeToString (macBytes )
34
- }
35
-
36
14
// TestLsatAuthenticator tests that the authenticator properly handles auth
37
15
// headers and the tokens contained in them.
38
16
func TestLsatAuthenticator (t * testing.T ) {
39
17
var (
40
18
testPreimage = "49349dfea4abed3cd14f6d356afa83de" +
41
19
"9787b609f088c8df09bacc7b4bd21b39"
42
- testMacHex = createDummyMacHex (testPreimage )
20
+ testMacHex = auth . CreateDummyMacHex (testPreimage )
43
21
testMacBytes , _ = hex .DecodeString (testMacHex )
44
22
testMacBase64 = base64 .StdEncoding .EncodeToString (
45
23
testMacBytes ,
@@ -139,10 +117,10 @@ func TestLsatAuthenticator(t *testing.T) {
139
117
}
140
118
)
141
119
142
- c := & mockChecker {}
143
- a := auth .NewLsatAuthenticator (& mockMint {}, c )
120
+ c := & auth. MockChecker {}
121
+ a := auth .NewLsatAuthenticator (& auth. MockMint {}, c )
144
122
for _ , testCase := range headerTests {
145
- c .err = testCase .checkErr
123
+ c .Err = testCase .checkErr
146
124
result := a .Accept (testCase .header , "test" )
147
125
if result != testCase .result {
148
126
t .Fatalf ("test case %s failed. got %v expected %v" ,
0 commit comments