test(auth): gate local and OIDC authentication release
This commit is contained in:
@@ -48,3 +48,27 @@ func TestLifecycleLockReleaseDoesNotRemoveAnotherOwnersFile(t *testing.T) {
|
||||
t.Fatalf("foreign lock was removed: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTransactionCapabilityIsInstallationBoundAndExpiresOnRelease(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
installation := config.Installation{ProjectDirectory: root, Path: filepath.Join(root, "thothii-installation.yaml")}
|
||||
transaction, err := AcquireTransaction(installation)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := transaction.Verify(installation); err != nil {
|
||||
t.Fatalf("Verify() active capability error = %v", err)
|
||||
}
|
||||
|
||||
otherRoot := t.TempDir()
|
||||
other := config.Installation{ProjectDirectory: otherRoot, Path: filepath.Join(otherRoot, "thothii-installation.yaml")}
|
||||
if err := transaction.Verify(other); !errors.Is(err, ErrTransactionInstallation) {
|
||||
t.Fatalf("Verify() for another installation error = %v, want ErrTransactionInstallation", err)
|
||||
}
|
||||
if err := transaction.Release(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := transaction.Verify(installation); !errors.Is(err, ErrTransactionInactive) {
|
||||
t.Fatalf("Verify() after Release() error = %v, want ErrTransactionInactive", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user