@@ -9,37 +9,15 @@ import (
99
1010 "github.com/lightninglabs/aperture/auth"
1111 "github.com/lightninglabs/aperture/lsat"
12- "gopkg.in/macaroon.v2"
1312)
1413
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-
3614// TestLsatAuthenticator tests that the authenticator properly handles auth
3715// headers and the tokens contained in them.
3816func TestLsatAuthenticator (t * testing.T ) {
3917 var (
4018 testPreimage = "49349dfea4abed3cd14f6d356afa83de" +
4119 "9787b609f088c8df09bacc7b4bd21b39"
42- testMacHex = createDummyMacHex (testPreimage )
20+ testMacHex = auth . CreateDummyMacHex (testPreimage )
4321 testMacBytes , _ = hex .DecodeString (testMacHex )
4422 testMacBase64 = base64 .StdEncoding .EncodeToString (
4523 testMacBytes ,
@@ -139,10 +117,10 @@ func TestLsatAuthenticator(t *testing.T) {
139117 }
140118 )
141119
142- c := & mockChecker {}
143- a := auth .NewLsatAuthenticator (& mockMint {}, c )
120+ c := & auth. MockChecker {}
121+ a := auth .NewLsatAuthenticator (& auth. MockMint {}, c )
144122 for _ , testCase := range headerTests {
145- c .err = testCase .checkErr
123+ c .Err = testCase .checkErr
146124 result := a .Accept (testCase .header , "test" )
147125 if result != testCase .result {
148126 t .Fatalf ("test case %s failed. got %v expected %v" ,
0 commit comments