Пример #1
0
    def setUp(self):
        rebuild_schema()
        self.session = HollowmanSession()

        self.account_dev = Account(id=4,
                                   name="Dev Team",
                                   namespace="dev",
                                   owner="company")
        self.account_infra = Account(name="Infra Team",
                                     namespace="infra",
                                     owner="company")

        self.user = User(tx_email="*****@*****.**", tx_name="John Doe")
        self.user.accounts = [self.account_dev, self.account_infra]

        self.user_with_one_account = User(
            tx_email="*****@*****.**",
            tx_name="User One Account")
        self.user_with_one_account.accounts = [self.account_dev]

        self.session.add(self.account_dev)
        self.session.add(self.account_infra)

        self.session.add(self.user)
        self.session.add(self.user_with_one_account)
        self.session.commit()
Пример #2
0
    def test_change_request_path_if_is_write_on_one_app(self, fixture):
        """
        Quando fazemos WRITE em cima de uma app específica, devemos
        ajustar o request.path para que o `upstream_request` seja feito
        no endpoint correto.
        """
        user = User(tx_name="User One", tx_email="*****@*****.**")
        user.current_account = Account(name="Dev",
                                       namespace="dev",
                                       owner="company")

        full_app_with_name_space = deepcopy(fixture)
        full_app_with_name_space['id'] = "/dev/foo"
        with application.test_request_context('/v2/apps//foo',
                                              method='PUT',
                                              data=json.dumps(fixture)) as ctx:
            with RequestsMock() as rsps:
                rsps.add(method='GET',
                         url=conf.MARATHON_ADDRESSES[0] + '/v2/apps//dev/foo',
                         body=json.dumps({'app': full_app_with_name_space}),
                         status=200)
                ctx.request.user = user
                request_parser = Request(ctx.request)

                apps = list(request_parser.split())

                request = request_parser.join(apps)
                self.assertIsInstance(request, HollowmanRequest)
                self.assertEqual("/v2/apps/dev/foo", request.path)
Пример #3
0
 def setUp(self, single_full_app_fixture):
     self.filter = NameSpaceFilter()
     self.request_app = SieveMarathonApp.from_json(single_full_app_fixture)
     self.original_app = SieveMarathonApp.from_json(single_full_app_fixture)
     self.account = Account(name="Dev Account", namespace="dev", owner="company")
     self.user = User(tx_email="*****@*****.**")
     self.user.current_account = self.account
Пример #4
0
 def setUp(self, single_full_app_fixture):
     self.single_full_app_fixture = single_full_app_fixture
     self.user = User(tx_name="User", tx_email="*****@*****.**")
     self.user.current_account = Account(name="Some Account", namespace="dev", owner="company")
     responses.add(method='GET', url=conf.MARATHON_ADDRESSES[0] + '/v2/apps//dev/foo',
                      body=json.dumps({'app': self.single_full_app_fixture}), status=200)
     responses.start()
Пример #5
0
 def setUp(self):
     self.empty_ok_response = FlaskResponse(response=b"{}",
                                            status=HTTPStatus.OK,
                                            headers={})
     self.user = User(tx_name="User One", tx_email="*****@*****.**")
     self.user.current_account = Account(name="Dev",
                                         namespace="dev",
                                         owner="company")
Пример #6
0
 def setUp(self, single_full_app_fixture):
     rebuild_schema()
     self.session = HollowmanSession()
     self.user = User(tx_email="*****@*****.**", tx_name="John Doe", tx_authkey="69ed620926be4067a36402c3f7e9ddf0")
     self.account_dev = Account(id=4, name="Dev Team", namespace="dev", owner="company")
     self.user.accounts = [self.account_dev]
     self.session.add(self.user)
     self.session.add(self.account_dev)
     self.session.commit()
Пример #7
0
 def setUp(self, single_full_app_fixture):
     self.filter = AutoDisableHTTPFilter()
     self.request_app = AsgardApp.from_json(single_full_app_fixture)
     self.original_app = AsgardApp.from_json(single_full_app_fixture)
     self.account = Account(name="Dev Account",
                            namespace="dev",
                            owner="company")
     self.user = User(tx_email="*****@*****.**")
     self.user.current_account = self.account
Пример #8
0
    def setUp(self):
        rebuild_schema()
        self.session = HollowmanSession()

        self.new_dispatcher_user = User(
            tx_email="*****@*****.**",
            tx_name="Xablau",
            tx_authkey="69ed620926be4067a36402c3f7e9ddf0")
        self.normal_user = User(tx_email="*****@*****.**",
                                tx_name="John Doe",
                                tx_authkey="70ed620926be4067a36402c3f7e9ddf0")
        self.account = Account(name="New Account",
                               namespace="acc",
                               owner="company")
        self.normal_user.accounts = [self.account]
        self.session.add_all([self.new_dispatcher_user, self.normal_user])
        self.session.commit()

        self.response_http_200 = Response(status=200)
