|
|
|
@ -19,8 +19,9 @@ var (
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
func createDummyMacaroon(t *testing.T) *macaroon.Macaroon { |
|
|
|
|
dummyMacaroon, err := macaroon.New(testRootKey, testID, |
|
|
|
|
testLocation, testVersion) |
|
|
|
|
dummyMacaroon, err := macaroon.New( |
|
|
|
|
testRootKey, testID, testLocation, testVersion, |
|
|
|
|
) |
|
|
|
|
if err != nil { |
|
|
|
|
t.Fatalf("Error creating initial macaroon: %v", err) |
|
|
|
|
} |
|
|
|
@ -36,8 +37,9 @@ func TestAddConstraints(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Now add a constraint and make sure we have a cloned macaroon
|
|
|
|
|
// with the constraint applied instead of a mutated initial one.
|
|
|
|
|
newMac, err := macaroons.AddConstraints(initialMac, |
|
|
|
|
macaroons.TimeoutConstraint(1)) |
|
|
|
|
newMac, err := macaroons.AddConstraints( |
|
|
|
|
initialMac, macaroons.TimeoutConstraint(1), |
|
|
|
|
) |
|
|
|
|
if err != nil { |
|
|
|
|
t.Fatalf("Error adding constraint: %v", err) |
|
|
|
|
} |
|
|
|
@ -69,8 +71,10 @@ func TestTimeoutConstraint(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Finally, check that the created caveat has an
|
|
|
|
|
// acceptable value.
|
|
|
|
|
if !strings.HasPrefix(string(testMacaroon.Caveats()[0].Id), |
|
|
|
|
expectedTimeCaveatSubstring) { |
|
|
|
|
if !strings.HasPrefix( |
|
|
|
|
string(testMacaroon.Caveats()[0].Id), |
|
|
|
|
expectedTimeCaveatSubstring, |
|
|
|
|
) { |
|
|
|
|
t.Fatalf("Added caveat '%s' does not meet the expectations!", |
|
|
|
|
testMacaroon.Caveats()[0].Id) |
|
|
|
|
} |
|
|
|
|