-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathTtlTest.cs
56 lines (52 loc) · 2.13 KB
/
TtlTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using Xunit;
namespace RingCentral.Tests;
[Collection("Sequential")]
public class TtlTest
{
[Fact]
public async void TestAuth()
{
using (var rc = new RestClient(
Environment.GetEnvironmentVariable("RINGCENTRAL_CLIENT_ID"),
Environment.GetEnvironmentVariable("RINGCENTRAL_CLIENT_SECRET"),
Environment.GetEnvironmentVariable("RINGCENTRAL_SERVER_URL")
))
{
var token = await rc.Authorize(new GetTokenRequest
{
grant_type = "urn:ietf:params:oauth:grant-type:jwt-bearer",
assertion = Environment.GetEnvironmentVariable("RINGCENTRAL_JWT_TOKEN"),
access_token_ttl = 1800,
refresh_token_ttl = 302400
});
Assert.True(token.expires_in > 1700 && token.expires_in < 1900);
Assert.True(token.refresh_token_expires_in > 302300 && token.refresh_token_expires_in < 302500);
}
}
[Fact]
public async void TestRefresh()
{
using (var rc = new RestClient(
Environment.GetEnvironmentVariable("RINGCENTRAL_CLIENT_ID"),
Environment.GetEnvironmentVariable("RINGCENTRAL_CLIENT_SECRET"),
Environment.GetEnvironmentVariable("RINGCENTRAL_SERVER_URL")
))
{
var token = await rc.Authorize(
Environment.GetEnvironmentVariable("RINGCENTRAL_JWT_TOKEN")
);
Assert.True(token.expires_in > 3500 && token.expires_in < 3700);
Assert.True(token.refresh_token_expires_in > 604700 && token.refresh_token_expires_in < 604900);
token = await rc.Authorize(new GetTokenRequest
{
grant_type = "refresh_token",
refresh_token = token.refresh_token,
access_token_ttl = 1800,
refresh_token_ttl = 302400
});
Assert.True(token.expires_in > 1700 && token.expires_in < 1900);
Assert.True(token.refresh_token_expires_in > 302300 && token.refresh_token_expires_in < 302500);
}
}
}