macaroons test: reverse macaroon time caveat check
This commit fixes a go 1.15 vet check. In doing so it uncovers that the time caveat check is actually reversed. Since we should check that the caveat is added, we should only fail the check when the caveat prefix is not equal.
This commit is contained in:
parent
8ca5342b37
commit
14960b1fb4
@ -1,6 +1,7 @@
|
||||
package macaroons_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@ -14,7 +15,7 @@ var (
|
||||
testID = []byte("dummyId")
|
||||
testLocation = "lnd"
|
||||
testVersion = macaroon.LatestVersion
|
||||
expectedTimeCaveatSubstring = "time-before " + string(time.Now().Year())
|
||||
expectedTimeCaveatSubstring = fmt.Sprintf("time-before %d", time.Now().Year())
|
||||
)
|
||||
|
||||
func createDummyMacaroon(t *testing.T) *macaroon.Macaroon {
|
||||
@ -67,8 +68,8 @@ func TestTimeoutConstraint(t *testing.T) {
|
||||
}
|
||||
|
||||
// Finally, check that the created caveat has an
|
||||
// acceptable value
|
||||
if strings.HasPrefix(string(testMacaroon.Caveats()[0].Id),
|
||||
// acceptable value.
|
||||
if !strings.HasPrefix(string(testMacaroon.Caveats()[0].Id),
|
||||
expectedTimeCaveatSubstring) {
|
||||
t.Fatalf("Added caveat '%s' does not meet the expectations!",
|
||||
testMacaroon.Caveats()[0].Id)
|
||||
@ -90,7 +91,7 @@ func TestIpLockConstraint(t *testing.T) {
|
||||
}
|
||||
|
||||
// Finally, check that the created caveat has an
|
||||
// acceptable value
|
||||
// acceptable value.
|
||||
if string(testMacaroon.Caveats()[0].Id) != "ipaddr 127.0.0.1" {
|
||||
t.Fatalf("Added caveat '%s' does not meet the expectations!",
|
||||
testMacaroon.Caveats()[0].Id)
|
||||
|
Loading…
Reference in New Issue
Block a user