-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: generic openapi authenticator
- Loading branch information
1 parent
bda82d8
commit ff11740
Showing
4 changed files
with
148 additions
and
71 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 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,51 @@ | ||
package authz | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestUnimplemented(t *testing.T) { | ||
t.Parallel() | ||
|
||
checker := &Unimplemented{} | ||
require.NotNil(t, checker) | ||
|
||
allowed, err := checker.Allowed(context.TODO(), "principal", "object", "action") | ||
require.NoError(t, err) | ||
require.False(t, allowed) | ||
} | ||
|
||
func TestFakeChecker(t *testing.T) { | ||
t.Parallel() | ||
|
||
tests := []struct { | ||
name string | ||
allowed bool | ||
expected bool | ||
}{ | ||
{ | ||
name: "allowed", | ||
allowed: true, | ||
expected: true, | ||
}, | ||
{ | ||
name: "not allowed", | ||
allowed: false, | ||
expected: false, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
checker := NewFake(tt.allowed) | ||
require.NotNil(t, checker) | ||
|
||
allowed, err := checker.Allowed(context.TODO(), "principal", "object", "action") | ||
require.NoError(t, err) | ||
require.Equal(t, tt.expected, allowed) | ||
}) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
module github.com/zeiss/fiber-authz | ||
|
||
go 1.21.6 | ||
go 1.21.9 | ||
|
||
toolchain go1.22.2 | ||
|
||
require ( | ||
|
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