Skip to content

Commit

Permalink
Fix auth_test.go, minor err-check in auth_oidc.go
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtamm committed Feb 15, 2024
1 parent bde1d83 commit 5487aa4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
7 changes: 7 additions & 0 deletions server/auth_oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@ func (c *OidcConfig) isJwtActive(token string) bool {
c.remote.IntrospectionEndpoint,
strings.NewReader(params))

if err != nil {
fmt.Printf("[ERROR] Failed to create a new request for the OIDC "+
"introspection endpoint (POST %s): %s\n",
c.remote.IntrospectionEndpoint, err)
return false
}

request.Header.Set("Content-Type", "application/x-www-form-urlencoded")

if c.local.ClientId != "" && c.local.ClientSecret != "" {
Expand Down
16 changes: 8 additions & 8 deletions tests/auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,26 @@ func TestBasicAuthFail(t *testing.T) {
Id: "1",
View: tes.TaskView_MINIMAL,
})
if err == nil || !strings.Contains(err.Error(), "STATUS CODE - 403") {
if err == nil || !strings.Contains(err.Error(), "STATUS CODE - 401") {
t.Fatal("expected error")
}

_, err = fun.HTTP.ListTasks(ctx, &tes.ListTasksRequest{
View: tes.TaskView_MINIMAL,
})
if err == nil || !strings.Contains(err.Error(), "STATUS CODE - 403") {
if err == nil || !strings.Contains(err.Error(), "STATUS CODE - 401") {
t.Fatal("expected error")
}

_, err = fun.HTTP.CreateTask(ctx, extask)
if err == nil || !strings.Contains(err.Error(), "STATUS CODE - 403") {
if err == nil || !strings.Contains(err.Error(), "STATUS CODE - 401") {
t.Fatal("expected error")
}

_, err = fun.HTTP.CancelTask(ctx, &tes.CancelTaskRequest{
Id: "1",
})
if err == nil || !strings.Contains(err.Error(), "STATUS CODE - 403") {
if err == nil || !strings.Contains(err.Error(), "STATUS CODE - 401") {
t.Fatal("expected error")
}

Expand All @@ -61,26 +61,26 @@ func TestBasicAuthFail(t *testing.T) {
Id: "1",
View: tes.TaskView_MINIMAL,
})
if err == nil || !strings.Contains(err.Error(), "PermissionDenied") {
if err == nil || !strings.Contains(err.Error(), "Unauthenticated") {
t.Fatal("expected error")
}

_, err = fun.RPC.ListTasks(ctx, &tes.ListTasksRequest{
View: tes.TaskView_MINIMAL,
})
if err == nil || !strings.Contains(err.Error(), "PermissionDenied") {
if err == nil || !strings.Contains(err.Error(), "Unauthenticated") {
t.Fatal("expected error")
}

_, err = fun.RPC.CreateTask(ctx, tests.HelloWorld())
if err == nil || !strings.Contains(err.Error(), "PermissionDenied") {
if err == nil || !strings.Contains(err.Error(), "Unauthenticated") {
t.Fatal("expected error")
}

_, err = fun.RPC.CancelTask(ctx, &tes.CancelTaskRequest{
Id: "1",
})
if err == nil || !strings.Contains(err.Error(), "PermissionDenied") {
if err == nil || !strings.Contains(err.Error(), "Unauthenticated") {
t.Fatal("expected error")
}

Expand Down

0 comments on commit 5487aa4

Please sign in to comment.