Ejemplo n.º 1
0
    def setUp(self):
        self.setup_test_reactor()

        avatar_method = avatar.AvatarGitHub(client_id="oauth_id",
                                            client_secret="oauth_secret")
        master = self.make_master(url='http://a/b/',
                                  auth=auth.NoAuth(),
                                  avatar_methods=[avatar_method])

        self.rsrc = avatar.AvatarResource(master)
        self.rsrc.reconfigResource(master.config)

        headers = {
            'User-Agent': 'Buildbot',
            # oauth_id:oauth_secret in Base64
            'Authorization': 'basic b2F1dGhfaWQ6b2F1dGhfc2VjcmV0',
        }
        self._http = yield fakehttpclientservice.HTTPClientService.getService(
            master,
            self,
            avatar.AvatarGitHub.DEFAULT_GITHUB_API_URL,
            headers=headers,
            debug=False,
            verify=False)
        yield self.master.startService()
Ejemplo n.º 2
0
    def test_github(self):
        master = self.make_master(url='http://a/b/',
                                  auth=auth.NoAuth(),
                                  avatar_methods=[avatar.AvatarGitHub()])
        rsrc = avatar.AvatarResource(master)
        rsrc.reconfigResource(master.config)

        res = yield self.render_resource(rsrc, b'/?username=warner')
        self.assertEqual(
            res,
            dict(redirected=b'https://avatars.githubusercontent.com/warner'))
Ejemplo n.º 3
0
    def setUp(self):
        self.setUpTestReactor()

        master = self.make_master(
            url='http://a/b/',
            auth=auth.NoAuth(),
            avatar_methods=[avatar.AvatarGitHub(token="abcd")])

        self.rsrc = avatar.AvatarResource(master)
        self.rsrc.reconfigResource(master.config)

        headers = {
            'User-Agent': 'Buildbot',
            'Authorization': 'token abcd',
        }
        self._http = yield fakehttpclientservice.HTTPClientService.getService(
            master,
            self,
            avatar.AvatarGitHub.DEFAULT_GITHUB_API_URL,
            headers=headers,
            debug=False,
            verify=False)
        yield self.master.startService()
Ejemplo n.º 4
0
 def test_token_and_client_credentials(self):
     with self.assertRaises(config.ConfigErrors):
         avatar.AvatarGitHub(client_id="oauth_id",
                             client_secret="oauth_secret",
                             token="token")
Ejemplo n.º 5
0
 def test_incomplete_credentials(self):
     with self.assertRaises(config.ConfigErrors):
         avatar.AvatarGitHub(client_id="oauth_id")
     with self.assertRaises(config.ConfigErrors):
         avatar.AvatarGitHub(client_secret="oauth_secret")