diff --git a/recipe/session/accessTokenVersions_test.go b/recipe/session/accessTokenVersions_test.go index 57b38f58..d24970d3 100644 --- a/recipe/session/accessTokenVersions_test.go +++ b/recipe/session/accessTokenVersions_test.go @@ -171,34 +171,30 @@ func TestShouldThrowErrorWhenUsingProtectedProps(t *testing.T) { testServer.Close() }() - appSub := "asdf" - body := map[string]map[string]*string{ - "payload": { - "sub": &appSub, - }, - } + sessionResponse, err := CreateNewSessionWithoutRequestResponse("public", "testing", map[string]interface{}{ + "customProps": "custom", + }, map[string]interface{}{}, nil) - postBody, err := json.Marshal(body) if err != nil { t.Error(err.Error()) } - res2, err2 := http.Post(testServer.URL+"/create", "application/json", bytes.NewBuffer(postBody)) - if err2 != nil { - t.Error(err2.Error()) + + newSession, err := CreateNewSessionWithoutRequestResponse("public", "testing2", sessionResponse.GetAccessTokenPayload(), map[string]interface{}{}, nil) + + if err != nil { + t.Error(err.Error()) } - assert.Equal(t, 200, res2.StatusCode) - cookies := unittesting.ExtractInfoFromResponse(res2) - assert.False(t, cookies["accessTokenFromAny"] == "") - assert.False(t, cookies["refreshTokenFromAny"] == "") - assert.False(t, cookies["frontToken"] == "") + accessToken := newSession.GetAccessToken() - parsedToken, err := ParseJWTWithoutSignatureVerification(cookies["accessTokenFromAny"]) + parsedToken, err := ParseJWTWithoutSignatureVerification(accessToken) if err != nil { t.Error(err.Error()) } - assert.True(t, parsedToken.Payload["sub"] != "asdf") + assert.True(t, parsedToken.Payload["customProps"] == "custom") + // This makes sure it does not reuse the sub from the old payload + assert.True(t, parsedToken.Payload["sub"] == "testing2") } func TestMergeIntoATShouldHelpMigratingV2TokenUsingProtectedProps(t *testing.T) {