Пример #9
0
 def setUp(self, fixture):
     rebuild_schema()
     self.session = HollowmanSession()
     self.user = User(tx_email="*****@*****.**",
                      tx_name="John Doe",
                      tx_authkey="69ed620926be4067a36402c3f7e9ddf0")
     self.account_dev = Account(id=4,
                                name="Dev Team",
                                namespace="dev",
                                owner="company")
     self.account_infra = Account(name="Infra Team",
                                  namespace="infra",
                                  owner="company")
     self.account_sup = Account(name="Support Team",
                                namespace="sup",
                                owner="company")
     self.user.accounts = [self.account_dev, self.account_infra]
     self.session.add(self.user)
     self.session.add(self.account_dev)
     self.session.add(self.account_infra)
     self.session.add(self.account_sup)
     self.user_with_no_accounts = User(
         tx_email="*****@*****.**",
         tx_name="No Accounts",
         tx_authkey="7b4184bfe7d2349eb56bcfb9dc246cf8")
     self.session.add(self.user_with_no_accounts)
     self.account_with_no_user = Account(name="Team Nobody",
                                         namespace="nobody",
                                         owner="nobody")
     self.session.add(self.account_with_no_user)
     self.session.commit()
     self.response_http_200 = MagicMock(status_code=200)
     responses.add(method='GET',
                   url=conf.MARATHON_ADDRESSES[0] + '/v2/apps',
                   body=json.dumps({'apps': [fixture]}),
                   status=200)
     responses.add(method='GET',
                   url=conf.MARATHON_ADDRESSES[0] + '/v2/apps//foo',
                   body=json.dumps({'app': fixture}),
                   status=200)
     responses.start()
Пример #10
0
    def setUp(self, single_full_app_fixture):

        self.request_apps = [
            (MarathonApp(id='/xablau'), MarathonApp(id='/xena')),
            (MarathonApp(id='/foo'), MarathonApp(id='/bar')),
        ]

        rebuild_schema()
        self.session = HollowmanSession()
        self.user = User(tx_email="*****@*****.**", tx_name="John Doe", tx_authkey="69ed620926be4067a36402c3f7e9ddf0")
        self.account_dev = Account(id=4, name="Dev Team", namespace="dev", owner="company")
        self.user.accounts = [self.account_dev]
        self.session.add(self.user)
        self.session.add(self.account_dev)
        self.session.commit()
Пример #11
0
    def setUp(self):
        rebuild_schema()
        self.session = HollowmanSession()
        self.user = User(tx_email="*****@*****.**",
                         tx_name="John Doe",
                         tx_authkey="69ed620926be4067a36402c3f7e9ddf0")
        self.account_dev = Account(id=4,
                                   name="Dev Team",
                                   namespace="dev",
                                   owner="company")
        self.user.accounts = [self.account_dev]
        self.session.add(self.account_dev)
        self.session.add(self.user)
        self.session.commit()

        self.proxy_mock_patcher = patch.object(hollowman.routes, 'raw_proxy')
        self.proxy_mock = self.proxy_mock_patcher.start()
        self.proxy_mock.return_value = Response(status=200)
Пример #12
0
    def setUp(self, single_full_app_fixture):
        self.filter = AddOwnerConstraintFilter()
        rebuild_schema()
        self.session = HollowmanSession()
        self.user = User(tx_email="*****@*****.**",
                         tx_name="John Doe",
                         tx_authkey="69ed620926be4067a36402c3f7e9ddf0")
        self.account_dev = Account(id=4,
                                   name="Dev Team",
                                   namespace="dev",
                                   owner="company")
        self.user.accounts = [self.account_dev]
        self.session.add(self.user)
        self.session.add(self.account_dev)
        self.session.commit()

        self.request_app = SieveMarathonApp.from_json(single_full_app_fixture)
        self.original_app = SieveMarathonApp.from_json(single_full_app_fixture)
        self.user.current_account = self.account_dev
Пример #13
0
 def setUp(self):
     self.user = User(tx_email="*****@*****.**")
     self.account = Account(name="Dev Account",
                            namespace="dev",
                            owner="company")
     self.user.current_account = self.account
Пример #14
0
 def setUp(self, single_full_app_fixture):
     self.single_full_app_fixture = single_full_app_fixture
     self.user = User(tx_name="User", tx_email="*****@*****.**")
     self.user.current_account = Account(name="Some Account",
                                         namespace="dev",
                                         owner="company")
Пример #15
0
 def setUp(self):
     self.user = User(tx_name="User One", tx_email="*****@*****.**")
     self.user.current_account = Account(name="Dev",
                                         namespace="dev",
                                         owner="company")
     responses.start()