Skip to content

Commit

Permalink
chore: add disposable token testing
Browse files Browse the repository at this point in the history
  • Loading branch information
pgautier404 committed Sep 19, 2023
1 parent c99391f commit ba6302d
Show file tree
Hide file tree
Showing 4 changed files with 919 additions and 30 deletions.
24 changes: 19 additions & 5 deletions src/Momento.Sdk/Internal/ScsTokenClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,28 @@ protected DateTime CalculateDeadline()
public async Task<GenerateDisposableTokenResponse> GenerateDisposableToken(
DisposableTokenScope scope, ExpiresIn expiresIn
) {
_GenerateDisposableTokenRequest request = new _GenerateDisposableTokenRequest
Permissions permissions;
try
{
permissions = PermissionsFromDisposableTokenScope(scope);
}
catch (ArgumentNullException e)
{
Expires = new _GenerateDisposableTokenRequest.Types.Expires() { ValidForSeconds = (uint)expiresIn.Seconds() },
AuthToken = this.authToken,
Permissions = PermissionsFromDisposableTokenScope(scope)
};
return _logger.LogTraceAuthRequestError(RequestTypeAuthGenerateDisposableToken,
new GenerateDisposableTokenResponse.Error(
new InvalidArgumentException("Permissions parameters may not be null", null, e)
)
);
}

try
{
_GenerateDisposableTokenRequest request = new _GenerateDisposableTokenRequest
{
Expires = new _GenerateDisposableTokenRequest.Types.Expires() { ValidForSeconds = (uint)expiresIn.Seconds() },
AuthToken = this.authToken,
Permissions = permissions
};
_logger.LogTraceExecutingAuthRequest(RequestTypeAuthGenerateDisposableToken);
var response = await grpcManager.Client.generateDisposableToken(
request, new CallOptions(deadline: CalculateDeadline())
Expand Down
Loading

0 comments on commit ba6302d

Please sign in to comment.