public void SetIamPolicy()
        {
            moq::Mock <ContainerAnalysis.ContainerAnalysisClient> mockGrpcClient = new moq::Mock <ContainerAnalysis.ContainerAnalysisClient>(moq::MockBehavior.Strict);
            gciv::SetIamPolicyRequest request = new gciv::SetIamPolicyRequest
            {
                ResourceAsResourceName = new gax::UnparsedResourceName("a/wildcard/resource"),
                Policy = new gciv::Policy(),
            };
            gciv::Policy expectedResponse = new gciv::Policy
            {
                Version  = 271578922,
                Etag     = proto::ByteString.CopyFromUtf8("etage8ad7218"),
                Bindings =
                {
                    new gciv::Binding(),
                },
            };

            mockGrpcClient.Setup(x => x.SetIamPolicy(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            ContainerAnalysisClient client   = new ContainerAnalysisClientImpl(mockGrpcClient.Object, null);
            gciv::Policy            response = client.SetIamPolicy(request.Resource, request.Policy);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async stt::Task TestIamPermissionsResourceNamesAsync()
        {
            moq::Mock <ContainerAnalysis.ContainerAnalysisClient> mockGrpcClient = new moq::Mock <ContainerAnalysis.ContainerAnalysisClient>(moq::MockBehavior.Strict);
            gciv::TestIamPermissionsRequest request = new gciv::TestIamPermissionsRequest
            {
                ResourceAsResourceName = new gax::UnparsedResourceName("a/wildcard/resource"),
                Permissions            =
                {
                    "permissions535a2741",
                },
            };
            gciv::TestIamPermissionsResponse expectedResponse = new gciv::TestIamPermissionsResponse
            {
                Permissions =
                {
                    "permissions535a2741",
                },
            };

            mockGrpcClient.Setup(x => x.TestIamPermissionsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gciv::TestIamPermissionsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            ContainerAnalysisClient          client = new ContainerAnalysisClientImpl(mockGrpcClient.Object, null);
            gciv::TestIamPermissionsResponse responseCallSettings = await client.TestIamPermissionsAsync(request.ResourceAsResourceName, request.Permissions, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            gciv::TestIamPermissionsResponse responseCancellationToken = await client.TestIamPermissionsAsync(request.ResourceAsResourceName, request.Permissions, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public async stt::Task GetVulnerabilityOccurrencesSummaryResourceNamesAsync()
        {
            moq::Mock <ContainerAnalysis.ContainerAnalysisClient> mockGrpcClient = new moq::Mock <ContainerAnalysis.ContainerAnalysisClient>(moq::MockBehavior.Strict);
            GetVulnerabilityOccurrencesSummaryRequest             request        = new GetVulnerabilityOccurrencesSummaryRequest
            {
                ParentAsProjectName = gagr::ProjectName.FromProject("[PROJECT]"),
                Filter = "filtere47ac9b2",
            };
            VulnerabilityOccurrencesSummary expectedResponse = new VulnerabilityOccurrencesSummary
            {
                Counts =
                {
                    new VulnerabilityOccurrencesSummary.Types.FixableTotalByDigest(),
                },
            };

            mockGrpcClient.Setup(x => x.GetVulnerabilityOccurrencesSummaryAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <VulnerabilityOccurrencesSummary>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            ContainerAnalysisClient         client = new ContainerAnalysisClientImpl(mockGrpcClient.Object, null);
            VulnerabilityOccurrencesSummary responseCallSettings = await client.GetVulnerabilityOccurrencesSummaryAsync(request.ParentAsProjectName, request.Filter, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            VulnerabilityOccurrencesSummary responseCancellationToken = await client.GetVulnerabilityOccurrencesSummaryAsync(request.ParentAsProjectName, request.Filter, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public async stt::Task SetIamPolicyRequestObjectAsync()
        {
            moq::Mock <ContainerAnalysis.ContainerAnalysisClient> mockGrpcClient = new moq::Mock <ContainerAnalysis.ContainerAnalysisClient>(moq::MockBehavior.Strict);
            gciv::SetIamPolicyRequest request = new gciv::SetIamPolicyRequest
            {
                ResourceAsResourceName = new gax::UnparsedResourceName("a/wildcard/resource"),
                Policy = new gciv::Policy(),
            };
            gciv::Policy expectedResponse = new gciv::Policy
            {
                Version  = 271578922,
                Etag     = proto::ByteString.CopyFromUtf8("etage8ad7218"),
                Bindings =
                {
                    new gciv::Binding(),
                },
            };

            mockGrpcClient.Setup(x => x.SetIamPolicyAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gciv::Policy>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            ContainerAnalysisClient client = new ContainerAnalysisClientImpl(mockGrpcClient.Object, null);
            gciv::Policy            responseCallSettings = await client.SetIamPolicyAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            gciv::Policy responseCancellationToken = await client.SetIamPolicyAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public void TestIamPermissionsResourceNames()
        {
            moq::Mock <ContainerAnalysis.ContainerAnalysisClient> mockGrpcClient = new moq::Mock <ContainerAnalysis.ContainerAnalysisClient>(moq::MockBehavior.Strict);
            gciv::TestIamPermissionsRequest request = new gciv::TestIamPermissionsRequest
            {
                ResourceAsResourceName = new gax::UnparsedResourceName("a/wildcard/resource"),
                Permissions            =
                {
                    "permissions535a2741",
                },
            };
            gciv::TestIamPermissionsResponse expectedResponse = new gciv::TestIamPermissionsResponse
            {
                Permissions =
                {
                    "permissions535a2741",
                },
            };

            mockGrpcClient.Setup(x => x.TestIamPermissions(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            ContainerAnalysisClient          client   = new ContainerAnalysisClientImpl(mockGrpcClient.Object, null);
            gciv::TestIamPermissionsResponse response = client.TestIamPermissions(request.ResourceAsResourceName, request.Permissions);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 6
0
        public async Task TestIamPermissionsAsync2()
        {
            Mock <ContainerAnalysis.ContainerAnalysisClient> mockGrpcClient = new Mock <ContainerAnalysis.ContainerAnalysisClient>(MockBehavior.Strict);
            TestIamPermissionsRequest request = new TestIamPermissionsRequest
            {
                ResourceAsResourceName = IamResourceNameOneof.From(new NoteName("[PROJECT]", "[NOTE]")),
                Permissions            = { },
            };
            TestIamPermissionsResponse expectedResponse = new TestIamPermissionsResponse();

            mockGrpcClient.Setup(x => x.TestIamPermissionsAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <TestIamPermissionsResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            ContainerAnalysisClient    client   = new ContainerAnalysisClientImpl(mockGrpcClient.Object, null);
            TestIamPermissionsResponse response = await client.TestIamPermissionsAsync(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 7
0
        public void TestIamPermissions()
        {
            Mock <ContainerAnalysis.ContainerAnalysisClient> mockGrpcClient = new Mock <ContainerAnalysis.ContainerAnalysisClient>(MockBehavior.Strict);
            TestIamPermissionsRequest expectedRequest = new TestIamPermissionsRequest
            {
                ResourceAsResourceName = IamResourceNameOneof.From(new NoteName("[PROJECT]", "[NOTE]")),
                Permissions            = { },
            };
            TestIamPermissionsResponse expectedResponse = new TestIamPermissionsResponse();

            mockGrpcClient.Setup(x => x.TestIamPermissions(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            ContainerAnalysisClient    client      = new ContainerAnalysisClientImpl(mockGrpcClient.Object, null);
            IamResourceNameOneof       resource    = IamResourceNameOneof.From(new NoteName("[PROJECT]", "[NOTE]"));
            IEnumerable <string>       permissions = new List <string>();
            TestIamPermissionsResponse response    = client.TestIamPermissions(resource, permissions);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 8
0
        public async Task GetIamPolicyAsync2()
        {
            Mock <ContainerAnalysis.ContainerAnalysisClient> mockGrpcClient = new Mock <ContainerAnalysis.ContainerAnalysisClient>(MockBehavior.Strict);
            GetIamPolicyRequest request = new GetIamPolicyRequest
            {
                ResourceAsResourceName = IamResourceNameOneof.From(new NoteName("[PROJECT]", "[NOTE]")),
            };
            Policy expectedResponse = new Policy
            {
                Version = 351608024,
                Etag    = ByteString.CopyFromUtf8("21"),
            };

            mockGrpcClient.Setup(x => x.GetIamPolicyAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <Policy>(Task.FromResult(expectedResponse), null, null, null, null));
            ContainerAnalysisClient client = new ContainerAnalysisClientImpl(mockGrpcClient.Object, null);
            Policy response = await client.GetIamPolicyAsync(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 9
0
        public void SetIamPolicy2()
        {
            Mock <ContainerAnalysis.ContainerAnalysisClient> mockGrpcClient = new Mock <ContainerAnalysis.ContainerAnalysisClient>(MockBehavior.Strict);
            SetIamPolicyRequest request = new SetIamPolicyRequest
            {
                ResourceAsResourceName = IamResourceNameOneof.From(new NoteName("[PROJECT]", "[NOTE]")),
                Policy = new Policy(),
            };
            Policy expectedResponse = new Policy
            {
                Version = 351608024,
                Etag    = ByteString.CopyFromUtf8("21"),
            };

            mockGrpcClient.Setup(x => x.SetIamPolicy(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            ContainerAnalysisClient client = new ContainerAnalysisClientImpl(mockGrpcClient.Object, null);
            Policy response = client.SetIamPolicy(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void GetVulnerabilityOccurrencesSummaryResourceNames()
        {
            moq::Mock <ContainerAnalysis.ContainerAnalysisClient> mockGrpcClient = new moq::Mock <ContainerAnalysis.ContainerAnalysisClient>(moq::MockBehavior.Strict);
            GetVulnerabilityOccurrencesSummaryRequest             request        = new GetVulnerabilityOccurrencesSummaryRequest
            {
                ParentAsProjectName = gagr::ProjectName.FromProject("[PROJECT]"),
                Filter = "filtere47ac9b2",
            };
            VulnerabilityOccurrencesSummary expectedResponse = new VulnerabilityOccurrencesSummary
            {
                Counts =
                {
                    new VulnerabilityOccurrencesSummary.Types.FixableTotalByDigest(),
                },
            };

            mockGrpcClient.Setup(x => x.GetVulnerabilityOccurrencesSummary(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            ContainerAnalysisClient         client   = new ContainerAnalysisClientImpl(mockGrpcClient.Object, null);
            VulnerabilityOccurrencesSummary response = client.GetVulnerabilityOccurrencesSummary(request.ParentAsProjectName, request.Filter);

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