diff options
author | crupest <crupest@outlook.com> | 2022-04-20 22:15:14 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-04-20 22:15:14 +0800 |
commit | 56cd10828f090b4526196d012b0c2efb5033aced (patch) | |
tree | fa009ecf1b4f0f2c94748c7a5dc09b08ae6cc1dd /BackEnd/Timeline.Tests/IntegratedTests2/IntegratedTestPermissionTestExtensions.cs | |
parent | 4ea9fb554ec97248805ddf85489a9800f1f4b002 (diff) | |
download | timeline-56cd10828f090b4526196d012b0c2efb5033aced.tar.gz timeline-56cd10828f090b4526196d012b0c2efb5033aced.tar.bz2 timeline-56cd10828f090b4526196d012b0c2efb5033aced.zip |
...
Diffstat (limited to 'BackEnd/Timeline.Tests/IntegratedTests2/IntegratedTestPermissionTestExtensions.cs')
-rw-r--r-- | BackEnd/Timeline.Tests/IntegratedTests2/IntegratedTestPermissionTestExtensions.cs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/BackEnd/Timeline.Tests/IntegratedTests2/IntegratedTestPermissionTestExtensions.cs b/BackEnd/Timeline.Tests/IntegratedTests2/IntegratedTestPermissionTestExtensions.cs new file mode 100644 index 00000000..ad67293b --- /dev/null +++ b/BackEnd/Timeline.Tests/IntegratedTests2/IntegratedTestPermissionTestExtensions.cs @@ -0,0 +1,18 @@ +using System; +using System.Net; +using System.Net.Http; +using System.Threading.Tasks; + +namespace Timeline.Tests.IntegratedTests2 +{ + public static class IntegratedTestPermissionTestExtensions + { + public static async Task TestOnlySelfAndAdminCanCall(this IntegratedTestBase testBase, HttpMethod httpMethod, string selfResourceUrl, string otherResourceUrl, object? body) + { + await testBase.DefaultClient.TestJsonSendAsync(httpMethod, selfResourceUrl, body, expectedStatusCode: HttpStatusCode.Unauthorized); + await testBase.UserClient.TestJsonSendAsync(httpMethod, selfResourceUrl, body); + await testBase.UserClient.TestJsonSendAsync(httpMethod, otherResourceUrl, body, expectedStatusCode: HttpStatusCode.Forbidden); + await testBase.AdminClient.TestJsonSendAsync(httpMethod, selfResourceUrl, body); + } + } +} |