~mfoord/canonical-identity-provider/account-killer

« back to all changes in this revision

Viewing changes to src/api/v20/tests/test_login.py

  • Committer: Tarmac
  • Author(s): Diogo Baeder de Paula Pinto
  • Date: 2013-09-16 18:51:17 UTC
  • mfrom: (1055.1.13 self-service-2fa)
  • Revision ID: tarmac-20130916185117-6m7tahhrko4ffuht
[r=ricardokirkner] Basic 2fa synching - model implementation only, for now

Show diffs side-by-side

added added

removed removed

Lines of Context:
138
138
            with patch('api.v20.handlers.twofactor') as mock_twofactor:
139
139
                response, json_body = call(handler.create, API_URL, data)
140
140
 
141
 
        authenticate_device = mock_twofactor.authenticate_device
 
141
        authenticate = mock_twofactor.authenticate
142
142
 
143
 
        authenticate_device.assert_called_once_with(mock_account, 'one time')
 
143
        authenticate.assert_called_once_with(mock_account, 'one time')
144
144
        self.assertEqual(response.status_code, 201)
145
145
 
146
146
    def test_twofactor_wrong_otp(self):
148
148
        data['otp'] = 'one time'
149
149
        with patch('api.v20.handlers.authenticate_user') as mock_authenticate:
150
150
            with patch('api.v20.handlers.twofactor') as mock_twofactor:
151
 
                authenticate_device = mock_twofactor.authenticate_device
152
 
                authenticate_device.side_effect = AuthenticationError
 
151
                authenticate = mock_twofactor.authenticate
 
152
                authenticate.side_effect = AuthenticationError
153
153
 
154
154
                response, json_body = call(handler.create, API_URL, data)
155
155
 
156
156
        mock_account = mock_authenticate.return_value
157
 
        authenticate_device.assert_called_once_with(mock_account, 'one time')
 
157
        authenticate.assert_called_once_with(mock_account, 'one time')
158
158
        self.assertEqual(response.status_code, 403)
159
159
        self.assertEqual(json_body['code'], 'TWOFACTOR_FAILURE')