public void SignBlobResourceNames() { moq::Mock <IAMCredentials.IAMCredentialsClient> mockGrpcClient = new moq::Mock <IAMCredentials.IAMCredentialsClient>(moq::MockBehavior.Strict); SignBlobRequest request = new SignBlobRequest { ServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"), Delegates = { "delegates331d18f6", }, Payload = proto::ByteString.CopyFromUtf8("payloadf43c1c32"), }; SignBlobResponse expectedResponse = new SignBlobResponse { KeyId = "key_id2691f630", SignedBlob = proto::ByteString.CopyFromUtf8("signed_blob0afddec9"), }; mockGrpcClient.Setup(x => x.SignBlob(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); IAMCredentialsClient client = new IAMCredentialsClientImpl(mockGrpcClient.Object, null); SignBlobResponse response = client.SignBlob(request.ServiceAccountName, request.Delegates, request.Payload); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task SignBlobResourceNamesAsync() { moq::Mock <IAMCredentials.IAMCredentialsClient> mockGrpcClient = new moq::Mock <IAMCredentials.IAMCredentialsClient>(moq::MockBehavior.Strict); SignBlobRequest request = new SignBlobRequest { ServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"), Delegates = { "delegates331d18f6", }, Payload = proto::ByteString.CopyFromUtf8("payloadf43c1c32"), }; SignBlobResponse expectedResponse = new SignBlobResponse { KeyId = "key_id2691f630", SignedBlob = proto::ByteString.CopyFromUtf8("signed_blob0afddec9"), }; mockGrpcClient.Setup(x => x.SignBlobAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <SignBlobResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); IAMCredentialsClient client = new IAMCredentialsClientImpl(mockGrpcClient.Object, null); SignBlobResponse responseCallSettings = await client.SignBlobAsync(request.ServiceAccountName, request.Delegates, request.Payload, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); SignBlobResponse responseCancellationToken = await client.SignBlobAsync(request.ServiceAccountName, request.Delegates, request.Payload, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task <string> CreateSignatureAsync(byte[] data, CancellationToken cancellationToken) { ProjectsResource.ServiceAccountsResource.SignBlobRequest request = CreateRequest(data); SignBlobResponse response = await request.ExecuteAsync(cancellationToken).ConfigureAwait(false); return(response.Signature); }
/// <summary>Snippet for SignBlob</summary> public void SignBlobResourceNames() { // Snippet: SignBlob(ServiceAccountName, IEnumerable<string>, ByteString, CallSettings) // Create client IAMCredentialsClient iAMCredentialsClient = IAMCredentialsClient.Create(); // Initialize request argument(s) ServiceAccountName name = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"); IEnumerable <string> delegates = new string[] { "", }; ByteString payload = ByteString.Empty; // Make the request SignBlobResponse response = iAMCredentialsClient.SignBlob(name, delegates, payload); // End snippet }
/// <summary>Snippet for SignBlobAsync</summary> public async Task SignBlobResourceNamesAsync() { // Snippet: SignBlobAsync(ServiceAccountName, IEnumerable<string>, ByteString, CallSettings) // Additional: SignBlobAsync(ServiceAccountName, IEnumerable<string>, ByteString, CancellationToken) // Create client IAMCredentialsClient iAMCredentialsClient = await IAMCredentialsClient.CreateAsync(); // Initialize request argument(s) ServiceAccountName name = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"); IEnumerable <string> delegates = new string[] { "", }; ByteString payload = ByteString.Empty; // Make the request SignBlobResponse response = await iAMCredentialsClient.SignBlobAsync(name, delegates, payload); // End snippet }
/// <summary>Snippet for SignBlob</summary> public void SignBlobRequestObject() { // Snippet: SignBlob(SignBlobRequest, CallSettings) // Create client IAMCredentialsClient iAMCredentialsClient = IAMCredentialsClient.Create(); // Initialize request argument(s) SignBlobRequest request = new SignBlobRequest { ServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"), Delegates = { "", }, Payload = ByteString.Empty, }; // Make the request SignBlobResponse response = iAMCredentialsClient.SignBlob(request); // End snippet }
/// <summary>Snippet for SignBlobAsync</summary> public async Task SignBlobRequestObjectAsync() { // Snippet: SignBlobAsync(SignBlobRequest, CallSettings) // Additional: SignBlobAsync(SignBlobRequest, CancellationToken) // Create client IAMCredentialsClient iAMCredentialsClient = await IAMCredentialsClient.CreateAsync(); // Initialize request argument(s) SignBlobRequest request = new SignBlobRequest { ServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"), Delegates = { "", }, Payload = ByteString.Empty, }; // Make the request SignBlobResponse response = await iAMCredentialsClient.SignBlobAsync(request); // End snippet }