@@ -171,34 +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- },
179- }
174+ sessionResponse , err := CreateNewSessionWithoutRequestResponse ("public" , "testing" , map [string ]interface {}{
175+ "customProps" : "custom" ,
176+ }, map [string ]interface {}{}, nil )
180177
181- postBody , err := json .Marshal (body )
182178 if err != nil {
183179 t .Error (err .Error ())
184180 }
185- res2 , err2 := http .Post (testServer .URL + "/create" , "application/json" , bytes .NewBuffer (postBody ))
186- if err2 != nil {
187- t .Error (err2 .Error ())
181+
182+ newSession , err := CreateNewSessionWithoutRequestResponse ("public" , "testing2" , sessionResponse .GetAccessTokenPayload (), map [string ]interface {}{}, nil )
183+
184+ if err != nil {
185+ t .Error (err .Error ())
188186 }
189187
190- assert .Equal (t , 200 , res2 .StatusCode )
191- cookies := unittesting .ExtractInfoFromResponse (res2 )
192- assert .False (t , cookies ["accessTokenFromAny" ] == "" )
193- assert .False (t , cookies ["refreshTokenFromAny" ] == "" )
194- assert .False (t , cookies ["frontToken" ] == "" )
188+ accessToken := newSession .GetAccessToken ()
195189
196- parsedToken , err := ParseJWTWithoutSignatureVerification (cookies [ "accessTokenFromAny" ] )
190+ parsedToken , err := ParseJWTWithoutSignatureVerification (accessToken )
197191 if err != nil {
198192 t .Error (err .Error ())
199193 }
200194
201- assert .True (t , parsedToken .Payload ["sub" ] != "asdf" )
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" )
202198}
203199
204200func TestMergeIntoATShouldHelpMigratingV2TokenUsingProtectedProps (t * testing.T ) {
0 commit comments