示例#1
0
        public void SignJwtResourceNames()
        {
            moq::Mock <IAMCredentials.IAMCredentialsClient> mockGrpcClient = new moq::Mock <IAMCredentials.IAMCredentialsClient>(moq::MockBehavior.Strict);
            SignJwtRequest request = new SignJwtRequest
            {
                ServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"),
                Delegates          =
                {
                    "delegates331d18f6",
                },
                Payload = "payloadf43c1c32",
            };
            SignJwtResponse expectedResponse = new SignJwtResponse
            {
                KeyId     = "key_id2691f630",
                SignedJwt = "signed_jwt09d786db",
            };

            mockGrpcClient.Setup(x => x.SignJwt(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            IAMCredentialsClient client   = new IAMCredentialsClientImpl(mockGrpcClient.Object, null);
            SignJwtResponse      response = client.SignJwt(request.ServiceAccountName, request.Delegates, request.Payload);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
示例#2
0
        public async stt::Task SignJwtResourceNamesAsync()
        {
            moq::Mock <IAMCredentials.IAMCredentialsClient> mockGrpcClient = new moq::Mock <IAMCredentials.IAMCredentialsClient>(moq::MockBehavior.Strict);
            SignJwtRequest request = new SignJwtRequest
            {
                ServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"),
                Delegates          =
                {
                    "delegates331d18f6",
                },
                Payload = "payloadf43c1c32",
            };
            SignJwtResponse expectedResponse = new SignJwtResponse
            {
                KeyId     = "key_id2691f630",
                SignedJwt = "signed_jwt09d786db",
            };

            mockGrpcClient.Setup(x => x.SignJwtAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <SignJwtResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            IAMCredentialsClient client = new IAMCredentialsClientImpl(mockGrpcClient.Object, null);
            SignJwtResponse      responseCallSettings = await client.SignJwtAsync(request.ServiceAccountName, request.Delegates, request.Payload, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            SignJwtResponse responseCancellationToken = await client.SignJwtAsync(request.ServiceAccountName, request.Delegates, request.Payload, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
示例#3
0
 /// <summary>Snippet for SignJwt</summary>
 public void SignJwtResourceNames()
 {
     // Snippet: SignJwt(ServiceAccountName, IEnumerable<string>, string, CallSettings)
     // Create client
     IAMCredentialsClient iAMCredentialsClient = IAMCredentialsClient.Create();
     // Initialize request argument(s)
     ServiceAccountName   name      = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]");
     IEnumerable <string> delegates = new string[] { "", };
     string payload = "";
     // Make the request
     SignJwtResponse response = iAMCredentialsClient.SignJwt(name, delegates, payload);
     // End snippet
 }
示例#4
0
 /// <summary>Snippet for SignJwt</summary>
 public void SignJwt()
 {
     // Snippet: SignJwt(string, IEnumerable<string>, string, CallSettings)
     // Create client
     IAMCredentialsClient iAMCredentialsClient = IAMCredentialsClient.Create();
     // Initialize request argument(s)
     string name = "projects/[PROJECT]/serviceAccounts/[SERVICE_ACCOUNT]";
     IEnumerable <string> delegates = new string[] { "", };
     string payload = "";
     // Make the request
     SignJwtResponse response = iAMCredentialsClient.SignJwt(name, delegates, payload);
     // End snippet
 }
示例#5
0
        /// <summary>Snippet for SignJwtAsync</summary>
        public async Task SignJwtResourceNamesAsync()
        {
            // Snippet: SignJwtAsync(ServiceAccountName, IEnumerable<string>, string, CallSettings)
            // Additional: SignJwtAsync(ServiceAccountName, IEnumerable<string>, string, CancellationToken)
            // Create client
            IAMCredentialsClient iAMCredentialsClient = await IAMCredentialsClient.CreateAsync();

            // Initialize request argument(s)
            ServiceAccountName   name      = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]");
            IEnumerable <string> delegates = new string[] { "", };
            string payload = "";
            // Make the request
            SignJwtResponse response = await iAMCredentialsClient.SignJwtAsync(name, delegates, payload);

            // End snippet
        }
示例#6
0
 /// <summary>Snippet for SignJwt</summary>
 public void SignJwtRequestObject()
 {
     // Snippet: SignJwt(SignJwtRequest, CallSettings)
     // Create client
     IAMCredentialsClient iAMCredentialsClient = IAMCredentialsClient.Create();
     // Initialize request argument(s)
     SignJwtRequest request = new SignJwtRequest
     {
         ServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"),
         Delegates          = { "", },
         Payload            = "",
     };
     // Make the request
     SignJwtResponse response = iAMCredentialsClient.SignJwt(request);
     // End snippet
 }
示例#7
0
        /// <summary>Snippet for SignJwtAsync</summary>
        public async Task SignJwtRequestObjectAsync()
        {
            // Snippet: SignJwtAsync(SignJwtRequest, CallSettings)
            // Additional: SignJwtAsync(SignJwtRequest, CancellationToken)
            // Create client
            IAMCredentialsClient iAMCredentialsClient = await IAMCredentialsClient.CreateAsync();

            // Initialize request argument(s)
            SignJwtRequest request = new SignJwtRequest
            {
                ServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"),
                Delegates          = { "", },
                Payload            = "",
            };
            // Make the request
            SignJwtResponse response = await iAMCredentialsClient.SignJwtAsync(request);

            // End snippet
        }