Skip to content

Commit

Permalink
CBG-3164: fix for flake where grant for channel was after the current…
Browse files Browse the repository at this point in the history
… sequence at the cache causing changes feed to not pick the update up. Changed the changes call to use request plus and also disable sequence batching to allow asertions on sequences to hold true (#6443) (#6541)

Co-authored-by: Gregory Newman-Smith <109068393+gregns1@users.noreply.github.com>
  • Loading branch information
torcolvin and gregns1 authored Oct 19, 2023
1 parent 824cd77 commit 42eefb9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rest/oidc_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,7 @@ func TestOpenIDConnectImplicitFlowInitWithKeyspace(t *testing.T) {
// TestOpenIDConnectImplicitFlowReuseToken ensures that requests that use the same token containing channel grants don't end up recomputing or updating the user for each use.
func TestOpenIDConnectImplicitFlowReuseToken(t *testing.T) {
base.SetUpTestLogging(t, base.LevelTrace, base.KeyAll)
defer db.SuspendSequenceBatching()() // allows assertions on last sequence of the database to hold true when request plus is used

testProviders := auth.OIDCProviderMap{
"foo": mockProviderWith("foo", mockProviderUserPrefix{"foo"}, mockProviderChannelsClaim{"channels"}),
Expand Down Expand Up @@ -1198,7 +1199,8 @@ func TestOpenIDConnectImplicitFlowReuseToken(t *testing.T) {
require.NoError(t, err, "Error obtaining signed token from OpenID Connect provider")
require.NotEmpty(t, token, "Empty token retrieved from OpenID Connect provider")

resp = restTester.SendRequestWithHeaders(http.MethodGet, fmt.Sprintf("/{{.keyspace}}/_changes?since=%d", docSeq), ``, map[string]string{"Authorization": BearerToken + " " + token})
// request_plus used here after CBG-3164 found race where grant for channel is after the current sequence at cache
resp = restTester.SendRequestWithHeaders(http.MethodGet, fmt.Sprintf("/{{.keyspace}}/_changes?request_plus=true&since=%d", docSeq), ``, map[string]string{"Authorization": BearerToken + " " + token})
RequireStatus(t, resp, http.StatusOK)
var changesResp ChangesResults
require.NoError(t, json.Unmarshal(resp.BodyBytes(), &changesResp))
Expand Down

0 comments on commit 42eefb9

Please sign in to comment.