Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple wallets per subject #213

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"summary": "Gets all certificates in the wallet that are <b>available</b> for use.",
"parameters": [
{
"name": "start",
"name": "Start",
"in": "query",
"description": "The start of the time range in Unix time in seconds.",
"schema": {
Expand All @@ -22,7 +22,7 @@
}
},
{
"name": "end",
"name": "End",
"in": "query",
"description": "The end of the time range in Unix time in seconds.",
"schema": {
Expand All @@ -31,15 +31,15 @@
}
},
{
"name": "type",
"name": "Type",
"in": "query",
"description": "Filter the type of certificates to return.",
"schema": {
"$ref": "#/components/schemas/CertificateType"
}
},
{
"name": "limit",
"name": "Limit",
"in": "query",
"description": "The number of items to return.",
"schema": {
Expand All @@ -48,7 +48,7 @@
}
},
{
"name": "skip",
"name": "Skip",
"in": "query",
"description": "The number of items to skip.",
"schema": {
Expand Down Expand Up @@ -83,23 +83,23 @@
"summary": "Returns aggregates certificates that are <b>available</b> to use, based on the specified time zone and time range.",
"parameters": [
{
"name": "timeAggregate",
"name": "TimeAggregate",
"in": "query",
"description": "The size of each bucket in the aggregation",
"description": "The size of each bucket in the aggregation.",
"schema": {
"$ref": "#/components/schemas/TimeAggregate"
}
},
{
"name": "timeZone",
"name": "TimeZone",
"in": "query",
"description": "The time zone. See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a list of valid time zones.",
"schema": {
"type": "string"
}
},
{
"name": "start",
"name": "Start",
"in": "query",
"description": "The start of the time range in Unix time in seconds.",
"schema": {
Expand All @@ -108,7 +108,7 @@
}
},
{
"name": "end",
"name": "End",
"in": "query",
"description": "The end of the time range in Unix time in seconds.",
"schema": {
Expand All @@ -117,15 +117,15 @@
}
},
{
"name": "type",
"name": "Type",
"in": "query",
"description": "Filter the type of certificates to return.",
"schema": {
"$ref": "#/components/schemas/CertificateType"
}
},
{
"name": "limit",
"name": "Limit",
"in": "query",
"description": "The number of items to return.",
"schema": {
Expand All @@ -134,7 +134,7 @@
}
},
{
"name": "skip",
"name": "Skip",
"in": "query",
"description": "The number of items to skip.",
"schema": {
Expand Down Expand Up @@ -172,7 +172,7 @@
"summary": "Gets all claims in the wallet",
"parameters": [
{
"name": "start",
"name": "Start",
"in": "query",
"description": "The start of the time range in Unix time in seconds.",
"schema": {
Expand All @@ -181,7 +181,7 @@
}
},
{
"name": "end",
"name": "End",
"in": "query",
"description": "The end of the time range in Unix time in seconds.",
"schema": {
Expand All @@ -190,7 +190,7 @@
}
},
{
"name": "limit",
"name": "Limit",
"in": "query",
"description": "The number of items to return.",
"schema": {
Expand All @@ -199,7 +199,7 @@
}
},
{
"name": "skip",
"name": "Skip",
"in": "query",
"description": "The number of items to skip.",
"schema": {
Expand Down Expand Up @@ -275,23 +275,23 @@
"summary": "Returns a list of aggregates claims for the authenticated user based on the specified time zone and time range.",
"parameters": [
{
"name": "timeAggregate",
"name": "TimeAggregate",
"in": "query",
"description": "The size of each bucket in the aggregation",
"schema": {
"$ref": "#/components/schemas/TimeAggregate"
}
},
{
"name": "timeZone",
"name": "TimeZone",
"in": "query",
"description": "The time zone. See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a list of valid time zones.",
"schema": {
"type": "string"
}
},
{
"name": "start",
"name": "Start",
"in": "query",
"description": "The start of the time range in Unix time in seconds.",
"schema": {
Expand All @@ -300,7 +300,7 @@
}
},
{
"name": "end",
"name": "End",
"in": "query",
"description": "The end of the time range in Unix time in seconds.",
"schema": {
Expand All @@ -309,7 +309,7 @@
}
},
{
"name": "limit",
"name": "Limit",
"in": "query",
"description": "The number of items to return.",
"schema": {
Expand All @@ -318,7 +318,7 @@
}
},
{
"name": "skip",
"name": "Skip",
"in": "query",
"description": "The number of items to skip.",
"schema": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,7 @@ public async Task Verify_Unauthorized()
var controller = new CertificatesController();

// Act
var result = await controller.GetCertificates(
_unitOfWork,
null,
null,
null,
null);
var result = await controller.GetCertificates(_unitOfWork, new GetCertificatesQueryParameters());

// Assert
result.Result.Should().BeOfType<UnauthorizedResult>();
Expand Down Expand Up @@ -88,12 +83,14 @@ public async Task Test_AggregateCertificates(string timezone, long[] values, Cer
// Act
var result = await controller.AggregateCertificates(
_unitOfWork,
TimeAggregate.Day,
timezone,
queryStartDate.ToUnixTimeSeconds(),
queryEndDate.ToUnixTimeSeconds(),
type,
null);
new AggregateCertificatesQueryParameters
{
TimeAggregate = TimeAggregate.Day,
TimeZone = timezone,
Start = queryStartDate.ToUnixTimeSeconds(),
End = queryEndDate.ToUnixTimeSeconds(),
Type = type
});

// Assert
result.Value.Should().NotBeNull();
Expand All @@ -116,12 +113,11 @@ public async Task AggregateCertificates_Invalid_TimeZone()
// Act
var result = await controller.AggregateCertificates(
_unitOfWork,
TimeAggregate.Day,
"invalid-time-zone",
null,
null,
null,
null);
new AggregateCertificatesQueryParameters
{
TimeAggregate = TimeAggregate.Day,
TimeZone = "invalid-time-zone",
});

// Assert
result.Result.Should().BeOfType<BadRequestObjectResult>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ public async Task Verify_Unauthorized()
// Act
var result = await controller.GetClaims(
_unitOfWork,
null,
null,
null);
new GetClaimsQueryParameters());

// Assert
result.Result.Should().BeOfType<UnauthorizedResult>();
Expand Down Expand Up @@ -93,11 +91,13 @@ public async Task Test_AggregateClaims(string timezone, long[] values)
// Act
var result = await controller.AggregateClaims(
_unitOfWork,
TimeAggregate.Day,
timezone,
queryStartDate.ToUnixTimeSeconds(),
queryEndDate.ToUnixTimeSeconds(),
null);
new AggregateClaimsQueryParameters
{
TimeAggregate = TimeAggregate.Day,
TimeZone = timezone,
Start = queryStartDate.ToUnixTimeSeconds(),
End = queryEndDate.ToUnixTimeSeconds()
});

// Assert
result.Value.Should().NotBeNull();
Expand All @@ -120,11 +120,11 @@ public async Task AggregateClaims_Invalid_TimeZone()
// Act
var result = await controller.AggregateClaims(
_unitOfWork,
TimeAggregate.Day,
"invalid-time-zone",
null,
null,
null);
new AggregateClaimsQueryParameters
{
TimeAggregate = TimeAggregate.Day,
TimeZone = "invalid-time-zone"
});

// Assert
result.Result.Should().BeOfType<BadRequestObjectResult>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public async Task Verify_Valid()
}

[Fact]
public async Task Verify_OnlySingleAllowedPerSubject()
public async Task Verify_MultipleWalletsAllowedPerSubject()
{
// Arrange
var subject = _fixture.Create<string>();
Expand All @@ -154,7 +154,8 @@ public async Task Verify_OnlySingleAllowedPerSubject()
_options,
new CreateWalletRequest());

firstCreateResult.Result.Should().BeOfType<CreatedResult>();
var firstResponse = firstCreateResult.Result.Should().BeOfType<CreatedResult>()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not spin it up and call via rest?

.Which.Value.Should().BeOfType<CreateWalletResponse>().Which;

// Act
var secondCreateResult = await controller.CreateWallet(
Expand All @@ -164,8 +165,9 @@ public async Task Verify_OnlySingleAllowedPerSubject()
new CreateWalletRequest());

// Assert
secondCreateResult.Result.Should().BeOfType<BadRequestObjectResult>()
.Which.Value.Should().Be("Wallet already exists.");
var secondResponse = secondCreateResult.Result.Should().BeOfType<CreatedResult>()
.Which.Value.Should().BeOfType<CreateWalletResponse>().Which;
firstResponse.WalletId.Should().NotBe(secondResponse.WalletId);
}

[Fact]
Expand Down
Loading
Loading