diff options
| author | James Elliott <james-d-elliott@users.noreply.github.com> | 2023-05-25 07:58:00 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-25 07:58:00 +1000 |
| commit | f1b3fc7b31249bc38b2795c694022036c58e89af (patch) | |
| tree | 14af8896fd8d1a7738f7f9abad95c87f4ce24aeb /internal/handlers/handler_authz_misc_test.go | |
| parent | 1f2672e37979391e439a9a8644381b353ee7aa84 (diff) | |
test(handlers): add missing tests (#5480)
Signed-off-by: James Elliott <james-d-elliott@users.noreply.github.com>
Diffstat (limited to 'internal/handlers/handler_authz_misc_test.go')
| -rw-r--r-- | internal/handlers/handler_authz_misc_test.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/internal/handlers/handler_authz_misc_test.go b/internal/handlers/handler_authz_misc_test.go new file mode 100644 index 000000000..ad57c21b2 --- /dev/null +++ b/internal/handlers/handler_authz_misc_test.go @@ -0,0 +1,31 @@ +package handlers + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/valyala/fasthttp" + + "github.com/authelia/authelia/v4/internal/authentication" + "github.com/authelia/authelia/v4/internal/mocks" + "github.com/authelia/authelia/v4/internal/session" +) + +func TestAuthzImplementation(t *testing.T) { + assert.Equal(t, "Legacy", AuthzImplLegacy.String()) + assert.Equal(t, "", AuthzImplementation(-1).String()) +} + +func TestFriendlyMethod(t *testing.T) { + assert.Equal(t, "unknown", friendlyMethod("")) + assert.Equal(t, "GET", friendlyMethod(fasthttp.MethodGet)) +} + +func TestGenerateVerifySessionHasUpToDateProfileTraceLogs(t *testing.T) { + mock := mocks.NewMockAutheliaCtx(t) + + generateVerifySessionHasUpToDateProfileTraceLogs(mock.Ctx, &session.UserSession{Username: "john", DisplayName: "example", Groups: []string{"abc"}, Emails: []string{"user@example.com", "test@example.com"}}, &authentication.UserDetails{Username: "john", Groups: []string{"123"}, DisplayName: "notexample", Emails: []string{"notuser@example.com"}}) + generateVerifySessionHasUpToDateProfileTraceLogs(mock.Ctx, &session.UserSession{Username: "john", DisplayName: "example"}, &authentication.UserDetails{Username: "john", DisplayName: "example"}) + generateVerifySessionHasUpToDateProfileTraceLogs(mock.Ctx, &session.UserSession{Username: "john", DisplayName: "example", Emails: []string{"abc@example.com"}}, &authentication.UserDetails{Username: "john", DisplayName: "example"}) + generateVerifySessionHasUpToDateProfileTraceLogs(mock.Ctx, &session.UserSession{Username: "john", DisplayName: "example"}, &authentication.UserDetails{Username: "john", DisplayName: "example", Emails: []string{"abc@example.com"}}) +} |
