aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline.Tests/IntegratedTests2/IntegratedTestPermissionTestExtensions.cs
diff options
context:
space:
mode:
Diffstat (limited to 'BackEnd/Timeline.Tests/IntegratedTests2/IntegratedTestPermissionTestExtensions.cs')
-rw-r--r--BackEnd/Timeline.Tests/IntegratedTests2/IntegratedTestPermissionTestExtensions.cs18
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);
+ }
+ }
+}