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

chore: add disposable token testing #495

Merged
merged 2 commits into from
Sep 20, 2023
Merged
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
26 changes: 20 additions & 6 deletions src/Momento.Sdk/Internal/ScsTokenClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
this._exceptionMapper = new CacheExceptionMapper(config.LoggerFactory);
}

protected DateTime CalculateDeadline()
private DateTime CalculateDeadline()
{
return DateTime.UtcNow.Add(authClientOperationTimeout);
}
Expand All @@ -39,14 +39,28 @@
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() },

Check warning on line 60 in src/Momento.Sdk/Internal/ScsTokenClient.cs

View workflow job for this annotation

GitHub Actions / build_csharp (ubuntu-latest, net6.0)

Nullable value type may be null.

Check warning on line 60 in src/Momento.Sdk/Internal/ScsTokenClient.cs

View workflow job for this annotation

GitHub Actions / build_csharp (windows-latest, net6.0)

Nullable value type may be null.

Check warning on line 60 in src/Momento.Sdk/Internal/ScsTokenClient.cs

View workflow job for this annotation

GitHub Actions / build_csharp (windows-latest, net461)

Nullable value type may be null.
AuthToken = this.authToken,
Permissions = permissions
};
_logger.LogTraceExecutingAuthRequest(RequestTypeAuthGenerateDisposableToken);
var response = await grpcManager.Client.generateDisposableToken(
request, new CallOptions(deadline: CalculateDeadline())
Expand Down
Loading
Loading