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(); }
public async stt::Task GenerateIdTokenResourceNamesAsync() { moq::Mock <IAMCredentials.IAMCredentialsClient> mockGrpcClient = new moq::Mock <IAMCredentials.IAMCredentialsClient>(moq::MockBehavior.Strict); GenerateIdTokenRequest request = new GenerateIdTokenRequest { ServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"), Delegates = { "delegates331d18f6", }, Audience = "audience986f1fe3", IncludeEmail = false, }; GenerateIdTokenResponse expectedResponse = new GenerateIdTokenResponse { Token = "tokena18da094", }; mockGrpcClient.Setup(x => x.GenerateIdTokenAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <GenerateIdTokenResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); IAMCredentialsClient client = new IAMCredentialsClientImpl(mockGrpcClient.Object, null); GenerateIdTokenResponse responseCallSettings = await client.GenerateIdTokenAsync(request.ServiceAccountName, request.Delegates, request.Audience, request.IncludeEmail, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); GenerateIdTokenResponse responseCancellationToken = await client.GenerateIdTokenAsync(request.ServiceAccountName, request.Delegates, request.Audience, request.IncludeEmail, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void SignBlobRequestObject() { 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); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task GenerateAccessTokenRequestObjectAsync() { moq::Mock <IAMCredentials.IAMCredentialsClient> mockGrpcClient = new moq::Mock <IAMCredentials.IAMCredentialsClient>(moq::MockBehavior.Strict); GenerateAccessTokenRequest request = new GenerateAccessTokenRequest { ServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"), Delegates = { "delegates331d18f6", }, Scope = { "scope14fda131", }, Lifetime = new wkt::Duration(), }; GenerateAccessTokenResponse expectedResponse = new GenerateAccessTokenResponse { AccessToken = "access_token85826cd8", ExpireTime = new wkt::Timestamp(), }; mockGrpcClient.Setup(x => x.GenerateAccessTokenAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <GenerateAccessTokenResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); IAMCredentialsClient client = new IAMCredentialsClientImpl(mockGrpcClient.Object, null); GenerateAccessTokenResponse responseCallSettings = await client.GenerateAccessTokenAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); GenerateAccessTokenResponse responseCancellationToken = await client.GenerateAccessTokenAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
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(); }
public void GenerateIdTokenResourceNames() { moq::Mock <IAMCredentials.IAMCredentialsClient> mockGrpcClient = new moq::Mock <IAMCredentials.IAMCredentialsClient>(moq::MockBehavior.Strict); GenerateIdTokenRequest request = new GenerateIdTokenRequest { ServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"), Delegates = { "delegates331d18f6", }, Audience = "audience986f1fe3", IncludeEmail = false, }; GenerateIdTokenResponse expectedResponse = new GenerateIdTokenResponse { Token = "tokena18da094", }; mockGrpcClient.Setup(x => x.GenerateIdToken(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); IAMCredentialsClient client = new IAMCredentialsClientImpl(mockGrpcClient.Object, null); GenerateIdTokenResponse response = client.GenerateIdToken(request.ServiceAccountName, request.Delegates, request.Audience, request.IncludeEmail); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void GenerateAccessToken() { moq::Mock <IAMCredentials.IAMCredentialsClient> mockGrpcClient = new moq::Mock <IAMCredentials.IAMCredentialsClient>(moq::MockBehavior.Strict); GenerateAccessTokenRequest request = new GenerateAccessTokenRequest { ServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"), Delegates = { "delegates331d18f6", }, Scope = { "scope14fda131", }, Lifetime = new wkt::Duration(), }; GenerateAccessTokenResponse expectedResponse = new GenerateAccessTokenResponse { AccessToken = "access_token85826cd8", ExpireTime = new wkt::Timestamp(), }; mockGrpcClient.Setup(x => x.GenerateAccessToken(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); IAMCredentialsClient client = new IAMCredentialsClientImpl(mockGrpcClient.Object, null); GenerateAccessTokenResponse response = client.GenerateAccessToken(request.Name, request.Delegates, request.Scope, request.Lifetime); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <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 }
public async stt::Task GetApiConfigRequestObjectAsync() { moq::Mock <ApiGatewayService.ApiGatewayServiceClient> mockGrpcClient = new moq::Mock <ApiGatewayService.ApiGatewayServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetApiConfigRequest request = new GetApiConfigRequest { ApiConfigName = ApiConfigName.FromProjectApiApiConfig("[PROJECT]", "[API]", "[API_CONFIG]"), View = GetApiConfigRequest.Types.ConfigView.Basic, }; ApiConfig expectedResponse = new ApiConfig { ApiConfigName = ApiConfigName.FromProjectApiApiConfig("[PROJECT]", "[API]", "[API_CONFIG]"), CreateTime = new wkt::Timestamp(), UpdateTime = new wkt::Timestamp(), Labels = { { "key8a0b6e3c", "value60c16320" }, }, DisplayName = "display_name137f65c2", State = ApiConfig.Types.State.Activating, OpenapiDocuments = { new ApiConfig.Types.OpenApiDocument(), }, GrpcServices = { new ApiConfig.Types.GrpcServiceDefinition(), }, ManagedServiceConfigs = { new ApiConfig.Types.File(), }, ServiceConfigIdAsServiceName = ServiceName.FromServiceConfig("[SERVICE]", "[CONFIG]"), GatewayServiceAccountAsServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"), }; mockGrpcClient.Setup(x => x.GetApiConfigAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <ApiConfig>(stt::Task.FromResult(expectedResponse), null, null, null, null)); ApiGatewayServiceClient client = new ApiGatewayServiceClientImpl(mockGrpcClient.Object, null); ApiConfig responseCallSettings = await client.GetApiConfigAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); ApiConfig responseCancellationToken = await client.GetApiConfigAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for GenerateIdToken</summary> public void GenerateIdTokenResourceNames() { // Snippet: GenerateIdToken(ServiceAccountName, IEnumerable<string>, string, bool, CallSettings) // Create client IAMCredentialsClient iAMCredentialsClient = IAMCredentialsClient.Create(); // Initialize request argument(s) ServiceAccountName name = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"); IEnumerable <string> delegates = new string[] { "", }; string audience = ""; bool includeEmail = false; // Make the request GenerateIdTokenResponse response = iAMCredentialsClient.GenerateIdToken(name, delegates, audience, includeEmail); // End snippet }
/// <summary>Snippet for GenerateAccessToken</summary> public void GenerateAccessTokenResourceNames() { // Snippet: GenerateAccessToken(ServiceAccountName, IEnumerable<string>, IEnumerable<string>, Duration, CallSettings) // Create client IAMCredentialsClient iAMCredentialsClient = IAMCredentialsClient.Create(); // Initialize request argument(s) ServiceAccountName name = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"); IEnumerable <string> delegates = new string[] { "", }; IEnumerable <string> scope = new string[] { "", }; Duration lifetime = new Duration(); // Make the request GenerateAccessTokenResponse response = iAMCredentialsClient.GenerateAccessToken(name, delegates, scope, lifetime); // End snippet }
/// <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 }
/// <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 }
/// <summary>Snippet for GenerateIdToken</summary> public void GenerateIdTokenRequestObject() { // Snippet: GenerateIdToken(GenerateIdTokenRequest, CallSettings) // Create client IAMCredentialsClient iAMCredentialsClient = IAMCredentialsClient.Create(); // Initialize request argument(s) GenerateIdTokenRequest request = new GenerateIdTokenRequest { ServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"), Delegates = { "", }, Audience = "", IncludeEmail = false, }; // Make the request GenerateIdTokenResponse response = iAMCredentialsClient.GenerateIdToken(request); // End snippet }
/// <summary>Snippet for GenerateAccessToken</summary> public void GenerateAccessTokenRequestObject() { // Snippet: GenerateAccessToken(GenerateAccessTokenRequest, CallSettings) // Create client IAMCredentialsClient iAMCredentialsClient = IAMCredentialsClient.Create(); // Initialize request argument(s) GenerateAccessTokenRequest request = new GenerateAccessTokenRequest { ServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"), Delegates = { "", }, Scope = { "", }, Lifetime = new Duration(), }; // Make the request GenerateAccessTokenResponse response = iAMCredentialsClient.GenerateAccessToken(request); // End snippet }
public void GetApiConfigResourceNames() { moq::Mock <ApiGatewayService.ApiGatewayServiceClient> mockGrpcClient = new moq::Mock <ApiGatewayService.ApiGatewayServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetApiConfigRequest request = new GetApiConfigRequest { ApiConfigName = ApiConfigName.FromProjectApiApiConfig("[PROJECT]", "[API]", "[API_CONFIG]"), }; ApiConfig expectedResponse = new ApiConfig { ApiConfigName = ApiConfigName.FromProjectApiApiConfig("[PROJECT]", "[API]", "[API_CONFIG]"), CreateTime = new wkt::Timestamp(), UpdateTime = new wkt::Timestamp(), Labels = { { "key8a0b6e3c", "value60c16320" }, }, DisplayName = "display_name137f65c2", State = ApiConfig.Types.State.Activating, OpenapiDocuments = { new ApiConfig.Types.OpenApiDocument(), }, GrpcServices = { new ApiConfig.Types.GrpcServiceDefinition(), }, ManagedServiceConfigs = { new ApiConfig.Types.File(), }, ServiceConfigIdAsServiceName = ServiceName.FromServiceConfig("[SERVICE]", "[CONFIG]"), GatewayServiceAccountAsServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"), }; mockGrpcClient.Setup(x => x.GetApiConfig(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); ApiGatewayServiceClient client = new ApiGatewayServiceClientImpl(mockGrpcClient.Object, null); ApiConfig response = client.GetApiConfig(request.ApiConfigName); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <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 }
/// <summary>Snippet for GenerateIdTokenAsync</summary> public async Task GenerateIdTokenRequestObjectAsync() { // Snippet: GenerateIdTokenAsync(GenerateIdTokenRequest, CallSettings) // Additional: GenerateIdTokenAsync(GenerateIdTokenRequest, CancellationToken) // Create client IAMCredentialsClient iAMCredentialsClient = await IAMCredentialsClient.CreateAsync(); // Initialize request argument(s) GenerateIdTokenRequest request = new GenerateIdTokenRequest { ServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"), Delegates = { "", }, Audience = "", IncludeEmail = false, }; // Make the request GenerateIdTokenResponse response = await iAMCredentialsClient.GenerateIdTokenAsync(request); // End snippet }
public async stt::Task GetTriggerRequestObjectAsync() { moq::Mock <Eventarc.EventarcClient> mockGrpcClient = new moq::Mock <Eventarc.EventarcClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetTriggerRequest request = new GetTriggerRequest { TriggerName = TriggerName.FromProjectLocationTrigger("[PROJECT]", "[LOCATION]", "[TRIGGER]"), }; Trigger expectedResponse = new Trigger { TriggerName = TriggerName.FromProjectLocationTrigger("[PROJECT]", "[LOCATION]", "[TRIGGER]"), Uid = "uida2d37198", CreateTime = new wkt::Timestamp(), UpdateTime = new wkt::Timestamp(), EventFilters = { new EventFilter(), }, ServiceAccountAsServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"), Destination = new Destination(), Transport = new Transport(), Labels = { { "key8a0b6e3c", "value60c16320" }, }, Etag = "etage8ad7218", }; mockGrpcClient.Setup(x => x.GetTriggerAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Trigger>(stt::Task.FromResult(expectedResponse), null, null, null, null)); EventarcClient client = new EventarcClientImpl(mockGrpcClient.Object, null); Trigger responseCallSettings = await client.GetTriggerAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Trigger responseCancellationToken = await client.GetTriggerAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GetTriggerResourceNames() { moq::Mock <Eventarc.EventarcClient> mockGrpcClient = new moq::Mock <Eventarc.EventarcClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetTriggerRequest request = new GetTriggerRequest { TriggerName = TriggerName.FromProjectLocationTrigger("[PROJECT]", "[LOCATION]", "[TRIGGER]"), }; Trigger expectedResponse = new Trigger { TriggerName = TriggerName.FromProjectLocationTrigger("[PROJECT]", "[LOCATION]", "[TRIGGER]"), Uid = "uida2d37198", CreateTime = new wkt::Timestamp(), UpdateTime = new wkt::Timestamp(), EventFilters = { new EventFilter(), }, ServiceAccountAsServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"), Destination = new Destination(), Transport = new Transport(), Labels = { { "key8a0b6e3c", "value60c16320" }, }, Etag = "etage8ad7218", }; mockGrpcClient.Setup(x => x.GetTrigger(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); EventarcClient client = new EventarcClientImpl(mockGrpcClient.Object, null); Trigger response = client.GetTrigger(request.TriggerName); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }