@@ -76,7 +76,12 @@ public async Task TestRequestToken()
76
76
[ Fact ]
77
77
public async Task TestRefreshToken ( )
78
78
{
79
- JsonToken expectedJsonToken = new JsonToken ( "the_access_token" , "the_refresh_token" , TimeSpan . FromSeconds ( 10 ) ) ;
79
+ const string accessToken0 = "the_access_token" ;
80
+ const string accessToken1 = "the_access_token_2" ;
81
+ const string refreshToken = "the_refresh_token" ;
82
+
83
+ JsonToken expectedJsonToken = new JsonToken ( accessToken0 , refreshToken , TimeSpan . FromSeconds ( 10 ) ) ;
84
+
80
85
ExpectTokenRequest ( new RequestFormMatcher ( )
81
86
. WithParam ( "client_id" , _client_id )
82
87
. WithParam ( "client_secret" , _client_secret )
@@ -86,12 +91,12 @@ public async Task TestRefreshToken()
86
91
IToken token = await _client . RequestTokenAsync ( ) ;
87
92
_oauthServer . Reset ( ) ;
88
93
89
- JsonToken responseJsonToken = new JsonToken ( "the_access_token2" , "the_refresh_token" , TimeSpan . FromSeconds ( 20 ) ) ;
90
- ExpectTokenRequest ( new RequestFormMatcher ( )
94
+ JsonToken responseJsonToken = new JsonToken ( accessToken1 , refreshToken , TimeSpan . FromSeconds ( 20 ) ) ;
95
+ ExpectTokenRefresh ( new RequestFormMatcher ( )
91
96
. WithParam ( "client_id" , _client_id )
92
97
. WithParam ( "client_secret" , _client_secret )
93
98
. WithParam ( "grant_type" , "refresh_token" )
94
- . WithParam ( "refresh_token" , "the_refresh_token" ) ,
99
+ . WithParam ( "refresh_token" , refreshToken ) ,
95
100
responseJsonToken ) ;
96
101
97
102
IToken refreshedToken = await _client . RefreshTokenAsync ( token ) ;
@@ -147,19 +152,13 @@ private void ExpectTokenRequest(RequestFormMatcher expectedRequestBody, JsonToke
147
152
) ;
148
153
}
149
154
150
- /*
151
- * TODO - remove
152
- private void ExpectTokenRefresh(JsonToken expectedResponse)
155
+ private void ExpectTokenRefresh ( RequestFormMatcher expectedRequestBody , JsonToken expectedResponse )
153
156
{
154
157
_oauthServer
155
158
. Given (
156
159
Request . Create ( )
157
160
. WithPath ( "/token" )
158
- .WithParam("client_id", _client_id)
159
- .WithParam("client_secret", _client_secret)
160
- .WithParam("grant_type", "refresh_token")
161
- .WithParam("refresh_token", expectedResponse.refresh_token)
162
- .WithHeader("content_type", "application/x-www-form-urlencoded")
161
+ . WithBody ( expectedRequestBody . Matcher ( ) )
163
162
. UsingPost ( )
164
163
)
165
164
. RespondWith (
@@ -169,6 +168,5 @@ private void ExpectTokenRefresh(JsonToken expectedResponse)
169
168
. WithBody ( JsonSerializer . Serialize ( expectedResponse ) )
170
169
) ;
171
170
}
172
- */
173
171
}
174
172
}
0 commit comments