def test_nonmember_cannot_editor_private_repo(self):
        user = User(username="******",
                    password="******",
                    display_name="Display Name",
                    email="*****@*****.**")
        org = Organization(name="org", display_name="Organization")
        Repository(organization=org,
                   name="repo",
                   display_name="A Repository",
                   is_public=False)

        self.session.add(user)
        self.session.commit()

        self.assertFalse(
            RepositoryUserMapManager.is_editable(self.session, "username",
                                                 "org", "repo"))
    def test_repo_editor_can_editor_private_repo(self):
        user = User(username="******",
                    password="******",
                    display_name="Display Name",
                    email="*****@*****.**")
        org = Organization(name="org", display_name="Organization")
        OrganizationUserMap(organization=org, user=user, role_shortname='M')
        repo = Repository(organization=org,
                          name="repo",
                          display_name="A Repository",
                          is_public=False)
        RepositoryUserMap(repository=repo, user=user, role_shortname='E')

        self.session.add(user)
        self.session.commit()

        self.assertTrue(
            RepositoryUserMapManager.is_editable(self.session, "username",
                                                 "org", "repo"))
예제 #3
0
        org_name = match.group(1)
        repo_name = match.group(2)
        return (org_name, repo_name)

    match = re.search('(.+)/(.+).git', repo_path)
    if match:
        org_name = match.group(1)
        repo_name = match.group(2)
        return (org_name, repo_name)


if __name__ == "__main__":
    username = sys.argv[1]
    repo_path = sys.argv[2]

    org_repo_pair = parse_repo_path(repo_path)
    if not org_repo_pair:
        print(False)
    (org_name, repo_name) = org_repo_pair

    connection = postgres_engine().connect()
    Session = sessionmaker(bind=connection)
    session = Session()

    print(
        RepositoryUserMapManager.is_editable(session, username, org_name,
                                             repo_name))

    session.close()
    connection.close()