Ejemplo n.º 1
0
    def setUp(self):
        if requests is None:
            raise unittest.SkipTest("Need to install requests to test oauth2")

        self.patch(requests, 'request', mock.Mock(spec=requests.request))
        self.patch(requests, 'post', mock.Mock(spec=requests.post))
        self.patch(requests, 'get', mock.Mock(spec=requests.get))

        self.googleAuth = oauth2.GoogleAuth("ggclientID", "clientSECRET")
        self.githubAuth = oauth2.GitHubAuth("ghclientID", "clientSECRET")
        self.githubAuth_v4 = oauth2.GitHubAuth("ghclientID",
                                               "clientSECRET",
                                               apiVersion=4)
        self.githubAuth_v4_teams = oauth2.GitHubAuth("ghclientID",
                                                     "clientSECRET",
                                                     apiVersion=4,
                                                     getTeamsMembership=True)
        self.githubAuthEnt = oauth2.GitHubAuth(
            "ghclientID",
            "clientSECRET",
            serverURL="https://git.corp.fakecorp.com")
        self.gitlabAuth = oauth2.GitLabAuth("https://gitlab.test/",
                                            "glclientID", "clientSECRET")
        self.bitbucketAuth = oauth2.BitbucketAuth("bbclientID", "clientSECRET")

        for auth in [
                self.googleAuth, self.githubAuth, self.githubAuth_v4,
                self.githubAuth_v4_teams, self.githubAuthEnt, self.gitlabAuth,
                self.bitbucketAuth
        ]:
            self._master = master = self.make_master(url='h:/a/b/', auth=auth)
            auth.reconfigAuth(master, master.config)
Ejemplo n.º 2
0
    def setUp(self):
        self.setUpTestReactor()
        if requests is None:
            raise unittest.SkipTest("Need to install requests to test oauth2")

        self.patch(requests, 'request', mock.Mock(spec=requests.request))
        self.patch(requests, 'post', mock.Mock(spec=requests.post))
        self.patch(requests, 'get', mock.Mock(spec=requests.get))

        self.googleAuth = oauth2.GoogleAuth("ggclientID", "clientSECRET")
        self.githubAuth = oauth2.GitHubAuth("ghclientID", "clientSECRET")
        self.githubAuth_v4 = oauth2.GitHubAuth("ghclientID",
                                               "clientSECRET",
                                               apiVersion=4)
        self.githubAuth_v4_teams = oauth2.GitHubAuth("ghclientID",
                                                     "clientSECRET",
                                                     apiVersion=4,
                                                     getTeamsMembership=True)
        self.githubAuthEnt = oauth2.GitHubAuth(
            "ghclientID",
            "clientSECRET",
            serverURL="https://git.corp.fakecorp.com")
        self.gitlabAuth = oauth2.GitLabAuth("https://gitlab.test/",
                                            "glclientID", "clientSECRET")
        self.bitbucketAuth = oauth2.BitbucketAuth("bbclientID", "clientSECRET")

        for auth in [
                self.googleAuth, self.githubAuth, self.githubAuth_v4,
                self.githubAuth_v4_teams, self.githubAuthEnt, self.gitlabAuth,
                self.bitbucketAuth
        ]:
            self._master = master = self.make_master(url='h:/a/b/', auth=auth)
            auth.reconfigAuth(master, master.config)

        self.githubAuth_secret = oauth2.GitHubAuth(Secret("client-id"),
                                                   Secret("client-secret"),
                                                   apiVersion=4)
        self._master = master = self.make_master(url='h:/a/b/', auth=auth)
        fake_storage_service = FakeSecretStorage()
        fake_storage_service.reconfigService(
            secretdict={
                "client-id": "secretClientId",
                "client-secret": "secretClientSecret"
            })
        secret_service = SecretManager()
        secret_service.services = [fake_storage_service]
        yield secret_service.setServiceParent(self._master)
        self.githubAuth_secret.reconfigAuth(master, master.config)
Ejemplo n.º 3
0
 def test_GitHubAuthBadApiVersion(self):
     for bad_api_version in (2, 5, 'a'):
         with self.assertRaisesConfigError(
                 'GitHubAuth apiVersion must be 3 or 4 not '):
             oauth2.GitHubAuth("ghclientID",
                               "clientSECRET",
                               apiVersion=bad_api_version)
 def test_GitHubAuthRaiseErrorWithApiV3AndGetTeamMembership(self):
     self.assertRaisesConfigError(
         'Retrieving team membership information using GitHubAuth is only possible using GitHub api v4.',
         lambda: oauth2.GitHubAuth("ghclientID",
                                   "clientSECRET",
                                   apiVersion=3,
                                   getTeamsMembership=True))
Ejemplo n.º 5
0
    def setUp(self):
        self.oldsanction = sys.modules.get("sanction", None)
        self.sanction = FakeSanction()
        sys.modules["sanction"] = self.sanction
        # need to import it here if we want this trick to work
        from buildbot.www import oauth2

        self.googleAuth = oauth2.GoogleAuth("ggclientID", "clientSECRET")
        self.githubAuth = oauth2.GitHubAuth("ghclientID", "clientSECRET")
        master = self.make_master(url='h:/a/b/', auth=self.googleAuth)
        self.googleAuth.reconfigAuth(master, master.config)
        self.master = master = self.make_master(url='h:/a/b/',
                                                auth=self.githubAuth)
        self.githubAuth.reconfigAuth(master, master.config)
Ejemplo n.º 6
0
    def setUp(self):
        if requests is None:
            raise unittest.SkipTest("Need to install requests to test oauth2")

        self.patch(requests, 'request', mock.Mock(spec=requests.request))
        self.patch(requests, 'post', mock.Mock(spec=requests.post))
        self.patch(requests, 'get', mock.Mock(spec=requests.get))

        self.googleAuth = oauth2.GoogleAuth("ggclientID", "clientSECRET")
        self.githubAuth = oauth2.GitHubAuth("ghclientID", "clientSECRET")
        master = self.make_master(url='h:/a/b/', auth=self.googleAuth)
        self.googleAuth.reconfigAuth(master, master.config)
        self.master = master = self.make_master(url='h:/a/b/',
                                                auth=self.githubAuth)
        self.githubAuth.reconfigAuth(master, master.config)
Ejemplo n.º 7
0
    def setUp(self):
        if requests is None:
            raise unittest.SkipTest("Need to install requests to test oauth2")

        self.patch(requests, 'request', mock.Mock(spec=requests.request))
        self.patch(requests, 'post', mock.Mock(spec=requests.post))
        self.patch(requests, 'get', mock.Mock(spec=requests.get))

        self.googleAuth = oauth2.GoogleAuth("ggclientID", "clientSECRET")
        self.githubAuth = oauth2.GitHubAuth("ghclientID", "clientSECRET")
        self.gitlabAuth = oauth2.GitLabAuth(
            "https://gitlab.test/", "glclientID", "clientSECRET")
        self.bitbucketAuth = oauth2.BitbucketAuth("bbclientID", "clientSECRET")

        for auth in [self.googleAuth, self.githubAuth, self.gitlabAuth, self.bitbucketAuth]:
            self._master = master = self.make_master(url='h:/a/b/', auth=auth)
            auth.reconfigAuth(master, master.config)