Skip to content

Commit 904d006

Browse files
Merge pull request #177 from supertokens/test-fixes
fix: fixed unit test for null dropped in core
2 parents 440f967 + f1456fc commit 904d006

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2828
- Added `UserRoleClaim` and `PermissionClaim` to user roles recipe.
2929

3030
### Breaking changes
31+
- Removes support for FDI < 1.15
3132
- Changed `SignInUp` third party recipe function to accept an email string instead of an object that takes `{ID: string, IsVerified: boolean}`.
3233
- The frontend SDK should be updated to a version supporting session claims!
3334
- supertokens-auth-react: >= 0.25.0

recipe/session/createNewSession_test.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,17 @@ func TestMergeClaimsAndPassedAccessTokenPayload(t *testing.T) {
200200
t.Error(err.Error())
201201
}
202202

203+
querier, err := supertokens.GetNewQuerierInstanceOrThrowError("")
204+
if err != nil {
205+
t.Error(err.Error())
206+
}
207+
cdiVersion, err := querier.GetQuerierAPIVersion()
208+
if err != nil {
209+
t.Error(err.Error())
210+
}
211+
212+
includesNullInPayload := unittesting.MaxVersion(cdiVersion, "2.14") != "2.14"
213+
203214
mux := http.NewServeMux()
204215
var sessionContainer sessmodels.SessionContainer
205216

@@ -223,7 +234,11 @@ func TestMergeClaimsAndPassedAccessTokenPayload(t *testing.T) {
223234
assert.Equal(t, 1, len(payloadParam))
224235

225236
accessTokenPayload := sessionContainer.GetAccessTokenPayload()
226-
assert.Equal(t, 5, len(accessTokenPayload))
237+
if includesNullInPayload {
238+
assert.Equal(t, 5, len(accessTokenPayload))
239+
} else {
240+
assert.Equal(t, 4, len(accessTokenPayload))
241+
}
227242

228243
// We have the prop from the payload param
229244
assert.Equal(t, true, accessTokenPayload["initial"])
@@ -236,5 +251,11 @@ func TestMergeClaimsAndPassedAccessTokenPayload(t *testing.T) {
236251
// We have the custom claim
237252
// The resulting payload is different from the input: it doesn't container nil values
238253
assert.Equal(t, "asdf", accessTokenPayload["user-custom"])
239-
assert.Equal(t, custom2, accessTokenPayload["user-custom2"])
254+
if includesNullInPayload {
255+
assert.Equal(t, custom2, accessTokenPayload["user-custom2"])
256+
} else {
257+
assert.Equal(t, map[string]interface{}{
258+
"inner": "asdf",
259+
}, accessTokenPayload["user-custom2"])
260+
}
240261
}

0 commit comments

Comments
 (0)