"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "linotpd/src/linotp/tests/functional/test_tokens/test_emailtoken.py" between
LinOTP-release-2.11.1.tar.gz and LinOTP-release-2.11.2.tar.gz

About: LinOTP is a flexible and versatile OTP-platform for strong user authentication (two-factor authentication with one time passwords).

test_emailtoken.py  (LinOTP-release-2.11.1):test_emailtoken.py  (LinOTP-release-2.11.2)
skipping to change at line 396 skipping to change at line 396
response = self.make_validate_request('check', params=params) response = self.make_validate_request('check', params=params)
assert 'false' in response assert 'false' in response
assert '"message": "e-mail sent successfully"' in response assert '"message": "e-mail sent successfully"' in response
call_args = mock_smtp_instance.sendmail.call_args call_args = mock_smtp_instance.sendmail.call_args
_from, to, _message = call_args.args _from, to, _message = call_args.args
assert to == 'pass.true@example.com' assert to == 'pass.true@example.com'
def test_verify_not_blocking(self):
""" verify that email challenges are not blocked if challenge is closed
"""
# ------------------------------------------------------------------ --
# setup the email provider
email_provider_config = {
"SMTP_SERVER": "mail.example.com",
"SMTP_USER": "secret_user",
"SMTP_PASSWORD": "secret_pasword",
"EMAIL_SUBJECT": "otp: ${otp}",
}
email_provider_definition = {
'name': 'TemplEMailProvider',
'timeout': '3',
'type': 'email',
'config': json.dumps(email_provider_config),
'class': 'linotp.provider.emailprovider.SMTPEmailProvider'
}
response = self.make_system_request(
'setProvider', params=email_provider_definition)
assert 'false' not in response
# ------------------------------------------------------------------ --
# and make him the default email provider
params = {
'type': 'email',
'name': 'TemplEMailProvider'
}
response = self.make_system_request(
'setDefaultProvider', params=params)
assert 'false' not in response
# ------------------------------------------------------------------ --
# enroll email token for user and answer the challenge
user = 'passthru_user1'
serial = 'EMAIL_TOKEN_001'
params = {
'user': user,
'type': 'email',
'pin': '123',
'email_address': 'test@example.com',
'serial': serial
}
response = self.make_admin_request('init', params=params)
assert 'false' not in response
# ------------------------------------------------------------------ --
# setup the mocking smtp client from which we get the sendmail args
# to verify the template processing
with MockedSMTP() as mock_smtp_instance:
mock_smtp_instance.sendmail.return_value = []
# -------------------------------------------------------------- --
# now trigger a challenge for the user
params = {
'user': user,
'pass': '123'
}
response = self.make_validate_request('check', params=params)
assert 'false' in response
assert '"message": "e-mail sent successfully"' in response
jresp = json.loads(response.body)
transaction_id = jresp['detail']['transactionid']
call_args = mock_smtp_instance.sendmail.call_args
_from, _to, message = call_args.args
otp = message.rpartition('\n')[2].strip()
# -------------------------------------------------------------- --
# now trigger a second challenge for the user which is blocked
params = {
'user': user,
'pass': '123'
}
response = self.make_validate_request('check', params=params)
assert 'false' in response
assert '"message": "e-mail with otp already submitted"' in response
params = {
'user': user,
'pass': otp,
'transactionid': transaction_id
}
response = self.make_validate_request('check', params=params)
assert 'false' not in response
# -------------------------------------------------------------- --
# now trigger a challenge for the user -
# which should now be possible without blocking
params = {
'user': user,
'pass': '123'
}
response = self.make_validate_request('check', params=params)
assert 'false' in response
assert '"message": "e-mail sent successfully"' in response
# eof # eof
 End of changes. 1 change blocks. 
0 lines changed or deleted 123 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)