public void GetKeyRequestObject() { moq::Mock <RecaptchaEnterpriseService.RecaptchaEnterpriseServiceClient> mockGrpcClient = new moq::Mock <RecaptchaEnterpriseService.RecaptchaEnterpriseServiceClient>(moq::MockBehavior.Strict); GetKeyRequest request = new GetKeyRequest { KeyName = KeyName.FromProjectKey("[PROJECT]", "[KEY]"), }; 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.GetKey(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); RecaptchaEnterpriseServiceClient client = new RecaptchaEnterpriseServiceClientImpl(mockGrpcClient.Object, null); Key response = client.GetKey(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task GetKeyRequestObjectAsync() { moq::Mock <RecaptchaEnterpriseService.RecaptchaEnterpriseServiceClient> mockGrpcClient = new moq::Mock <RecaptchaEnterpriseService.RecaptchaEnterpriseServiceClient>(moq::MockBehavior.Strict); GetKeyRequest request = new GetKeyRequest { KeyName = KeyName.FromProjectKey("[PROJECT]", "[KEY]"), }; 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.GetKeyAsync(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.GetKeyAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Key responseCancellationToken = await client.GetKeyAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public static ApiKey GetApiKey(string userName, string password) { var myBinding = new BasicHttpBinding() { Name = PartnerEndpointName }; var myEndpoint = new EndpointAddress("http://partnerapi.ekmpowershop1.com/v1.1/partnerapi.asmx"); //// Instantiate Soap Client to access shop data var shopClient = new PartnerAPISoapClient(myBinding, myEndpoint); shopClient.Endpoint.Binding = myBinding; shopClient.Endpoint.Contract.Name = PartnerContractName; shopClient.Endpoint.Name = PartnerEndpointName; // Form request to retrieve shop data (Shop details) var getKeyRequest = new GetKeyRequest(); // Your unique PartnerKey must be passed with each request getKeyRequest.PartnerKey = PartnerKey; // The customers ekmPowershop username getKeyRequest.UserName = userName; // The customers ekmPowershop password getKeyRequest.Password = password; // Retrieve shop data (Shop details) var getKeyResponse = shopClient.GetKey(getKeyRequest); return(getKeyResponse); }
public void TestMethod1() { GetKeyRequest request = new GetKeyRequest(); request.SealedKeyRequest = new SealedContentType(); //TODO:take sealed content KgssPortTypeClient kgss = new KgssPortTypeClient("kgss-79021802145"); GetKeyResponse response = kgss.GetKey(request); }
public void TestMethod1() { GetKeyRequest request = new GetKeyRequest(); request.SealedKeyRequest = new SealedContentType(); //TODO:take sealed content KgssPortTypeClient kgss = new KgssPortTypeClient("kgss-79021802145"); GetKeyResponse response = kgss.GetKey(request); }
/// <summary> /// Creates a waiter using the provided configuration. /// </summary> /// <param name="request">Request to send.</param> /// <param name="config">Wait Configuration</param> /// <param name="targetStates">Desired resource states. If multiple states are provided then the waiter will return once the resource reaches any of the provided states</param> /// <returns>a new Oci.common.Waiter instance</returns> public Waiter <GetKeyRequest, GetKeyResponse> ForKey(GetKeyRequest request, WaiterConfiguration config, params Key.LifecycleStateEnum[] targetStates) { var agent = new WaiterAgent <GetKeyRequest, GetKeyResponse>( request, request => client.GetKey(request), response => targetStates.Contains(response.Key.LifecycleState.Value), targetStates.Contains(Key.LifecycleStateEnum.Deleted) ); return(new Waiter <GetKeyRequest, GetKeyResponse>(config, agent)); }
private static async Task GetKey(KmsManagementClient kmsManagementClient, string keyId) { logger.Info("Get Key"); GetKeyRequest getKeyRequest = new GetKeyRequest { KeyId = keyId }; GetKeyResponse getKeyResponse = await kmsManagementClient.GetKey(getKeyRequest); logger.Info($"Key Retrieved: {getKeyResponse.Key.DisplayName}"); }
/// <summary>Snippet for GetKey</summary> public void GetKeyRequestObject() { // Snippet: GetKey(GetKeyRequest, CallSettings) // Create client RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient = RecaptchaEnterpriseServiceClient.Create(); // Initialize request argument(s) GetKeyRequest request = new GetKeyRequest { KeyName = KeyName.FromProjectKey("[PROJECT]", "[KEY]"), }; // Make the request Key response = recaptchaEnterpriseServiceClient.GetKey(request); // End snippet }
/// <summary>Snippet for GetKeyAsync</summary> public async Task GetKeyRequestObjectAsync() { // Snippet: GetKeyAsync(GetKeyRequest, CallSettings) // Additional: GetKeyAsync(GetKeyRequest, CancellationToken) // Create client RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient = await RecaptchaEnterpriseServiceClient.CreateAsync(); // Initialize request argument(s) GetKeyRequest request = new GetKeyRequest { KeyName = KeyName.FromProjectKey("[PROJECT]", "[KEY]"), }; // Make the request Key response = await recaptchaEnterpriseServiceClient.GetKeyAsync(request); // End snippet }
public void GetKey() { var request = new GetKeyRequest(GeneralRequests.GetKey); request.Parse(); Assert.Equal("spyguy", request.NickName); Assert.Equal("004", request.Cookie); Assert.Equal("0", request.UnkownCmdParam); Assert.Equal("b_firewall", request.Keys[0]); Assert.Equal("b_profileid", request.Keys[1]); Assert.Equal("b_ipaddress", request.Keys[2]); Assert.Equal("b_publicip", request.Keys[3]); Assert.Equal("b_privateip", request.Keys[4]); Assert.Equal("b_authresponse", request.Keys[5]); Assert.Equal("b_gamever", request.Keys[6]); Assert.Equal("b_val", request.Keys[7]); }
private void HandleOutput(GetKeyRequest request) { var waiterConfig = new WaiterConfiguration { MaxAttempts = MaxWaitAttempts, GetNextDelayInSeconds = (_) => WaitIntervalSeconds }; switch (ParameterSetName) { case LifecycleStateParamSet: response = client.Waiters.ForKey(request, waiterConfig, WaitForLifecycleState).Execute(); break; case Default: response = client.GetKey(request).GetAwaiter().GetResult(); break; } WriteOutput(response, response.Key); }
protected override void ProcessRecord() { base.ProcessRecord(); GetKeyRequest request; try { request = new GetKeyRequest { KeyId = KeyId, OpcRequestId = OpcRequestId }; HandleOutput(request); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
public void GetKeyRequestObject() { moq::Mock <RecaptchaEnterpriseServiceV1Beta1.RecaptchaEnterpriseServiceV1Beta1Client> mockGrpcClient = new moq::Mock <RecaptchaEnterpriseServiceV1Beta1.RecaptchaEnterpriseServiceV1Beta1Client>(moq::MockBehavior.Strict); GetKeyRequest request = new GetKeyRequest { KeyName = new KeyName("[PROJECT]", "[KEY]"), }; Key expectedResponse = new Key { KeyName = new KeyName("[PROJECT]", "[KEY]"), DisplayName = "display_name137f65c2", WebSettings = new WebKeySettings(), AndroidSettings = new AndroidKeySettings(), IosSettings = new IOSKeySettings(), }; mockGrpcClient.Setup(x => x.GetKey(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); RecaptchaEnterpriseServiceV1Beta1Client client = new RecaptchaEnterpriseServiceV1Beta1ClientImpl(mockGrpcClient.Object, null); Key response = client.GetKey(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public static async Task MainKeyManagement() { logger.Info("Starting example"); var provider = new ConfigFileAuthenticationDetailsProvider("DEFAULT"); var compartmentId = Environment.GetEnvironmentVariable("OCI_COMPARTMENT_ID"); var vaultId = Environment.GetEnvironmentVariable("VAULT_ID"); KmsVaultClient kmsVaultClient = null; KmsManagementClient kmsManagementClient = null; KmsCryptoClient kmsCryptoClient = null; try { // Initialize the KMS Clients. KMS has three clients as following: // * KmsVaultClient: The client for Vault management // * KmsManagementClient: The client for Key management (ControlPlane) // * KmsCryptoClient: The client for data encryption and decryption (DataPlane) kmsVaultClient = new KmsVaultClient(provider); kmsManagementClient = new KmsManagementClient(provider); kmsCryptoClient = new KmsCryptoClient(provider); Vault vault = await GetVault(kmsVaultClient, vaultId); // The ManagementClient and CryptoClient use Vault specific endpoints; Set them now. kmsManagementClient.SetEndpoint(vault.ManagementEndpoint); kmsCryptoClient.SetEndpoint(vault.CryptoEndpoint); // Vault Operations await UpdateVaultResetTags(kmsVaultClient, vault.Id); await UpdateVault(kmsVaultClient, vault.Id); await ListVaults(kmsVaultClient, compartmentId); await ScheduleVaultDeletion(kmsVaultClient, vault.Id); var waiterConfiguration = new WaiterConfiguration { MaxAttempts = 10, GetNextDelayInSeconds = DelayStrategy.GetExponentialDelayInSeconds }; // After scheduling deletion, the Vault will stay in SCHEDULING_DELETION state shortly and then // transit to PENDING_DELETION state. Wait a bit for the transition to happen. logger.Info("Wait a bit for the deletion scheduling to finish"); GetVaultRequest getVaultRequest = new GetVaultRequest { VaultId = vault.Id }; kmsVaultClient.Waiters.ForVault(getVaultRequest, waiterConfiguration, Vault.LifecycleStateEnum.PendingDeletion).Execute(); await CancelVaultDeletion(kmsVaultClient, vault.Id); // After cancelling deletion, the Vault will stay in CANCELLING_DELETION state shortly and then // transit to ACTIVE state. Wait a bit for the transition to happen. logger.Info("Wait a bit for the deletion cancelling to finish"); kmsVaultClient.Waiters.ForVault(getVaultRequest, waiterConfiguration, Vault.LifecycleStateEnum.Active).Execute(); // Management / Key Operations string keyId = await CreateKey(kmsManagementClient, compartmentId); // After creating a Key, the Key will stay in CREATING state shortly and then // transit to ENABLED state. Wait a bit for the transition to happen. logger.Info("Wait a bit for Key creation to finish"); GetKeyRequest getKeyRequest = new GetKeyRequest { KeyId = keyId }; kmsManagementClient.Waiters.ForKey(getKeyRequest, waiterConfiguration, Key.LifecycleStateEnum.Enabled).Execute(); await GetKey(kmsManagementClient, keyId); await UpdateKeyResetTags(kmsManagementClient, keyId); kmsManagementClient.Waiters.ForKey(getKeyRequest, waiterConfiguration, Key.LifecycleStateEnum.Enabled).Execute(); await UpdateKey(kmsManagementClient, keyId); kmsManagementClient.Waiters.ForKey(getKeyRequest, waiterConfiguration, Key.LifecycleStateEnum.Enabled).Execute(); await ListKeys(kmsManagementClient, compartmentId); await DisableKey(kmsManagementClient, keyId); // After disabling a Key, the Key will stay in DISABLING state shortly and then // transit to DISABLED state. Wait a bit for the transition to happen. logger.Info("Wait a bit for Key disabling to finish"); kmsManagementClient.Waiters.ForKey(getKeyRequest, waiterConfiguration, Key.LifecycleStateEnum.Disabled).Execute(); await EnableKey(kmsManagementClient, keyId); // After enabling a Key, the Key will stay in ENABLING state shortly and then // transit to ENABLED state. Wait a bit for the transition to happen. logger.Info("Wait a bit for Key enabling to finish"); kmsManagementClient.Waiters.ForKey(getKeyRequest, waiterConfiguration, Key.LifecycleStateEnum.Enabled).Execute(); await ScheduleKeyDeletion(kmsManagementClient, keyId); // After scheduling deletion, the Key will stay in SCHEDULING_DELETION state shortly and then // transit to PENDING_DELETION state. Wait a bit for the transition to happen. logger.Info("Wait a bit for deletion scheduling to finish"); kmsManagementClient.Waiters.ForKey(getKeyRequest, waiterConfiguration, Key.LifecycleStateEnum.PendingDeletion).Execute(); await CancelKeyDeletion(kmsManagementClient, keyId); // After cancelling deletion, the Key will stay in CANCELLING_DELETION state shortly and then // transit to Enabled state. Wait a bit for the transition to happen. logger.Info("Wait a bit for deletion cancelling to finish"); kmsManagementClient.Waiters.ForKey(getKeyRequest, waiterConfiguration, Key.LifecycleStateEnum.Enabled).Execute(); await CreateKeyVersion(kmsManagementClient, keyId); await ListKeyVersions(kmsManagementClient, keyId); // Crypto Operations string cipherText = await Encrypt(kmsCryptoClient, keyId); await Decrypt(kmsCryptoClient, keyId, cipherText); await GenerateDataEncryptionKey(kmsCryptoClient, keyId); kmsManagementClient.Waiters.ForKey(getKeyRequest, waiterConfiguration, Key.LifecycleStateEnum.Enabled).Execute(); } catch (Exception e) { logger.Error($"Failed to perform operations on Vault: {e}"); } finally { if (kmsVaultClient != null) { kmsVaultClient.Dispose(); } if (kmsManagementClient != null) { kmsManagementClient.Dispose(); } if (kmsCryptoClient != null) { kmsCryptoClient.Dispose(); } } logger.Info("End example"); }
/// <summary> /// Creates a waiter using default wait configuration. /// </summary> /// <param name="request">Request to send.</param> /// <param name="targetStates">Desired resource states. If multiple states are provided then the waiter will return once the resource reaches any of the provided states</param> /// <returns>a new Oci.common.Waiter instance</returns> public Waiter <GetKeyRequest, GetKeyResponse> ForKey(GetKeyRequest request, params Key.LifecycleStateEnum[] targetStates) { return(this.ForKey(request, WaiterConfiguration.DefaultWaiterConfiguration, targetStates)); }