Beispiel #1
0
        public void UpdateKeyRequestObject()
        {
            moq::Mock <RecaptchaEnterpriseService.RecaptchaEnterpriseServiceClient> mockGrpcClient = new moq::Mock <RecaptchaEnterpriseService.RecaptchaEnterpriseServiceClient>(moq::MockBehavior.Strict);
            UpdateKeyRequest request = new UpdateKeyRequest
            {
                Key        = new Key(),
                UpdateMask = new wkt::FieldMask(),
            };
            Key expectedResponse = new Key
            {
                KeyName         = KeyName.FromProjectKey("[PROJECT]", "[KEY]"),
                DisplayName     = "display_name137f65c2",
                WebSettings     = new WebKeySettings(),
                AndroidSettings = new AndroidKeySettings(),
                IosSettings     = new IOSKeySettings(),
                Labels          =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                CreateTime = new wkt::Timestamp(),
            };

            mockGrpcClient.Setup(x => x.UpdateKey(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            RecaptchaEnterpriseServiceClient client = new RecaptchaEnterpriseServiceClientImpl(mockGrpcClient.Object, null);
            Key response = client.UpdateKey(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Beispiel #2
0
        public async stt::Task UpdateKeyRequestObjectAsync()
        {
            moq::Mock <RecaptchaEnterpriseService.RecaptchaEnterpriseServiceClient> mockGrpcClient = new moq::Mock <RecaptchaEnterpriseService.RecaptchaEnterpriseServiceClient>(moq::MockBehavior.Strict);
            UpdateKeyRequest request = new UpdateKeyRequest
            {
                Key        = new Key(),
                UpdateMask = new wkt::FieldMask(),
            };
            Key expectedResponse = new Key
            {
                KeyName         = KeyName.FromProjectKey("[PROJECT]", "[KEY]"),
                DisplayName     = "display_name137f65c2",
                WebSettings     = new WebKeySettings(),
                AndroidSettings = new AndroidKeySettings(),
                IosSettings     = new IOSKeySettings(),
                Labels          =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                CreateTime = new wkt::Timestamp(),
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Key responseCancellationToken = await client.UpdateKeyAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Beispiel #3
0
        public ActionResult UpdateKey([FromBody] UpdateKeyRequest request)
        {
            string message = _keycontext.UpdateDataByKey(request.data, HttpContext.Request.Headers["Authorization"]);

            if (message == null)
            {
                return(BadRequest(new { error = "Error" }));
            }

            return(Ok(new { message }));
        }
Beispiel #4
0
 /// <summary>Snippet for UpdateKey</summary>
 public void UpdateKeyRequestObject()
 {
     // Snippet: UpdateKey(UpdateKeyRequest, CallSettings)
     // Create client
     RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient = RecaptchaEnterpriseServiceClient.Create();
     // Initialize request argument(s)
     UpdateKeyRequest request = new UpdateKeyRequest
     {
         Key        = new Key(),
         UpdateMask = new FieldMask(),
     };
     // Make the request
     Key response = recaptchaEnterpriseServiceClient.UpdateKey(request);
     // End snippet
 }
Beispiel #5
0
        /// <summary>Snippet for UpdateKeyAsync</summary>
        public async Task UpdateKeyRequestObjectAsync()
        {
            // Snippet: UpdateKeyAsync(UpdateKeyRequest, CallSettings)
            // Additional: UpdateKeyAsync(UpdateKeyRequest, CancellationToken)
            // Create client
            RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient = await RecaptchaEnterpriseServiceClient.CreateAsync();

            // Initialize request argument(s)
            UpdateKeyRequest request = new UpdateKeyRequest
            {
                Key        = new Key(),
                UpdateMask = new FieldMask(),
            };
            // Make the request
            Key response = await recaptchaEnterpriseServiceClient.UpdateKeyAsync(request);

            // End snippet
        }
Beispiel #6
0
        public static async Task UpdateKeyResetTags(KmsManagementClient kmsManagementClient, string keyId)
        {
            logger.Info("Update Key");

            Dictionary <string, string> freeformTags     = new Dictionary <string, string>();
            UpdateKeyDetails            updateKeyDetails = new UpdateKeyDetails
            {
                DisplayName  = "update-key-name",
                FreeformTags = freeformTags
            };
            UpdateKeyRequest updateKeyRequest = new UpdateKeyRequest
            {
                UpdateKeyDetails = updateKeyDetails,
                KeyId            = keyId
            };
            UpdateKeyResponse updateKeyResponse = await kmsManagementClient.UpdateKey(updateKeyRequest);

            logger.Info($"Updated key: {updateKeyResponse.Key.DisplayName}");
        }
Beispiel #7
0
        public static async Task UpdateKey(KmsManagementClient kmsManagementClient, string keyId)
        {
            logger.Info("Update Key");

            Dictionary <string, string> freeformTags = GetSampleFreeformTagData();

            freeformTags.Add("dummyfreeformkey3", "dummyfreeformvalue3");

            UpdateKeyDetails updateKeyDetails = new UpdateKeyDetails
            {
                DisplayName  = "update-key-name",
                FreeformTags = freeformTags
            };
            UpdateKeyRequest updateKeyRequest = new UpdateKeyRequest
            {
                UpdateKeyDetails = updateKeyDetails,
                KeyId            = keyId
            };
            UpdateKeyResponse updateKeyResponse = await kmsManagementClient.UpdateKey(updateKeyRequest);

            logger.Info($"Updated key: {updateKeyResponse.Key.DisplayName}");
        }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            UpdateKeyRequest request;

            try
            {
                request = new UpdateKeyRequest
                {
                    KeyId            = KeyId,
                    UpdateKeyDetails = UpdateKeyDetails,
                    IfMatch          = IfMatch,
                    OpcRequestId     = OpcRequestId
                };

                response = client.UpdateKey(request).GetAwaiter().GetResult();
                WriteOutput(response, response.Key);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
Beispiel #9
0
        public void TestUpdateKey()
        {
            var client      = new DefaultOneNETClient(url, appkey, "");
            var permissions = new List <Permission>
            {
                new Permission
                {
                    Access_Methods = new[]
                    {
                        HttpRequestMethod.Get.GetMethodString(),
                HttpRequestMethod.Post.GetMethodString(),
                HttpRequestMethod.Put.GetMethodString()
                    },
                    Resources = new List <KeyResource>
                    {
                        new KeyResource {
                            Dev_Id = "776938"
                        },
                        new KeyResource {
                            Dev_Id = "776941"
                        }
                    }
                }
            };
            var data = new ApiKeyInfo
            {
                Title       = "test update key from C#",
                Permissions = permissions
            };
            var req = new UpdateKeyRequest {
                KeyString = "jb3idOcNvc3Tv=WtoBLBLPYgVyg=", KeyInfo = data
            };
            var rsp = client.Execute(req);

            Assert.IsFalse(rsp.IsError);
        }