Exemplo n.º 1
0
        public void GetServerTlsPolicyResourceNames()
        {
            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);
            GetServerTlsPolicyRequest request = new GetServerTlsPolicyRequest
            {
                ServerTlsPolicyName = ServerTlsPolicyName.FromProjectLocationServerTlsPolicy("[PROJECT]", "[LOCATION]", "[SERVER_TLS_POLICY]"),
            };
            ServerTlsPolicy expectedResponse = new ServerTlsPolicy
            {
                ServerTlsPolicyName = ServerTlsPolicyName.FromProjectLocationServerTlsPolicy("[PROJECT]", "[LOCATION]", "[SERVER_TLS_POLICY]"),
                Description         = "description2cf9da67",
                CreateTime          = new wkt::Timestamp(),
                UpdateTime          = new wkt::Timestamp(),
                Labels =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                AllowOpen         = false,
                ServerCertificate = new CertificateProvider(),
                MtlsPolicy        = new ServerTlsPolicy.Types.MTLSPolicy(),
            };

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

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Exemplo n.º 2
0
        public async stt::Task GetServerTlsPolicyAsync()
        {
            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);
            GetServerTlsPolicyRequest request = new GetServerTlsPolicyRequest
            {
                ServerTlsPolicyName = ServerTlsPolicyName.FromProjectLocationServerTlsPolicy("[PROJECT]", "[LOCATION]", "[SERVER_TLS_POLICY]"),
            };
            ServerTlsPolicy expectedResponse = new ServerTlsPolicy
            {
                ServerTlsPolicyName = ServerTlsPolicyName.FromProjectLocationServerTlsPolicy("[PROJECT]", "[LOCATION]", "[SERVER_TLS_POLICY]"),
                Description         = "description2cf9da67",
                CreateTime          = new wkt::Timestamp(),
                UpdateTime          = new wkt::Timestamp(),
                Labels =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                AllowOpen         = false,
                ServerCertificate = new CertificateProvider(),
                MtlsPolicy        = new ServerTlsPolicy.Types.MTLSPolicy(),
            };

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

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

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