-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
auth: export mock mint so we can use it elsewhere
- Loading branch information
1 parent
c43f4a8
commit 1b0479b
Showing
3 changed files
with
65 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package auth | ||
|
||
import ( | ||
"context" | ||
"encoding/hex" | ||
"time" | ||
|
||
"github.com/lightninglabs/aperture/lsat" | ||
"github.com/lightninglabs/aperture/mint" | ||
"github.com/lightningnetwork/lnd/lnrpc" | ||
"github.com/lightningnetwork/lnd/lntypes" | ||
"gopkg.in/macaroon.v2" | ||
) | ||
|
||
// CreateDummyMacHex creates a valid macaroon with dummy content for our tests. | ||
func CreateDummyMacHex(preimage string) string { | ||
dummyMac, err := macaroon.New( | ||
[]byte("aabbccddeeff00112233445566778899"), []byte("AA=="), | ||
"aperture", macaroon.LatestVersion, | ||
) | ||
if err != nil { | ||
panic(err) | ||
} | ||
preimageCaveat := lsat.Caveat{Condition: lsat.PreimageKey, Value: preimage} | ||
err = lsat.AddFirstPartyCaveats(dummyMac, preimageCaveat) | ||
if err != nil { | ||
panic(err) | ||
} | ||
macBytes, err := dummyMac.MarshalBinary() | ||
if err != nil { | ||
panic(err) | ||
} | ||
return hex.EncodeToString(macBytes) | ||
} | ||
|
||
type MockMint struct { | ||
} | ||
|
||
var _ Minter = (*MockMint)(nil) | ||
|
||
func (m *MockMint) MintLSAT(_ context.Context, | ||
services ...lsat.Service) (*macaroon.Macaroon, string, error) { | ||
|
||
return nil, "", nil | ||
} | ||
|
||
func (m *MockMint) VerifyLSAT(_ context.Context, p *mint.VerificationParams) error { | ||
return nil | ||
} | ||
|
||
type MockChecker struct { | ||
Err error | ||
} | ||
|
||
var _ InvoiceChecker = (*MockChecker)(nil) | ||
|
||
func (m *MockChecker) VerifyInvoiceStatus(lntypes.Hash, | ||
lnrpc.Invoice_InvoiceState, time.Duration) error { | ||
|
||
return m.Err | ||
} |