public void RunAuthorization() { var duoRestApiService = new RestApiService(IntegrationKey, SecretKey, Host); var adapter = new HttpWebRequestFactory(); duoRestApiService.QueryDuoApi(adapter, "https", Path, HttpWebRequestMethod.POST, GetQueryValues("*****@*****.**")); }
public void AuthorizationKeyShouldBeCorrectlyCalculated2() { // Arrange // Act var sut = new RestApiService("DIA1AQJCU97DCLD11AZE", "TZOiTvqx3xb8VuBBaF7ewtYSsqnfUfTq8V6W3EsT", "api-f8aa1baa.duosecurity.com"); var result = sut.GetAuthorizationKey(HttpWebRequestMethod.POST, "/verify/v1/call", "message=the%20pin%20is%20%3Cpin%3E&phone=%2B447952556282"); // Assert Assert.That(result, Is.EqualTo("RElBMUFRSkNVOTdEQ0xEMTFBWkU6ZTgxMjQwMGY2NjhhNTc3NDQ0MmQ0NGUyMGYxZTA4YmUzZWQzZWZhMA==")); }
public void AuthorizationKeyShouldBeCorrectlyCalculated() { // Arrange // Act var sut = new RestApiService(IntegrationKey, SecretKey, Host); var result = sut.GetAuthorizationKey(HttpWebRequestMethod.POST, "/rest/v1/auth", "auto=phone1&factor=auto&ipaddr=141.213.231.43&user=bob"); // Assert Assert.That(result, Is.EqualTo("MTIzNDpmNDYzM2YzZWNhOGQ2YmFmNzk5Mzc5ZDgzMGM3YmU2ODA1Y2FkMWQ2")); }
public void QueryDuoApiShouldResturnNullIfGetResponseReturnsNull() { // Arrange _mockWebRequest.Setup(o => o.GetResponse()).Returns((IHttpWebResponse)null); // Act var sut = new RestApiService(IntegrationKey, SecretKey, Host); var result = sut.QueryDuoApi(_mockWebRequestFactory.Object, "https", "/rest/v1/auth", HttpWebRequestMethod.POST, _queryItems); // Assert Assert.That(result, Is.Null); }
public void CreateSignedDuoWebRequestShouldReturnAWebRequestWhoseHeaderHasHadAuthorizationAddedTo() { // Arrange var mockWebResponse = new Mock<IHttpWebResponse>(MockBehavior.Strict); mockWebResponse.Setup(o => o.GetResponseStream()).Returns(new MemoryStream()); _mockWebRequest.Setup(o => o.GetResponse()).Returns(mockWebResponse.Object); // Act var sut = new RestApiService(IntegrationKey, SecretKey, Host); sut.QueryDuoApi(_mockWebRequestFactory.Object, "https", "/rest/v1/auth", HttpWebRequestMethod.POST, _queryItems); // Assert _mockWebRequestFactory.Verify(); _mockWebRequest.Verify(); }
public void QueryDuoApiShouldReturnObjectFromJsonStream() { // Arrange var mockWebResponse = new Mock<IHttpWebResponse>(MockBehavior.Strict); mockWebResponse.Setup(o => o.GetResponseStream()).Returns(new MemoryStream()).Verifiable(); _mockWebRequest.Setup(o => o.GetResponse()).Returns(mockWebResponse.Object); // Act var sut = new RestApiService(IntegrationKey, SecretKey, Host); sut.QueryDuoApi(_mockWebRequestFactory.Object, "https", "/rest/v1/auth", HttpWebRequestMethod.POST, _queryItems); // Assert _mockWebRequest.Verify(); }