Skip to content

Commit 15cbce6

Browse files
committed
Fix xunit tests.
1 parent 1f15dc9 commit 15cbce6

File tree

4 files changed

+120
-67
lines changed

4 files changed

+120
-67
lines changed

src/Authress.SDK/Api/ResourcePermissionsApi.cs

+56-56
Original file line numberDiff line numberDiff line change
@@ -9,66 +9,66 @@
99

1010
namespace Authress.SDK
1111
{
12-
/// <summary>
13-
/// Represents a collection of functions to interact with the API endpoints
14-
/// </summary>
15-
internal partial class AuthressClient : IResourcePermissionsApi
16-
{
17-
/// <summary>
18-
/// List resource configurations Permissions can be set globally at a resource level. Lists any resources with a globally set resource policy
19-
/// </summary>
20-
/// <returns>ResourcePermissionCollection</returns>
21-
public async Task<ResourcePermissionCollection> GetResources ()
22-
{
12+
// /// <summary>
13+
// /// Represents a collection of functions to interact with the API endpoints
14+
// /// </summary>
15+
// internal partial class AuthressClient : IResourcePermissionsApi
16+
// {
17+
// /// <summary>
18+
// /// List resource configurations Permissions can be set globally at a resource level. Lists any resources with a globally set resource policy
19+
// /// </summary>
20+
// /// <returns>ResourcePermissionCollection</returns>
21+
// public async Task<ResourcePermissionCollection> GetResources ()
22+
// {
2323

24-
var path = "/v1/resources";
25-
var client = await authressHttpClientProvider.GetHttpClientAsync();
26-
using (var response = await client.GetAsync(path))
27-
{
28-
await response.ThrowIfNotSuccessStatusCode();
29-
return await response.Content.ReadAsAsync<ResourcePermissionCollection>();
30-
}
31-
}
24+
// var path = "/v1/resources";
25+
// var client = await authressHttpClientProvider.GetHttpClientAsync();
26+
// using (var response = await client.GetAsync(path))
27+
// {
28+
// await response.ThrowIfNotSuccessStatusCode();
29+
// return await response.Content.ReadAsAsync<ResourcePermissionCollection>();
30+
// }
31+
// }
3232

33-
/// <summary>
34-
/// Get a resource permissions object. Permissions can be set globally at a resource level. This will apply to all users in an account.
35-
/// </summary>
36-
/// <param name="resourceUri">The uri path of a resource to validate, uri segments are allowed.</param>
37-
/// <returns>ResourcePermission</returns>
38-
public async Task<ResourcePermission> GetResourcePermissions (string resourceUri)
39-
{
40-
// verify the required parameter 'resourceUri' is set
41-
if (resourceUri == null) throw new ArgumentNullException("Missing required parameter 'resourceUri'.");
33+
// /// <summary>
34+
// /// Get a resource permissions object. Permissions can be set globally at a resource level. This will apply to all users in an account.
35+
// /// </summary>
36+
// /// <param name="resourceUri">The uri path of a resource to validate, uri segments are allowed.</param>
37+
// /// <returns>ResourcePermission</returns>
38+
// public async Task<ResourcePermission> GetResourcePermissions (string resourceUri)
39+
// {
40+
// // verify the required parameter 'resourceUri' is set
41+
// if (resourceUri == null) throw new ArgumentNullException("Missing required parameter 'resourceUri'.");
4242

43-
var path = $"/v1/resources/{System.Web.HttpUtility.UrlEncode(resourceUri)}";
44-
var client = await authressHttpClientProvider.GetHttpClientAsync();
45-
using (var response = await client.GetAsync(path))
46-
{
47-
await response.ThrowIfNotSuccessStatusCode();
48-
return await response.Content.ReadAsAsync<ResourcePermission>();
49-
}
50-
}
43+
// var path = $"/v1/resources/{System.Web.HttpUtility.UrlEncode(resourceUri)}";
44+
// var client = await authressHttpClientProvider.GetHttpClientAsync();
45+
// using (var response = await client.GetAsync(path))
46+
// {
47+
// await response.ThrowIfNotSuccessStatusCode();
48+
// return await response.Content.ReadAsAsync<ResourcePermission>();
49+
// }
50+
// }
5151

52-
/// <summary>
53-
/// Update a resource permissions object. Updates the global permissions on a resource. This applies to all users in an account.
54-
/// </summary>
55-
/// <param name="body">The contents of the permission to set on the resource. Overwrites existing data.</param>
56-
/// <param name="resourceUri">The uri path of a resource to validate, uri segments are allowed.</param>
57-
/// <returns>Object</returns>
58-
public async Task SetResourcePermissions (string resourceUri, ResourcePermission body)
59-
{
60-
// verify the required parameter 'body' is set
61-
if (body == null) throw new ArgumentNullException("Missing required parameter 'body'.");
62-
// verify the required parameter 'resourceUri' is set
63-
if (resourceUri == null) throw new ArgumentNullException("Missing required parameter 'resourceUri'.");
52+
// /// <summary>
53+
// /// Update a resource permissions object. Updates the global permissions on a resource. This applies to all users in an account.
54+
// /// </summary>
55+
// /// <param name="body">The contents of the permission to set on the resource. Overwrites existing data.</param>
56+
// /// <param name="resourceUri">The uri path of a resource to validate, uri segments are allowed.</param>
57+
// /// <returns>Object</returns>
58+
// public async Task SetResourcePermissions (string resourceUri, ResourcePermission body)
59+
// {
60+
// // verify the required parameter 'body' is set
61+
// if (body == null) throw new ArgumentNullException("Missing required parameter 'body'.");
62+
// // verify the required parameter 'resourceUri' is set
63+
// if (resourceUri == null) throw new ArgumentNullException("Missing required parameter 'resourceUri'.");
6464

65-
var path = $"/v1/resources/{System.Web.HttpUtility.UrlEncode(resourceUri)}";
66-
var client = await authressHttpClientProvider.GetHttpClientAsync();
67-
using (var response = await client.PutAsync(path, body.ToHttpContent()))
68-
{
69-
await response.ThrowIfNotSuccessStatusCode();
70-
}
71-
}
65+
// var path = $"/v1/resources/{System.Web.HttpUtility.UrlEncode(resourceUri)}";
66+
// var client = await authressHttpClientProvider.GetHttpClientAsync();
67+
// using (var response = await client.PutAsync(path, body.ToHttpContent()))
68+
// {
69+
// await response.ThrowIfNotSuccessStatusCode();
70+
// }
71+
// }
7272

73-
}
73+
// }
7474
}

tests/Authress.SDK/Api/UserPermissions/AuthorizeUserTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class TestCase
2727
public string Permission { get; set; }
2828
}
2929

30-
public static TestData<TestCase> TestCases = new TestData<TestCase>
30+
public static TestData<TestCase> TestCases => new TestData<TestCase>
3131
{
3232
{
3333
"Expect cached value to be returned",

tests/Authress.SDK/TestData.cs

+10-10
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ namespace Authress.SDK.UnitTests
66
/// Represents a set of data for a theory. Data can be added to the data set using the collection initializer syntax.
77
/// </summary>
88
/// <typeparam name="T"></typeparam>
9-
public class TestData<T> : TheoryData
9+
public class TestData<T> : TheoryData<string, T>
1010
{
11-
/// <summary>
12-
/// Adds a theory to the Test
13-
/// </summary>
14-
/// <param name="testName">Name of the Test</param>
15-
/// <param name="testObject">Data used in the Test</param>
16-
public void Add(string testName, T testObject)
17-
{
18-
AddRow(testName, testObject);
19-
}
11+
// /// <summary>
12+
// /// Adds a theory to the Test
13+
// /// </summary>
14+
// /// <param name="testName">Name of the Test</param>
15+
// /// <param name="testObject">Data used in the Test</param>
16+
// public void Add(string testName, T testObject)
17+
// {
18+
// AddRow(testName, testObject);
19+
// }
2020
}
2121
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using System.Net;
4+
using System.Threading.Tasks;
5+
using FluentAssertions;
6+
using Moq;
7+
using Xunit;
8+
using Authress.SDK;
9+
using Authress.SDK.Client;
10+
11+
namespace Authress.SDK.UnitTests
12+
{
13+
public class AuthressClientTokenProviderTests
14+
{
15+
private const string userId = "unit-test-user-id";
16+
17+
public class TestCase
18+
{
19+
public string AccessKey { get; set; }
20+
}
21+
22+
public static TestData<TestCase> TestCases = new TestData<TestCase>
23+
{
24+
{
25+
"EdDSA",
26+
new TestCase{ AccessKey = "KEY" }
27+
}
28+
};
29+
30+
[Theory, MemberData(nameof(TestCases))]
31+
public async Task GetBearerToken(string testName, TestCase testCase)
32+
{
33+
var tokenProvider = new AuthressClientTokenProvider(testCase.AccessKey);
34+
var token = await tokenProvider.GetBearerToken();
35+
System.Console.WriteLine(token);
36+
37+
tokenProvider.Should().NotBeNull(testName, testCase);
38+
39+
var authressSettings = new AuthressSettings { AuthressApiUrl = "DOMAIN", };
40+
var authressClient = new AuthressClient(tokenProvider, authressSettings);
41+
var result = await authressClient.GetUserResources("user_001", "resources/*/sub", "edit", DTO.CollectionConfigurationEnum.INCLUDE_NESTED);
42+
await authressClient.GetUserResources("user_001", "resources/*/sub", "edit", DTO.CollectionConfigurationEnum.INCLUDE_NESTED);
43+
await authressClient.GetUserResources("user_001", "resources/*/sub", "edit", DTO.CollectionConfigurationEnum.INCLUDE_NESTED);
44+
await authressClient.GetUserResources("user_001", "resources/*/sub", "edit", DTO.CollectionConfigurationEnum.INCLUDE_NESTED);
45+
await authressClient.GetUserResources("user_001", "resources/*/sub", "edit", DTO.CollectionConfigurationEnum.INCLUDE_NESTED);
46+
await authressClient.GetUserResources("user_001", "resources/*/sub", "edit", DTO.CollectionConfigurationEnum.INCLUDE_NESTED);
47+
System.Console.WriteLine(string.Join(", ", result.Resources.Select(s => s.ResourceUri)));
48+
49+
var token2 = await tokenProvider.GetBearerToken();
50+
System.Console.WriteLine(token2);
51+
}
52+
}
53+
}

0 commit comments

Comments
 (0)