Skip to content

Commit 780ffdc

Browse files
committed
TestOAuthServiceAccountClient: check approval needed after scope gets restricted
1 parent 5b6d17f commit 780ffdc

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

test/integration/oauth_serviceaccount_client_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,26 @@ func TestOAuthServiceAccountClient(t *testing.T) {
160160
t.Fatalf("Unexpected error: %v", err)
161161
} else if !reflect.DeepEqual(clientAuth.Scopes, []string{"user:full"}) {
162162
t.Fatalf("Unexpected scopes: %v", clientAuth.Scopes)
163+
} else {
164+
// update the authorization to contain only read scopes
165+
clientAuth.Scopes = []string{"user:info"}
166+
if _, err := clusterAdminOAuthClient.OAuthClientAuthorizations().Update(clientAuth); err != nil {
167+
t.Fatalf("Unexpected error: %v", err)
168+
}
163169
}
170+
// approval steps are needed again for unscoped access
171+
runOAuthFlow(t, clusterAdminClientConfig, projectName, oauthClientConfig, nil, authorizationCodes, authorizationErrors, true, true, []string{
172+
"GET /oauth/authorize",
173+
"received challenge",
174+
"GET /oauth/authorize",
175+
"redirect to /oauth/authorize/approve",
176+
"form",
177+
"POST /oauth/authorize/approve",
178+
"redirect to /oauth/authorize",
179+
"redirect to /oauthcallback",
180+
"code",
181+
"scope:user:full",
182+
})
164183

165184
// with the authorization stored, approval steps are skipped
166185
runOAuthFlow(t, clusterAdminClientConfig, projectName, oauthClientConfig, nil, authorizationCodes, authorizationErrors, true, true, []string{

0 commit comments

Comments
 (0)