This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/test/test_github.py

48 lines
2.1 KiB
Python

import unittest
from oauth.services.github import GithubOAuthService
class TestGithub(unittest.TestCase):
def test_basic_enterprise_config(self):
config = {
'GITHUB_TRIGGER_CONFIG': {
'GITHUB_ENDPOINT': 'https://github.somedomain.com/',
'CLIENT_ID': 'someclientid',
'CLIENT_SECRET': 'someclientsecret',
}
}
github_trigger = GithubOAuthService(config, 'GITHUB_TRIGGER_CONFIG')
self.assertTrue(github_trigger.is_enterprise())
self.assertEquals('https://github.somedomain.com/login/oauth/authorize?', github_trigger.authorize_endpoint())
self.assertEquals('https://github.somedomain.com/login/oauth/access_token', github_trigger.token_endpoint())
self.assertEquals('https://github.somedomain.com/api/v3', github_trigger.api_endpoint())
self.assertEquals('https://github.somedomain.com/api/v3/user', github_trigger.user_endpoint())
self.assertEquals('https://github.somedomain.com/api/v3/user/emails', github_trigger.email_endpoint())
self.assertEquals('https://github.somedomain.com/api/v3/user/orgs', github_trigger.orgs_endpoint())
def test_custom_enterprise_config(self):
config = {
'GITHUB_TRIGGER_CONFIG': {
'GITHUB_ENDPOINT': 'https://github.somedomain.com/',
'API_ENDPOINT': 'http://somedomain.com/api',
'CLIENT_ID': 'someclientid',
'CLIENT_SECRET': 'someclientsecret',
}
}
github_trigger = GithubOAuthService(config, 'GITHUB_TRIGGER_CONFIG')
self.assertTrue(github_trigger.is_enterprise())
self.assertEquals('https://github.somedomain.com/login/oauth/authorize?', github_trigger.authorize_endpoint())
self.assertEquals('https://github.somedomain.com/login/oauth/access_token', github_trigger.token_endpoint())
self.assertEquals('http://somedomain.com/api', github_trigger.api_endpoint())
self.assertEquals('http://somedomain.com/api/user', github_trigger.user_endpoint())
self.assertEquals('http://somedomain.com/api/user/emails', github_trigger.email_endpoint())
self.assertEquals('http://somedomain.com/api/user/orgs', github_trigger.orgs_endpoint())
if __name__ == '__main__':
unittest.main()