Skip to content

Commit b253d47

Browse files
authored
Merge pull request #61 from kuzzleio/2.0.4-proposal
# [2.0.4](https://github.com/kuzzleio/sdk-csharp/releases/tag/2.0.4) (2020-09-18) #### Bug fixes - [ [#60](#60) ] Fix expiresIn option handling ([scottinet](https://github.com/scottinet)) ---
2 parents 1c9d119 + c568e35 commit b253d47

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

Kuzzle.Tests/API/Controllers/AuthControllerTest.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,18 @@ public async void LoginAsyncTestSuccess(TimeSpan? expiresIn) {
192192
credentials,
193193
expiresIn);
194194

195-
_api.Verify(new JObject {
195+
var expectedQuery = new JObject {
196196
{ "controller", "auth" },
197197
{ "action", "login" },
198198
{ "strategy", "foostrategy" },
199-
{ "expiresIn", expiresIn?.TotalMilliseconds },
200-
{ "body", credentials }
201-
});
199+
{ "body", credentials },
200+
};
201+
202+
if (expiresIn != null) {
203+
expectedQuery["expiresIn"] = $"{Math.Floor((double)expiresIn?.TotalSeconds)}s";
204+
}
205+
206+
_api.Verify(expectedQuery);
202207

203208
Assert.Equal<JObject>(
204209
expected,
@@ -252,11 +257,11 @@ public async void RefreshTokenTestSuccess(TimeSpan? expiresIn) {
252257

253258
var expectedQuery = new JObject {
254259
{ "controller", "auth" },
255-
{ "action", "refreshToken" }
260+
{ "action", "refreshToken" },
256261
};
257262

258263
if (expiresIn != null) {
259-
expectedQuery["expiresIn"] = expiresIn?.TotalMilliseconds;
264+
expectedQuery["expiresIn"] = $"{Math.Floor((double)expiresIn?.TotalSeconds)}s";
260265
}
261266

262267
_api.Verify(expectedQuery);

Kuzzle/API/Controllers/AuthController.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,10 @@ public async Task<JObject> LoginAsync(
149149
{ "action", "login" },
150150
{ "strategy", strategy },
151151
{ "body", credentials },
152-
{ "expiresIn", expiresIn?.TotalMilliseconds }
153152
};
154153

155154
if (expiresIn != null) {
156-
query["expiresIn"] = expiresIn?.TotalMilliseconds;
155+
query["expiresIn"] = $"{Math.Floor((double)expiresIn?.TotalSeconds)}s";
157156
}
158157

159158
Response response = await api.QueryAsync(query);
@@ -188,7 +187,7 @@ public async Task<JObject> RefreshTokenAsync(TimeSpan? expiresIn = null) {
188187
};
189188

190189
if (expiresIn != null) {
191-
query["expiresIn"] = expiresIn?.TotalMilliseconds;
190+
query["expiresIn"] = $"{Math.Floor((double)expiresIn?.TotalSeconds)}s";
192191
}
193192

194193
var response = await api.QueryAsync(query);

Kuzzle/Kuzzle.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<metadata>
44
<id>kuzzlesdk</id>
55
<title>Kuzzle SDK</title>
6-
<version>2.0.3</version>
6+
<version>2.0.4</version>
77
<authors>Kuzzle Team</authors>
88
<owners>Kuzzle Team</owners>
99
<license type="expression">Apache-2.0</license>

0 commit comments

Comments
 (0)