public void TestGetDevice() { try { MockupWebClientFactory mockFactory = new MockupWebClientFactory(this.jsonDevInfo); AccessSdk sdk = new AccessSdk(accessUrl, merchantId, apiKey, DEFAULT_VERSION, mockFactory); DeviceInfo dInfo = sdk.GetDevice(session); Assert.IsNotNull(dInfo); this.logger.Debug(JsonConvert.SerializeObject(dInfo)); Assert.AreEqual(fingerprint, dInfo.Device.Id); Assert.AreEqual(ipAddress, dInfo.Device.IpAddress); Assert.AreEqual(ipGeo, dInfo.Device.IpGeo); Assert.AreEqual(1, dInfo.Device.Mobile); Assert.AreEqual(0, dInfo.Device.Proxy); Assert.AreEqual(responseId, dInfo.ResponseId); } catch (AccessException ae) { Assert.Fail($"Bad exception {ae.ErrorType}:{ae.Message}"); } }
public void TestGetDecision() { try { MockupWebClientFactory mockFactory = new MockupWebClientFactory(this.jsonDeciInfo); AccessSdk sdk = new AccessSdk(accessUrl, merchantId, apiKey, DEFAULT_VERSION, mockFactory); DecisionInfo decisionInfo = sdk.GetDecision(session, user, password); Assert.IsNotNull(decisionInfo); this.logger.Debug(JsonConvert.SerializeObject(decisionInfo)); Assert.AreEqual(decision, decisionInfo.Decision.Reply.RuleEvents.Decision); Assert.AreEqual(deviceInfo.Device.Id, decisionInfo.Device.Id); Assert.IsTrue(velocityInfo.Velocity.Password.Equals(decisionInfo.Velocity.Password)); } catch (AccessException ae) { Assert.Fail($"Bad exception {ae.ErrorType}:{ae.Message}"); } }
public void TestDeviceTrustByDevice_ShouldNotThrowException() { // Arrange MockupWebClientFactory mockFactory = new MockupWebClientFactory(this.jsonUniquesInfo); AccessSdk sdk = new AccessSdk(accessUrl, merchantId, apiKey, DEFAULT_VERSION, mockFactory); // Act sdk.SetDeviceTrustByDevice(uniq, "abcdef12345678910abcdef987654321", DeviceTrustState.Trusted); // Assert }
public void TestDeviceTrustBySession_ShouldNotThrowException() { // Arrange MockupWebClientFactory mockFactory = new MockupWebClientFactory(this.jsonUniquesInfo); AccessSdk sdk = new AccessSdk(accessUrl, merchantId, apiKey, DEFAULT_VERSION, mockFactory); // Act sdk.SetDeviceTrustBySession(session, uniq, DeviceTrustState.Trusted); // Assert }
public void TestDeviceTrustByDeviceWithoutUniq_ShouldThrowException() { // Arrange MockupWebClientFactory mockFactory = new MockupWebClientFactory(this.jsonDevicesInfo); AccessSdk sdk = new AccessSdk(accessUrl, merchantId, apiKey, DEFAULT_VERSION, mockFactory); var emptyUniq = ""; // Act // Assert Assert.That(() => sdk.SetDeviceTrustByDevice(emptyUniq, "abcdef12345678910abcdef987654321", DeviceTrustState.Trusted), Throws.TypeOf <AccessException>()); }
public void TestDeviceTrustBySessionWithoutSessionId_ShouldThrowException() { // Arrange MockupWebClientFactory mockFactory = new MockupWebClientFactory(this.jsonDevicesInfo); AccessSdk sdk = new AccessSdk(accessUrl, merchantId, apiKey, DEFAULT_VERSION, mockFactory); var emptySession = ""; // Act // Assert Assert.That(() => sdk.SetDeviceTrustBySession(emptySession, uniq, DeviceTrustState.Trusted), Throws.TypeOf <AccessException>()); }
[TestCase(7)] // WithInfo, WithVelocity and WithDecision public void TestGetInfoWithoutUniq_ShouldPassValidation(int dataSetNumber) { DataSetElements dataSets = GetDataSetElementsFromExpectedValueAfterBuild(dataSetNumber); // Arrange MockupWebClientFactory mockFactory = new MockupWebClientFactory(this.jsonInfo); AccessSdk sdk = new AccessSdk(accessUrl, merchantId, apiKey, DEFAULT_VERSION, mockFactory); var emptyUniq = ""; // Act Info infoResp = sdk.GetInfo(session, user, password, emptyUniq, dataSets); // Assert Assert.IsNotNull(infoResp); }
public void TestGetInfoWithoutPassword_ShouldThrowException(int dataSetNumber) { DataSetElements dataSets = GetDataSetElementsFromExpectedValueAfterBuild(dataSetNumber); // Arrange MockupWebClientFactory mockFactory = new MockupWebClientFactory(this.jsonInfo); AccessSdk sdk = new AccessSdk(accessUrl, merchantId, apiKey, DEFAULT_VERSION, mockFactory); var emptyPassword = ""; // Act ActualValueDelegate <object> testDelegate = () => sdk.GetInfo(session, user, emptyPassword, uniq, dataSets); // Assert Assert.That(testDelegate, Throws.TypeOf <AccessException>()); }
public void TestGetUniquesWithoutDeviceId_ShouldThrowException() { // Arrange MockupWebClientFactory mockFactory = new MockupWebClientFactory(this.jsonDevicesInfo); AccessSdk sdk = new AccessSdk(accessUrl, merchantId, apiKey, DEFAULT_VERSION, mockFactory); var emptyDeviceId = ""; // Act ActualValueDelegate <object> testDelegate = () => sdk.GetUniques(emptyDeviceId); // Assert Assert.That(testDelegate, Throws.TypeOf <AccessException>()); }
public void TestGetInfoWithoutSession_ShouldThrowException() { // Arrange MockupWebClientFactory mockFactory = new MockupWebClientFactory(this.jsonInfo); AccessSdk sdk = new AccessSdk(accessUrl, merchantId, apiKey, DEFAULT_VERSION, mockFactory); var dataSets = new DataSetElements() .WithInfo(); var emptySessionId = ""; // Act ActualValueDelegate <object> testDelegate = () => sdk.GetInfo(emptySessionId, user, password, uniq, dataSets); // Assert Assert.That(testDelegate, Throws.TypeOf <AccessException>()); }
public void TestGetDeviceConnectionClosed() { try { MockupWebClientFactory mockFactory = new MockupWebClientFactory(this.jsonDevInfo); AccessSdk sdk = new AccessSdk("gty://bad.host.com", merchantId, apiKey, DEFAULT_VERSION, mockFactory); DeviceInfo dInfo = sdk.GetDevice(session); Assert.Fail($"AccessException Not thrown"); } catch (AccessException ae) { Assert.AreEqual(ae.ErrorType, AccessErrorType.NETWORK_ERROR); } }
public void TestGetUniques() { // Arrange MockupWebClientFactory mockFactory = new MockupWebClientFactory(this.jsonUniquesInfo); AccessSdk sdk = new AccessSdk(accessUrl, merchantId, apiKey, DEFAULT_VERSION, mockFactory); // Act UniquesInfo uniquesResp = sdk.GetUniques("54569fcbd187483a8a1570a3c67d1113"); this.logger.Debug(JsonConvert.SerializeObject(uniquesResp)); // Assert Assert.IsNotNull(uniquesResp); Assert.AreEqual(this.uniquesInfo.ResponseId, uniquesResp.ResponseId); Assert.AreEqual(this.uniquesInfo.Uniques.Count, uniquesResp.Uniques.Count); }
public void TestGetDevices() { // Arrange MockupWebClientFactory mockFactory = new MockupWebClientFactory(this.jsonDevicesInfo); AccessSdk sdk = new AccessSdk(accessUrl, merchantId, apiKey, DEFAULT_VERSION, mockFactory); // Act DevicesInfo devicesResp = sdk.GetDevices(uniq); this.logger.Debug(JsonConvert.SerializeObject(devicesResp)); // Assert Assert.IsNotNull(devicesResp); Assert.AreEqual(this.devicesInfo.ResponseId, devicesResp.ResponseId); Assert.AreEqual(this.devicesInfo.Devices.Count, devicesResp.Devices.Count); }
public void TestGetVelocityWebExceptionWithResponse() { try { MockupWebClientFactory mockFactory = new MockupWebClientFactory(this.jsonVeloInfo); AccessSdk sdk = new AccessSdk("gty://bad.host.com", merchantId, apiKey, DEFAULT_VERSION, mockFactory); VelocityInfo vInfo = sdk.GetVelocity(session, user, password); Assert.Fail($"AccessException Not thrown"); } catch (AccessException ae) { Assert.AreEqual(ae.ErrorType, AccessErrorType.NETWORK_ERROR); Assert.IsTrue("BAD RESPONSE(OK):OK. UNKNOWN NETWORK ISSUE.".Equals(ae.Message.Trim())); } }
public void TestGetVelocity() { try { MockupWebClientFactory mockFactory = new MockupWebClientFactory(this.jsonVeloInfo); AccessSdk sdk = new AccessSdk(accessUrl, merchantId, apiKey, DEFAULT_VERSION, mockFactory); VelocityInfo vInfo = sdk.GetVelocity(session, user, password); Assert.IsNotNull(vInfo); this.logger.Debug(JsonConvert.SerializeObject(vInfo)); Assert.IsTrue(velocityInfo.Velocity.Password.Equals(vInfo.Velocity.Password)); Assert.AreEqual(vInfo.ResponseId, responseId); } catch (AccessException ae) { Assert.Fail($"Bad exception {ae.ErrorType}:{ae.Message}"); } }
public void TestGetInfo() { // Arrange MockupWebClientFactory mockFactory = new MockupWebClientFactory(this.jsonInfo); AccessSdk sdk = new AccessSdk(accessUrl, merchantId, apiKey, DEFAULT_VERSION, mockFactory); var allDataSets = new DataSetElements() .WithInfo() .WithVelocity() .WithDecision() .WithTrusted(); // Act Info infoResp = sdk.GetInfo(session, user, password, uniq, allDataSets); this.logger.Debug(JsonConvert.SerializeObject(info)); // Assert Assert.IsNotNull(info); Assert.AreEqual(info.ResponseId, infoResp.ResponseId); Assert.AreEqual(info.Device.Id, infoResp.Device.Id); Assert.IsTrue(info.Velocity.Password.Equals(infoResp.Velocity.Password)); }