@@ -171,27 +171,30 @@ func TestShouldThrowErrorWhenUsingProtectedProps(t *testing.T) {
171171 testServer .Close ()
172172 }()
173173
174- appSub := "asdf"
175- body := map [string ]map [string ]* string {
176- "payload" : {
177- "sub" : & appSub ,
178- },
174+ sessionResponse , err := CreateNewSessionWithoutRequestResponse ("public" , "testing" , map [string ]interface {}{
175+ "customProps" : "custom" ,
176+ }, map [string ]interface {}{}, nil )
177+
178+ if err != nil {
179+ t .Error (err .Error ())
179180 }
180181
181- postBody , err := json .Marshal (body )
182+ newSession , err := CreateNewSessionWithoutRequestResponse ("public" , "testing2" , sessionResponse .GetAccessTokenPayload (), map [string ]interface {}{}, nil )
183+
182184 if err != nil {
183185 t .Error (err .Error ())
184186 }
185- res2 , err2 := http .Post (testServer .URL + "/create" , "application/json" , bytes .NewBuffer (postBody ))
186- if err2 != nil {
187+
188+ accessToken := newSession .GetAccessToken ()
189+
190+ parsedToken , err := ParseJWTWithoutSignatureVerification (accessToken )
191+ if err != nil {
187192 t .Error (err .Error ())
188193 }
189194
190- assert .Equal (t , 400 , res2 .StatusCode )
191- cookies := unittesting .ExtractInfoFromResponse (res2 )
192- assert .True (t , cookies ["accessTokenFromAny" ] == "" )
193- assert .True (t , cookies ["refreshTokenFromAny" ] == "" )
194- assert .True (t , cookies ["frontToken" ] == "" )
195+ assert .True (t , parsedToken .Payload ["customProps" ] == "custom" )
196+ // This makes sure it does not reuse the sub from the old payload
197+ assert .True (t , parsedToken .Payload ["sub" ] == "testing2" )
195198}
196199
197200func TestMergeIntoATShouldHelpMigratingV2TokenUsingProtectedProps (t * testing.T ) {
0 commit comments