예제 #1
0
    def approve_account(account_name: str):
        """
        Approve user manually
        :param account_name: account name for approval
        """
        WhitelistModel.add_account(
            account_name=account_name,
            status=WhitelistStatus.approved_manually.value)

        logger.info(f"Account {account_name!r} approved successfully.")
예제 #2
0
    def approve_account(account_name: str) -> bool:
        """
        Approve user manually
        :param account_name: account name for approval
        :return:
        """
        WhitelistModel.add_account(
            account_name=account_name, status=WhitelistStatus.approved_manually.value
        )

        logger.info(f"Account {account_name} approved successfully")
        return True
예제 #3
0
def multiple_whitelist_entries():
    yield [
        WhitelistModel.add_account(account_name="Rayquaza",
                                   status="approved_manually"),
        WhitelistModel.add_account(account_name="Deoxys",
                                   status="approved_manually"),
        # Not a typo, account_name repeated intentionally to check behaviour
        WhitelistModel.add_account(account_name="Deoxys", status="waiting"),
        WhitelistModel.add_account(account_name="Solgaleo", status="waiting"),
        WhitelistModel.add_account(account_name="Zacian",
                                   status="approved_manually"),
    ]
예제 #4
0
def multiple_whitelist_entries():
    with get_sa_session() as session:
        session.query(WhitelistModel).delete()
        yield [
            WhitelistModel.add_account(account_name="Rayquaza",
                                       status="approved_manually"),
            WhitelistModel.add_account(account_name="Deoxys",
                                       status="approved_manually"),
            # Not a typo, account_name repeated intentionally to check behaviour
            WhitelistModel.add_account(account_name="Deoxys",
                                       status="waiting"),
            WhitelistModel.add_account(account_name="Solgaleo",
                                       status="waiting"),
            WhitelistModel.add_account(account_name="Zacian",
                                       status="approved_manually"),
        ]
예제 #5
0
    def add_account(self, event: InstallationEvent) -> bool:
        """
        Add account to whitelist.
        Status is set to 'waiting' or to 'approved_automatically'
        if the account is a packager in Fedora.
        :param event: Github app installation info
        :return: was the account (auto/already)-whitelisted?
        """
        if self.is_approved(event.account_login):
            return True

        WhitelistModel.add_account(event.account_login, WhitelistStatus.waiting.value)

        if self._signed_fpca(event.sender_login):
            event.status = WhitelistStatus.approved_automatically
            WhitelistModel.add_account(event.account_login, event.status.value)
            return True

        return False
예제 #6
0
def multiple_whitelist_entries():
    yield [
        WhitelistModel.add_account(
            account_name=SampleValues.account_name, status="approved_manually"
        ),
        WhitelistModel.add_account(
            account_name=SampleValues.different_account_name, status="approved_manually"
        ),
        # Not a typo, account_name repeated intentionally to check behaviour
        WhitelistModel.add_account(
            account_name=SampleValues.different_account_name, status="waiting"
        ),
        WhitelistModel.add_account(
            account_name=SampleValues.another_different_acount_name, status="waiting"
        ),
        WhitelistModel.add_account(
            account_name=SampleValues.yet_another_different_acount_name,
            status="approved_manually",
        ),
    ]
예제 #7
0
    def add_account(self, account_login: str, sender_login: str) -> bool:
        """
        Add account to whitelist.
        Status is set to 'waiting' or to 'approved_automatically'
        if the account is a packager in Fedora.
        :param sender_login: login of the user who installed the app into 'account'
        :param account_login: login of the account into which the app was installed
        :return: was the account (auto/already)-whitelisted?
        """
        if WhitelistModel.get_account(account_login):
            return True

        WhitelistModel.add_account(account_login,
                                   WhitelistStatus.waiting.value)

        if self._signed_fpca(sender_login):
            WhitelistModel.add_account(
                account_login, WhitelistStatus.approved_automatically.value)
            return True

        return False
예제 #8
0
def new_whitelist_entry():
    with get_sa_session() as session:
        session.query(WhitelistModel).delete()
        yield WhitelistModel.add_account(account_name="Rayquaza",
                                         status="approved_manually")
예제 #9
0
def new_whitelist_entry(clean_before_and_after):
    yield WhitelistModel.add_account(
        account_name=SampleValues.account_name, status="approved_manually"
    )
예제 #10
0
def new_whitelist_entry(clean_before_and_after):
    yield WhitelistModel.add_account(account_name="Rayquaza",
                                     status="approved_manually")