[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 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 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)); }
/// <summary> /// Simple Example within the Constructor. /// </summary> public KountAccessExample() { try { // Create the SDK. If any of these values are invalid, an com.kount.kountaccess.AccessException will be // thrown along with a message detailing why. AccessSdk sdk = new AccessSdk(host, merchantId, apiKey); // If you want the device information for a particular user's session, just pass in the sessionId. This // contains the id (fingerprint), IP address, IP Geo Location (country), whether the user was using a proxy // (and it was bypassed), and ... DeviceInfo deviceInfo = sdk.GetDevice(this.session); this.PrintDeviceInfo(deviceInfo.Device); // ... if you want to see the velocity information in relation to the users session and their account // information, you can make an access (velocity) request. Usernames and passwords will be hashed prior to // transmission to Kount within the SDK. You may optionally hash prior to passing them in as long as the // hashing method is consistent for the same value. String username = "******"; String password = "******"; VelocityInfo accessInfo = sdk.GetVelocity(session, username, password); // Let's see the response Console.WriteLine("Response: " + accessInfo); // Each Access Request has its own uniqueID Console.WriteLine("This is our access response_id: " + accessInfo.ResponseId); // The device is included in an access request: this.PrintDeviceInfo(accessInfo.Device); // you can get the device information from the accessInfo object Device device = accessInfo.Device; string jsonVeloInfo = JsonConvert.SerializeObject(accessInfo); Console.WriteLine(jsonVeloInfo); this.PrintVelocityInfo(accessInfo.Velocity); // Or you can access specific Metrics directly. Let's say we want the // number of unique user accounts used by the current sessions device // within the last hour int numUsersForDevice = accessInfo.Velocity.Device.ulh; Console.WriteLine( "The number of unique user access request(s) this hour for this device is:" + numUsersForDevice); // Decision Information is stored in a JSONObject, by entity type DecisionInfo decisionInfo = sdk.GetDecision(session, username, password); Decision decision = decisionInfo.Decision; // Let's look at the data this.PrintDecisionInfo(decision); // Get Kount Access data for session based on what was requested in the info flag String uniq = "uniq(customer identifier)"; DataSetElements dataSet = new DataSetElements() .WithInfo() .WithVelocity() .WithDecision() .WithTrusted() .WithBehavioSec(); Info info = sdk.GetInfo(session, username, password, uniq, dataSet); this.PrintDeviceInfo(info.Device); this.PrintDecisionInfo(info.Decision); this.PrintVelocityInfo(info.Velocity); this.PrintFields(info.Trusted); this.PrintFields(info.BehavioSec); // Get devices that belong to a uniq user. DevicesInfo devices = sdk.GetDevices(uniq); foreach (var d in devices.Devices) { this.PrintFields(d); } // Get the uniq users that belong to a device. string deviceId = "DEVICE_ID"; var uniques = sdk.GetUniques(deviceId); foreach (var u in uniques.Uniques) { this.PrintFields(u); } // Update device trust referenced by session ID sdk.SetDeviceTrustBySession(session, uniq, DeviceTrustState.Banned); // Update device trust referenced by device ID sdk.SetDeviceTrustByDevice(uniq, deviceId, DeviceTrustState.Trusted); // Update behavior data. string timing = "timing data"; // BehavioHost and BehavioEnvironment can be set via AccessSdk constructor too. // sdk.BehavioHost = "https://api.behavio.kaptcha.com"; //sdk.BehavioEnvironment = "sandbox"; //sdk.SetBehavioSec(session, uniq, timing); } catch (AccessException ae) { // These can be thrown if there were any issues making the request. // See the AccessException class for more information. Console.WriteLine("ERROR Type: " + ae.ErrorType); Console.WriteLine("ERROR: " + ae.Message); } }