SDK Integration & Unit Tests

Integration tests

  1. test_ris_test_suite.py
  2. test_basic_connectivity.py
  3. test_api_kount.py
  4. json_test.py - Example curl call:
curl -k -H "X-Kount-Api-Key: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiI5OTk2NjYiLCJhdWQiOiJLb3VudC4xIiwiaWF0IjoxNDk0NTM0Nzk5LCJzY3AiOnsia2EiOm51bGwsImtjIjpudWxsLCJhcGkiOmZhbHNlLCJyaXMiOnRydWV9fQ.eMmumYFpIF-d1up_mfxA5_VXBI41NSrNVe9CyhBUGck" -d "MODE=Q&LAST4=2514&PROD_ITEM[]=SG999999&PROD_DESC[]=3000+CANDLEPOWER+PLASMA+FLASHLIGHT&S2NM=SdkTestShipToFirst+SdkShipToLast&PTOK=0007380568572514&AUTH=A&IPAD=4.127.51.215&B2CI=Albuquerque&S2CC=US&SESS=088E9F4961354D4F90041988B8D5C66B&TOTL=123456&PROD_QUANT[]=2&B2CC=US&S2CI=Gnome&AVST=M&EMAL=curly.riscaller15%40kountqa.com&AVSZ=M&S2PC=99762&S2EM=sdkTestShipTo%40kountsdktestdomain.com&S2ST=AK&FRMT=JSON&VERS=0695&B2PC=87101&ORDR=088E9F496135&PROD_TYPE[]=SPORTING%5FGOODS&B2PN=555+867-5309&S2PN=208+777-1212&NAME=Goofy+Grumpus&MACK=Y&SITE=DEFAULT&PROD_PRICE[]=68990&UAGT=Mozilla%2F5.0+%28Macintosh%3B+Intel+Mac+OS+X+10%5F9%5F5%29+AppleWebKit%2F537.36+%28KHTML%2C+like+Gecko%29+Chrome%2F37.0.2062.124+Safari%2F537.36&CVVR=M&CASH=4444&B2ST=NM&ANID=&MERC=999666&CURR=USD&S2A1=567+West+S2A1+Court+North&B2A1=1234+North+B2A1+Tree+Lane+South&PTYP=CARD&UNIQ=088E9F4961354D4F9004" https://risk.beta.kount.net

should result in this response:

{"VERS":"0695","MODE":"Q","TRAN":"PTPN0Z04P8Y6","MERC":"999666","SESS":"088E9F4961354D4F90041988B8D5C66B",
"ORDR":"088E9F496135","AUTO":"R","SCOR":"29","GEOX":"US","BRND":null,"REGN":null,"NETW":"N","KAPT":"N","CARDS":"1",
"DEVICES":"1","EMAILS":"1","VELO":"0","VMAX":"0","SITE":"DEFAULT","DEVICE_LAYERS":"....","FINGERPRINT":null,
"TIMEZONE":null,"LOCALTIME":" ","REGION":null,"COUNTRY":null,"PROXY":null,"JAVASCRIPT":null,"FLASH":null,"COOKIES":null,
"HTTP_COUNTRY":null,"LANGUAGE":null,"MOBILE_DEVICE":null,"MOBILE_TYPE":null,"MOBILE_FORWARDER":null,
"VOICE_DEVICE":null,"PC_REMOTE":null,"RULES_TRIGGERED":1,"RULE_ID_0":"1024842","RULE_DESCRIPTION_0":
"Review if order total > $1000 USD","COUNTERS_TRIGGERED":0,"REASON_CODE":null,"DDFS":null,"DSR":null,"UAS":null,
"BROWSER":null,"OS":null,"PIP_IPAD":null,"PIP_LAT":null,"PIP_LON":null,"PIP_COUNTRY":null,"PIP_REGION":null,"PIP_CITY":null,
"PIP_ORG":null,"IP_IPAD":null,"IP_LAT":null,"IP_LON":null,"IP_COUNTRY":null,"IP_REGION":null,"IP_CITY":null,"IP_ORG":null,"WARNING_COUNT":0}

The Kount RIS Python SDK comes with a suite of integration tests, covering the various request modes and service behavior. Some of the internal SDK functionality is also covered by those test cases.

Each Kount client, upon negotiating an NDA, is going to receive the following configuration data:

  • RIS server URL
  • Merchant ID
  • API key
  • configurationKey used in encrypting sensitive data.

Setting configurationKey

In order to run the set of integration tests, it is required to provide the configurationKey either with command line argument (–conf-key) or with exporting environment variable CONF_KEY

Within the test suite test_basic_connectivity.py, there’s a test class named TestBasicConnectivity. Inside, there are two test cases, expecting predefined results (check the Predictive Response section). There are other options that have default values, although they can be overwritten for the test run:
  • –merchant_id
  • –api-key
  • –api-url

unit tests:

  1. test_address.py
  2. test_payment.py
  3. test_inquiry.py
  4. test_ris_validation_exception.py
  5. test_ris_validator.py
  6. test_validation_error.py
  7. test_xmlparser.py
  8. test_khash.py

resources:

  1. resources/validate.xml - Kount xml, used for request’s validation
  2. resources/correct_key_cryp.py- sha-256 of the correct configurationKey, used for validation