Add password options to RPS config, dynamic options and client settings
diff --git a/servers/rps/config_default.py b/servers/rps/config_default.py
index 915efee..bca82fd 100644
--- a/servers/rps/config_default.py
+++ b/servers/rps/config_default.py
@@ -131,3 +131,8 @@
"""Use NFC flag for mobile clients"""
useNFC = False
+
+"""Password options"""
+usePassword = "PIN"
+minPasswordLength = 6
+maxPasswordLength = 16
diff --git a/servers/rps/rps.py b/servers/rps/rps.py
index 4dd9c6f..7130361 100755
--- a/servers/rps/rps.py
+++ b/servers/rps/rps.py
@@ -130,6 +130,12 @@
define("mobileConfig", default=None, type=list)
define("useNFC", default=False, type=bool)
+# password instead of PIN options
+# usePassword should accept 'PIN', 'password' and 'either'
+define("usePassword", default="PIN", type=unicode)
+define("minPasswordLength", default=6, type=int)
+define("maxPasswordLength", default=16, type=int)
+
# Mapping between local names of dynamic options and names from json
# in the form `remote_name`: `local_name`
@@ -139,6 +145,9 @@
'time_synchronization_period': 'timePeriod',
'mobile_use_native': 'mobileUseNative',
'mobile_client_config': 'mobileConfig',
+ 'use_password': 'usePassword',
+ 'min_password_length': 'minPasswordLength',
+ 'max_password_length': 'maxPasswordLength',
}
@@ -309,6 +318,9 @@
"accessNumberDigits": 7 if options.accessNumberUseCheckSum else 6,
"cSum": 1,
"useNFC": options.useNFC,
+ "usePassword": options.usePassword,
+ "minPasswordLength": options.minPasswordLength,
+ "maxPasswordLength": options.maxPasswordLength,
}
if not options.requestOTP:
diff --git a/servers/rps/test_dynamic_options.py b/servers/rps/test_dynamic_options.py
index 7a035ed..0aa2e04 100644
--- a/servers/rps/test_dynamic_options.py
+++ b/servers/rps/test_dynamic_options.py
@@ -45,6 +45,14 @@
local_mapping=DYNAMIC_OPTION_MAPPING)
+def test_set_password_options():
+ _test_dynamic_options_update(
+ initial_options={'usePassword': "PIN", 'minPasswordLength': 0, 'maxPasswordLength': 100},
+ response_body='{"use_password": "either", "min_password_length": 10, "max_password_length": 11}',
+ expected_options={'usePassword': "either", 'minPasswordLength': 10, 'maxPasswordLength': 11},
+ local_mapping=DYNAMIC_OPTION_MAPPING)
+
+
def test_mobile_change():
_test_dynamic_options_update(
initial_options={
@@ -56,6 +64,9 @@
"mobile_online_name": "Spam",
"mobile_online_url": "spam",
"mobile_online_type": "onlinea",
+ "use_password": "PIN",
+ "min_password_length": 1,
+ "max_password_length": 10,
}],
},
response_body="""
@@ -67,7 +78,10 @@
"mobile_otp_type": "otpb",
"mobile_online_name": "Eggs",
"mobile_online_url": "eggs",
- "mobile_online_type": "onlineb"
+ "mobile_online_type": "onlineb",
+ "use_password": "either",
+ "min_password_length": 5,
+ "max_password_length": 15
}]
}
""",
@@ -80,6 +94,9 @@
"mobile_online_name": "Eggs",
"mobile_online_url": "eggs",
"mobile_online_type": "onlineb",
+ "use_password": "either",
+ "min_password_length": 5,
+ "max_password_length": 15,
}],
},
local_mapping=DYNAMIC_OPTION_MAPPING)