Skip to content

Commit bba3640

Browse files
committed
* Fixup TestRefreshToken
1 parent b01244f commit bba3640

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

projects/Test/OAuth2/TestOAuth2Client.cs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,12 @@ public async Task TestRequestToken()
7676
[Fact]
7777
public async Task TestRefreshToken()
7878
{
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+
8085
ExpectTokenRequest(new RequestFormMatcher()
8186
.WithParam("client_id", _client_id)
8287
.WithParam("client_secret", _client_secret)
@@ -86,12 +91,12 @@ public async Task TestRefreshToken()
8691
IToken token = await _client.RequestTokenAsync();
8792
_oauthServer.Reset();
8893

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()
9196
.WithParam("client_id", _client_id)
9297
.WithParam("client_secret", _client_secret)
9398
.WithParam("grant_type", "refresh_token")
94-
.WithParam("refresh_token", "the_refresh_token"),
99+
.WithParam("refresh_token", refreshToken),
95100
responseJsonToken);
96101

97102
IToken refreshedToken = await _client.RefreshTokenAsync(token);
@@ -147,19 +152,13 @@ private void ExpectTokenRequest(RequestFormMatcher expectedRequestBody, JsonToke
147152
);
148153
}
149154

150-
/*
151-
* TODO - remove
152-
private void ExpectTokenRefresh(JsonToken expectedResponse)
155+
private void ExpectTokenRefresh(RequestFormMatcher expectedRequestBody, JsonToken expectedResponse)
153156
{
154157
_oauthServer
155158
.Given(
156159
Request.Create()
157160
.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())
163162
.UsingPost()
164163
)
165164
.RespondWith(
@@ -169,6 +168,5 @@ private void ExpectTokenRefresh(JsonToken expectedResponse)
169168
.WithBody(JsonSerializer.Serialize(expectedResponse))
170169
);
171170
}
172-
*/
173171
}
174172
}

0 commit comments

Comments
 (0)