示例#1
0
 def test_two_auth_background_step_2fa_multiple(self):
     # multiple 2fa metods available
     response_2fa = MockResponse()
     response_2fa.content_json['user_info']['data']['two_factor_enrolled'] = True
     response_2fa.content_json['user_info']['data']['two_factor_enrolled_with'] = ['yubikey', 'totp']
     oauth_2fa = MockOAuth(response_2fa)
     background(builder=self.builder, meta=self.meta, oauth=oauth_2fa)
 def phase1_sideeffect(self, url):
     if url == self.meta.api_base_uri + '/info.json':
         return MockResponse()
     elif url == self.meta.api_base_uri + '/info.json.sig':
         return MockResponse('ABCDEFG')
     else:
         raise Exception
示例#3
0
 def test_two_auth_background_step_2fa(self):
     response_2fa = MockResponse()
     response_2fa.content_json['user_info']['data'][
         'two_factor_enrolled'] = True
     oauth_2fa = MockOAuth(response_2fa)
     _background(builder=self.builder,
                 meta=self.meta,
                 oauth=oauth_2fa,
                 config_dict=mock_config_dict,
                 lets_connect=False)
示例#4
0
 def test_background_no_profile(self):
     response = MockResponse(content_json={"profile_list": {"data": []}})
     oauth = MockOAuth(response=response)
     with self.assertRaises(EduvpnException):
         _background(meta=self.meta,
                     builder=self.builder,
                     dialog=None,
                     oauth=oauth)
class TestProvider(TestCase):
    @classmethod
    def setUpClass(cls):
        cls.builder = MockBuilder()

    @patch('requests.get', side_effect=lambda x: MockResponse())
    def test_update_providers(self, _):
        update_providers(builder=self.builder)
示例#6
0
class TestRemote(unittest.TestCase):
    def setUp(self):
        self.oauth = MockOAuth()
        self.verify = VerifyMock()

    def test_create_keypair(self):
        create_keypair(oauth=self.oauth, api_base_uri='test')

    def test_get_auth_url(self):
        get_auth_url(oauth=self.oauth,
                     code_verifier='test',
                     auth_endpoint='test')

    @patch('requests.get')
    def test_get_instance_info(self, _):
        get_instance_info(instance_uri='test', verifier=self.verify)

    @patch('requests.get', side_effect=lambda x: MockResponse())
    @patch('base64.b64decode', side_effect=lambda x: "decoded")
    def test_get_instances(self, _, __):
        get_instances(discovery_uri='test', verifier=self.verify)

    def test_get_profile_config(self):
        get_profile_config(oauth=self.oauth,
                           api_base_uri='test',
                           profile_id='test')

    def test_system_messages(self):
        system_messages(oauth=self.oauth, api_base_uri='http://test')

    def test_user_messages(self):
        user_messages(oauth=self.oauth, api_base_uri='http://test')

    def test_create_config(self):
        create_config(oauth=self.oauth,
                      api_base_uri='http://test',
                      display_name='test',
                      profile_id='test')

    def test_list_profiles(self):
        list_profiles(oauth=self.oauth, api_base_uri='http://test')

    def test_translate_display_name(self):
        translate_display_name("translate test")

    def test_user_info(self):
        user_info(oauth=self.oauth, api_base_uri='http://test')
示例#7
0
 def test_background_one_profile(self, *_):
     response = MockResponse(
         content_json={
             "profile_list": {
                 "data": [
                     {
                         "display_name": "test 1",
                         "profile_id": "internet",
                         "two_factor": False
                     },
                 ]
             }
         })
     oauth = MockOAuth(response=response)
     _background(meta=self.meta,
                 builder=self.builder,
                 dialog=None,
                 oauth=oauth)
示例#8
0
 def test_two_auth_step(self, *_):
     response_2fa = MockResponse()
     response_2fa.content_json['user_info']['data']['two_factor_enrolled'] = True
     oauth_2fa = MockOAuth(response_2fa)
     two_auth_step(builder=self.builder, meta=self.meta, oauth=oauth_2fa)