def test_session_id_returns_cookie_auth_method(self): """If an existing session exists, use that session in cookie auth.""" m = service._detect_auth_method(None, None, "session", "key", None, None, None) self.assertEqual(m, 'cookie')
def test_credentials_returns_cookie_auth_method(self): """If no method is specified, use cookie auth.""" m = service._detect_auth_method("u", "pass", None, "key", None, None, None) self.assertEqual(m, 'cookie')
def test_secret_returns_oauth2_resource_owner_auth_method(self): """If we specify a client_id and secret then use OAuth2.""" m = service._detect_auth_method(None, None, None, "key", "client_id", "secret", None) self.assertEqual(m, 'oauth2-resourceowner')
def test_secret_returns_oauth2_auth_method(self): m = service._detect_auth_method(None, None, None, "key", "secret", None) self.assertEqual(m, 'oauth2')
def test_no_apikey_raises_auth_method(self): with self.assertRaises(errors.ClientError): service._detect_auth_method(None, None, None, None, None, None)
def test_credentials_returns_cookie_auth_method(self): m = service._detect_auth_method("u", "pass", None, "key", None, None) self.assertEqual(m, 'cookie')
def test_session_id_returns_cookie_auth_method(self): m = service._detect_auth_method(None, None, "session", "key", None, None) self.assertEqual(m, 'cookie')
def test_token_returns_oauth2_auth_method(self): m = service._detect_auth_method(None, None, None, "key", None, "token") self.assertEqual(m, 'oauth2')
def test_secret_returns_oauth2_resource_owner_auth_method(self): m = service._detect_auth_method(None, None, None, "key", "client_id", "secret", None) self.assertEqual(m, 'oauth2')