Exemple #1
0
        public void GetClientTlsPolicyResourceNames()
        {
            moq::Mock <NetworkSecurity.NetworkSecurityClient> mockGrpcClient = new moq::Mock <NetworkSecurity.NetworkSecurityClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetClientTlsPolicyRequest request = new GetClientTlsPolicyRequest
            {
                ClientTlsPolicyName = ClientTlsPolicyName.FromProjectLocationClientTlsPolicy("[PROJECT]", "[LOCATION]", "[CLIENT_TLS_POLICY]"),
            };
            ClientTlsPolicy expectedResponse = new ClientTlsPolicy
            {
                ClientTlsPolicyName = ClientTlsPolicyName.FromProjectLocationClientTlsPolicy("[PROJECT]", "[LOCATION]", "[CLIENT_TLS_POLICY]"),
                Description         = "description2cf9da67",
                CreateTime          = new wkt::Timestamp(),
                UpdateTime          = new wkt::Timestamp(),
                Labels =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                Sni = "snif6a20ff7",
                ClientCertificate  = new CertificateProvider(),
                ServerValidationCa = { new ValidationCA(), },
            };

            mockGrpcClient.Setup(x => x.GetClientTlsPolicy(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            NetworkSecurityClient client   = new NetworkSecurityClientImpl(mockGrpcClient.Object, null);
            ClientTlsPolicy       response = client.GetClientTlsPolicy(request.ClientTlsPolicyName);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Exemple #2
0
        public async stt::Task GetClientTlsPolicyAsync()
        {
            moq::Mock <NetworkSecurity.NetworkSecurityClient> mockGrpcClient = new moq::Mock <NetworkSecurity.NetworkSecurityClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetClientTlsPolicyRequest request = new GetClientTlsPolicyRequest
            {
                ClientTlsPolicyName = ClientTlsPolicyName.FromProjectLocationClientTlsPolicy("[PROJECT]", "[LOCATION]", "[CLIENT_TLS_POLICY]"),
            };
            ClientTlsPolicy expectedResponse = new ClientTlsPolicy
            {
                ClientTlsPolicyName = ClientTlsPolicyName.FromProjectLocationClientTlsPolicy("[PROJECT]", "[LOCATION]", "[CLIENT_TLS_POLICY]"),
                Description         = "description2cf9da67",
                CreateTime          = new wkt::Timestamp(),
                UpdateTime          = new wkt::Timestamp(),
                Labels =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                Sni = "snif6a20ff7",
                ClientCertificate  = new CertificateProvider(),
                ServerValidationCa = { new ValidationCA(), },
            };

            mockGrpcClient.Setup(x => x.GetClientTlsPolicyAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <ClientTlsPolicy>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            NetworkSecurityClient client = new NetworkSecurityClientImpl(mockGrpcClient.Object, null);
            ClientTlsPolicy       responseCallSettings = await client.GetClientTlsPolicyAsync(request.Name, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            ClientTlsPolicy responseCancellationToken = await client.GetClientTlsPolicyAsync(request.Name, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }