@@ -75,7 +75,30 @@ func TestAccessTokenExchange(t *testing.T) {
7575
7676func TestAccessTokenExchangeWithoutPKCE (t * testing.T ) {
7777 prepareTestEnv (t )
78- req := NewRequestWithValues (t , "POST" , "/login/oauth/access_token" , map [string ]string {
78+ req := NewRequestWithJSON (t , "POST" , "/login/oauth/access_token" , map [string ]string {
79+ "grant_type" : "authorization_code" ,
80+ "client_id" : "da7da3ba-9a13-4167-856f-3899de0b0138" ,
81+ "client_secret" : "4MK8Na6R55smdCY0WuCCumZ6hjRPnGY5saWVRHHjJiA=" ,
82+ "redirect_uri" : "a" ,
83+ "code" : "authcode" ,
84+ "code_verifier" : "N1Zo9-8Rfwhkt68r1r29ty8YwIraXR8eh_1Qwxg7yQXsonBt" , // test PKCE additionally
85+ })
86+ resp := MakeRequest (t , req , 200 )
87+ type response struct {
88+ AccessToken string `json:"access_token"`
89+ TokenType string `json:"token_type"`
90+ ExpiresIn int64 `json:"expires_in"`
91+ RefreshToken string `json:"refresh_token"`
92+ }
93+ parsed := new (response )
94+ assert .NoError (t , json .Unmarshal (resp .Body .Bytes (), parsed ))
95+ assert .True (t , len (parsed .AccessToken ) > 10 )
96+ assert .True (t , len (parsed .RefreshToken ) > 10 )
97+ }
98+
99+ func TestAccessTokenExchangeJSON (t * testing.T ) {
100+ prepareTestEnv (t )
101+ req := NewRequestWithJSON (t , "POST" , "/login/oauth/access_token" , map [string ]string {
79102 "grant_type" : "authorization_code" ,
80103 "client_id" : "da7da3ba-9a13-4167-856f-3899de0b0138" ,
81104 "client_secret" : "4MK8Na6R55smdCY0WuCCumZ6hjRPnGY5saWVRHHjJiA=" ,
0 commit comments