Exemple #1
0
    def test_missing_required_type_installed(self):
        required = clientsecrets.VALID_CLIENT[
            clientsecrets.TYPE_INSTALLED]['required']
        # We will certainly have less than all 5 keys.
        self.assertEqual(len(required), 5)

        clientsecrets_dict = {
            clientsecrets.TYPE_INSTALLED: {
                'not_required': None
            },
        }
        with self.assertRaises(clientsecrets.InvalidClientSecretsError):
            clientsecrets._validate_clientsecrets(clientsecrets_dict)
Exemple #2
0
    def test_string_not_configured_type_web(self):
        string_props = clientsecrets.VALID_CLIENT[
            clientsecrets.TYPE_WEB]['string']

        self.assertTrue('client_id' in string_props)
        clientsecrets_dict = {
            clientsecrets.TYPE_WEB: {
                'client_id': '[[template]]',
                'client_secret': 'seekrit',
                'redirect_uris': None,
                'auth_uri': None,
                'token_uri': None,
            },
        }
        with self.assertRaises(clientsecrets.InvalidClientSecretsError):
            clientsecrets._validate_clientsecrets(clientsecrets_dict)
Exemple #3
0
 def test_success_type_installed(self):
     client_info = {
         'client_id': 'eye-dee',
         'client_secret': 'seekrit',
         'redirect_uris': None,
         'auth_uri': None,
         'token_uri': None,
     }
     clientsecrets_dict = {
         clientsecrets.TYPE_INSTALLED: client_info,
     }
     result = clientsecrets._validate_clientsecrets(clientsecrets_dict)
     self.assertEqual(result, (clientsecrets.TYPE_INSTALLED, client_info))
Exemple #4
0
 def test_invalid_client_type(self):
     fake_type = 'fake_type'
     self.assertNotEqual(fake_type, clientsecrets.TYPE_WEB)
     self.assertNotEqual(fake_type, clientsecrets.TYPE_INSTALLED)
     with self.assertRaises(clientsecrets.InvalidClientSecretsError):
         clientsecrets._validate_clientsecrets({fake_type: None})
Exemple #5
0
 def test_with_non_dictionary(self):
     non_dict = [None]
     with self.assertRaises(clientsecrets.InvalidClientSecretsError):
         clientsecrets._validate_clientsecrets(non_dict)
Exemple #6
0
 def test_with_other_than_one_key(self):
     with self.assertRaises(clientsecrets.InvalidClientSecretsError):
         clientsecrets._validate_clientsecrets({})
     with self.assertRaises(clientsecrets.InvalidClientSecretsError):
         clientsecrets._validate_clientsecrets({'one': 'val', 'two': 'val'})
Exemple #7
0
 def test_with_none(self):
     with self.assertRaises(clientsecrets.InvalidClientSecretsError):
         clientsecrets._validate_clientsecrets(None)