Ejemplo n.º 1
0
async def _build_user_instance(
    session: db.session.AsgardDBConnection,
    query_additional_criteria: sqlalchemy.sql.elements.BinaryExpression,
    auth_failed_log_data: dict,
):
    _build_base_query(session)
    rows = await session.filter(query_additional_criteria).all()
    if not rows:
        logger.warning(auth_failed_log_data)
        return None
    account_ids = [row.account_id for row in rows if row.account_id]
    user = UserDB(id=rows[0].id,
                  tx_name=rows[0].tx_name,
                  tx_email=rows[0].tx_email)
    user.account_ids = account_ids
    return user
Ejemplo n.º 2
0
 async def setUp(self):
     await super(TasksEndpointTest, self).setUp()
     self.user = UserDB()
     self.user.current_account = AccountDB(**ACCOUNT_DEV_DICT)
     self.auth_header = {
         "Authorization": f"Token {USER_WITH_MULTIPLE_ACCOUNTS_AUTH_KEY}"
     }
Ejemplo n.º 3
0
    def setUp(self):
        single_full_app_fixture = get_fixture("single_full_app.json")
        self.filter = AddOwnerConstraintFilter()

        self.request_app = AsgardApp.from_json(single_full_app_fixture)
        self.original_app = AsgardApp.from_json(single_full_app_fixture)
        self.user = UserDB()
        self.account_dev = Account(**ACCOUNT_DEV_DICT)
        self.user.current_account = self.account_dev
Ejemplo n.º 4
0
    async def setUp(self):
        await super(AuthenticationTest, self).setUp()

        self.normal_user = UserDB(
            tx_email=USER_WITH_MULTIPLE_ACCOUNTS_EMAIL,
            tx_name=USER_WITH_MULTIPLE_ACCOUNTS_NAME,
        )
        self.account = Account(**ACCOUNT_DEV_DICT)

        self.response_http_200 = Response(status=200)
Ejemplo n.º 5
0
 async def setUp(self):
     await super(DispatchResponse404Test, self).setUp()
     self.user = UserDB(
         tx_email="*****@*****.**",
         tx_name="John Doe",
         tx_authkey="69ed620926be4067a36402c3f7e9ddf0",
     )
     self.account_dev = AccountDB(id=4,
                                  name="Dev Team",
                                  namespace="dev",
                                  owner="company")
     self.user.accounts = [self.account_dev]
Ejemplo n.º 6
0
    async def setUp(self):
        await super(RoutesTest, self).setUp()
        self.user = UserDB()
        self.account_dev = AccountDB(
            id=ACCOUNT_DEV_ID,
            name=ACCOUNT_DEV_NAME,
            namespace=ACCOUNT_DEV_NAMESPACE,
            owner=ACCOUNT_DEV_OWNER,
        )
        self.user.accounts = [self.account_dev]

        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)
Ejemplo n.º 7
0
    async def setUp(self):
        await super(RequestHandlersTests, self).setUp()
        self.request_apps = [
            (MarathonApp(id="/xablau"), MarathonApp(id="/xena")),
            (MarathonApp(id="/foo"), MarathonApp(id="/bar")),
        ]

        self.user = UserDB(
            tx_email="*****@*****.**",
            tx_name="John Doe",
            tx_authkey="69ed620926be4067a36402c3f7e9ddf0",
        )
        self.account_dev = AccountDB(id=4,
                                     name="Dev Team",
                                     namespace="dev",
                                     owner="company")
        self.user.accounts = [self.account_dev]
Ejemplo n.º 8
0
 async def setUp(self):
     await super(HollowmanAppTest, self).setUp()
     fixture = get_fixture("single_full_app.json")
     self.user = UserDB(
         tx_email="*****@*****.**",
         tx_name="John Doe",
         tx_authkey="69ed620926be4067a36402c3f7e9ddf0",
     )
     self.account_dev = AccountDB(
         id=4, name="Dev Team", namespace="dev", owner="company"
     )
     responses.add(
         method="GET",
         url=conf.MARATHON_ADDRESSES[0] + "/v2/apps",
         body=json.dumps({"apps": [fixture]}),
         status=200,
         headers={"Content-Encoding": "chunked"},
     )
     responses.start()