public void TestFetchRequest() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); var request = new Request( HttpMethod.Get, Twilio.Rest.Domain.Preview, "/DeployedDevices/Fleets/FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Certificates/CYXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "" ); twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content")); try { CertificateResource.Fetch("FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "CYXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", client: twilioRestClient); Assert.Fail("Expected TwilioException to be thrown for 500"); } catch (ApiException) {} twilioRestClient.Received().Request(request); }
public void ReturnsCorrectSignature() { //Arrange const string senderId = "1337"; const string uri = "http://fakeuri.no/someendpoint"; const string method = "POST"; const string sha256Hash = "TheHashOfContentForHeader"; const string expectedSignature = "HEZfhL+mu0Pb9Owvfs7pHLUXxZPthONK53nWTwXPFtFVjslr4AIxLqUSbAO7PerzBcRryYa84SellVabx8t16Ixg52afLQb02qyeDx1qF23YAIvvv01NmEJkVUUTV/oN7MgDAb4NGeujzVoUzXKTV+b5YC4W2c4M/RWSGYF1HxEEo+82SDyTlwGa3XxhcVem2Kg0LOgZvKaJnFWk0fsVDI7J9xWdOY0NWbtlm/xu77w2IlR+91lbr2G5A75lyzboXVEYvOj3UGzKwFTqGDpR7var+/PzWh00lQ/dKtILKzDGz3E80CxCOtlU/6kczk9MtYVQvLCy7QR0GMUI6ypTzg=="; var certificate = CertificateResource.Certificate(); var dateTime = new DateTime(2014, 07, 07, 12, 00, 02).ToString("R"); //Act var computedSignature = AuthenticationHandler.ComputeSignature(method, new Uri(uri), dateTime, sha256Hash, senderId, certificate, false); //Assert Assert.Equal(expectedSignature, computedSignature); }
public void TestCreateRequest() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); var request = new Request( HttpMethod.Post, Twilio.Rest.Domain.Preview, "/DeployedDevices/Fleets/FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Certificates", "" ); request.AddPostParam("CertificateData", Serialize("certificate_data")); twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content")); try { CertificateResource.Create("FLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "certificate_data", client: twilioRestClient); Assert.Fail("Expected TwilioException to be thrown for 500"); } catch (ApiException) {} twilioRestClient.Received().Request(request); }
public static TestSender GetSender(TestEnvironment testEnvironment) { switch (testEnvironment) { case TestEnvironment.DifiTest: return(new TestSender( 497013, CertificateResource.Certificate(), Environment.DifiTest, new RecipientById(IdentificationType.DigipostAddress, "ReplaceMehere") )); case TestEnvironment.Qa: return(new TestSender( 1185201, CertificateReader.ReadCertificate(), Environment.Qa, new RecipientById(IdentificationType.DigipostAddress, "liv.test.aliassen#8514") )); default: throw new ArgumentOutOfRangeException(nameof(testEnvironment), testEnvironment, null); } }
internal static X509Certificate2 GetSenderSelfSignedCertificate() { return(CertificateResource.GetEternalTestCertificateWithPrivateKey()); }
/// <summary> /// Create or update certificate resource. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group that contains the resource. You can obtain /// this value from the Azure Resource Manager API or the portal. /// </param> /// <param name='serviceName'> /// The name of the Service resource. /// </param> /// <param name='certificateName'> /// The name of the certificate resource. /// </param> /// <param name='certificateResource'> /// Parameters for the create or update operation /// </param> public static CertificateResource CreateOrUpdate(this ICertificatesOperations operations, string resourceGroupName, string serviceName, string certificateName, CertificateResource certificateResource) { return(operations.CreateOrUpdateAsync(resourceGroupName, serviceName, certificateName, certificateResource).GetAwaiter().GetResult()); }
/// <summary> /// Create or update certificate resource. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group that contains the resource. You can obtain /// this value from the Azure Resource Manager API or the portal. /// </param> /// <param name='serviceName'> /// The name of the Service resource. /// </param> /// <param name='certificateName'> /// The name of the certificate resource. /// </param> /// <param name='certificateResource'> /// Parameters for the create or update operation /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <CertificateResource> BeginCreateOrUpdateAsync(this ICertificatesOperations operations, string resourceGroupName, string serviceName, string certificateName, CertificateResource certificateResource, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serviceName, certificateName, certificateResource, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }