aboutsummaryrefslogtreecommitdiff
path: root/Timeline.Tests/AuthorizationUnitTest.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2019-04-21 00:08:59 +0800
committercrupest <crupest@outlook.com>2019-04-21 00:08:59 +0800
commit076e0131dff71a9f76fff13c92fffa0ef408935f (patch)
tree9fa853690866f452a571b45fb062ac692d298a2e /Timeline.Tests/AuthorizationUnitTest.cs
parent325d4c7dbfba45e9c5a7518279831f54c4690d20 (diff)
downloadtimeline-076e0131dff71a9f76fff13c92fffa0ef408935f.tar.gz
timeline-076e0131dff71a9f76fff13c92fffa0ef408935f.tar.bz2
timeline-076e0131dff71a9f76fff13c92fffa0ef408935f.zip
Reorgnize api. Add basic unit test.
Diffstat (limited to 'Timeline.Tests/AuthorizationUnitTest.cs')
-rw-r--r--Timeline.Tests/AuthorizationUnitTest.cs14
1 files changed, 6 insertions, 8 deletions
diff --git a/Timeline.Tests/AuthorizationUnitTest.cs b/Timeline.Tests/AuthorizationUnitTest.cs
index e450af06..28715ada 100644
--- a/Timeline.Tests/AuthorizationUnitTest.cs
+++ b/Timeline.Tests/AuthorizationUnitTest.cs
@@ -26,7 +26,7 @@ namespace Timeline.Tests
{
using (var client = _factory.CreateDefaultClient())
{
- var response = await client.GetAsync(NeedAuthorizeUrl);
+ var response = await client.GetAsync(NeedAuthorizeUrl);
Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode);
}
}
@@ -34,10 +34,9 @@ namespace Timeline.Tests
[Fact]
public async Task AuthenticationTest()
{
- using (var client = _factory.CreateDefaultClient())
+ using (var client = await _factory.CreateClientWithUser("user", "user"))
{
- var token = (await client.CreateUserTokenAsync("user", "user")).Token;
- var response = await client.SendWithAuthenticationAsync(token, NeedAuthorizeUrl);
+ var response = await client.GetAsync(NeedAuthorizeUrl);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}
}
@@ -58,12 +57,11 @@ namespace Timeline.Tests
[Fact]
public async Task AdminAuthorizationTest()
{
- using (var client = _factory.CreateDefaultClient())
+ using (var client = await _factory.CreateClientWithUser("admin", "admin"))
{
- var token = (await client.CreateUserTokenAsync("admin", "admin")).Token;
- var response1 = await client.SendWithAuthenticationAsync(token, BothUserAndAdminUrl);
+ var response1 = await client.GetAsync(BothUserAndAdminUrl);
Assert.Equal(HttpStatusCode.OK, response1.StatusCode);
- var response2 = await client.SendWithAuthenticationAsync(token, OnlyAdminUrl);
+ var response2 = await client.GetAsync(OnlyAdminUrl);
Assert.Equal(HttpStatusCode.OK, response2.StatusCode);
}
}