Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fapitest/server_error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestServerResponseFromPushedAuthorizationRequest(t *testing.T) {
if err == nil {
t.Fatal("BeginAuthorization(unregistered scope) = nil error, want error")
}
requireServerResponse(t, err, "invalid_request", http.StatusBadRequest)
requireServerResponse(t, err, "invalid_scope", http.StatusBadRequest)
}

func TestServerResponseFromTokenEndpoint(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion server/backchannel_authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ func (s *Server) validateBackchannelAuthenticationParameters(verified verifiedBa
return verifiedBackchannelRequest{}, newError(ErrorInvalidRequest, 400, "scope must be a string", err)
}
if err := s.validateScope(scope, client); err != nil {
return verifiedBackchannelRequest{}, newError(ErrorInvalidRequest, 400, "scope is not valid for this client", err)
return verifiedBackchannelRequest{}, newError(ErrorInvalidScope, 400, "scope is not valid for this client", err)
}

hints := 0
Expand Down
29 changes: 16 additions & 13 deletions server/backchannel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -852,21 +852,24 @@ func TestBeginBackchannelAuthenticationRejectsNoMatchingClientKey(t *testing.T)
}

func TestBeginBackchannelAuthenticationRejectsInvalidScope(t *testing.T) {
cases := map[string]map[string]json.RawMessage{
"missing scope": {
cases := map[string]struct {
params map[string]json.RawMessage
want server.ErrorCode
}{
"missing scope": {map[string]json.RawMessage{
"login_hint": jsonRaw(t, "user-1"),
},
"scope is not a string": {
}, server.ErrorInvalidRequest},
"scope is not a string": {map[string]json.RawMessage{
"scope": jsonRaw(t, 123), "login_hint": jsonRaw(t, "user-1"),
},
"scope not allowed for this client": {
}, server.ErrorInvalidRequest},
"scope not allowed for this client": {map[string]json.RawMessage{
"scope": jsonRaw(t, "openid unregistered_scope"), "login_hint": jsonRaw(t, "user-1"),
},
}, server.ErrorInvalidScope},
}
for name, params := range cases {
for name, tc := range cases {
t.Run(name, func(t *testing.T) {
h, _ := newHarnessWithBackchannel(t)
requestObj := h.backchannelRequestObject(t, params)
requestObj := h.backchannelRequestObject(t, tc.params)

action, err := h.server.BeginBackchannelAuthentication(context.Background(), server.BeginBackchannelAuthenticationRequest{
HTTP: server.FormRequest{Parameters: backchannelFormParams(h.clientAssertion(t), requestObj)},
Expand All @@ -878,8 +881,8 @@ func TestBeginBackchannelAuthenticationRejectsInvalidScope(t *testing.T) {
if !ok {
t.Fatalf("action = %T, want server.BackchannelAuthenticationLocalError", action)
}
if localErr.Error.Code() != server.ErrorInvalidRequest {
t.Fatalf("Code = %q, want %q", localErr.Error.Code(), server.ErrorInvalidRequest)
if localErr.Error.Code() != tc.want {
t.Fatalf("Code = %q, want %q", localErr.Error.Code(), tc.want)
}
})
}
Expand All @@ -905,8 +908,8 @@ func TestBeginBackchannelAuthenticationOAuthOnlyRejectsOpenIDScope(t *testing.T)
if !ok {
t.Fatalf("action = %T, want server.BackchannelAuthenticationLocalError", action)
}
if localErr.Error.Code() != server.ErrorInvalidRequest {
t.Fatalf("Code = %q, want %q", localErr.Error.Code(), server.ErrorInvalidRequest)
if localErr.Error.Code() != server.ErrorInvalidScope {
t.Fatalf("Code = %q, want %q", localErr.Error.Code(), server.ErrorInvalidScope)
}
}

Expand Down
2 changes: 1 addition & 1 deletion server/par.go
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ func (s *Server) validateAuthorizationParameters(params map[string]json.RawMessa
return nil, newError(ErrorInvalidRequest, 400, "scope must be a string", err)
}
if err := s.validateScope(scope, client); err != nil {
return nil, newError(ErrorInvalidRequest, 400, "scope is not valid for this client", err)
return nil, newError(ErrorInvalidScope, 400, "scope is not valid for this client", err)
}
}

Expand Down
8 changes: 4 additions & 4 deletions server/par_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1292,8 +1292,8 @@ func TestPushAuthorizationRequestScopeNotAllowed(t *testing.T) {
_, err := h.server.PushAuthorizationRequest(context.Background(), server.PushAuthorizationRequest{
HTTP: server.FormRequest{Parameters: params},
})
if code := serverErrorCode(t, err); code != server.ErrorInvalidRequest {
t.Fatalf("error code = %q, want %q", code, server.ErrorInvalidRequest)
if code := serverErrorCode(t, err); code != server.ErrorInvalidScope {
t.Fatalf("error code = %q, want %q", code, server.ErrorInvalidScope)
}
}

Expand All @@ -1314,8 +1314,8 @@ func TestPushAuthorizationRequestOAuthOnlyRejectsOpenIDScope(t *testing.T) {
_, err := h.server.PushAuthorizationRequest(context.Background(), server.PushAuthorizationRequest{
HTTP: server.FormRequest{Parameters: params},
})
if code := serverErrorCode(t, err); code != server.ErrorInvalidRequest {
t.Fatalf("error code = %q, want %q", code, server.ErrorInvalidRequest)
if code := serverErrorCode(t, err); code != server.ErrorInvalidScope {
t.Fatalf("error code = %q, want %q", code, server.ErrorInvalidScope)
}
}

Expand Down
Loading