@@ -0,0 +1,2421 @@
+%22%22%22 Test public project protections %22%22%22%0Aimport json%0A%0Aimport pytest%0A%0Afrom dockci.models.project import Project%0Afrom dockci.server import DB%0A%0A%0A@pytest.fixture(scope='module')%0Adef projects(request):%0A    vals = %5B%0A        Project(slug='pp-pub1', repo='', name='', utility=False, public=True),%0A        Project(slug='pp-pri1', repo='', name='', utility=False, public=False),%0A        Project(slug='pp-pub2', repo='', name='', utility=False, public=True),%0A        Project(slug='pp-pri2', repo='', name='', utility=False, public=False),%0A    %5D%0A%0A    for proj in vals:%0A        proj_ex = Project.query.filter_by(slug=proj.slug).first()%0A        if proj_ex:%0A            DB.session.delete(proj_ex)%0A    DB.session.commit()%0A%0A    for proj in vals:%0A        DB.session.add(proj)%0A    DB.session.commit()%0A%0A    def fin():%0A        for proj in vals:%0A            DB.session.delete(proj)%0A        DB.session.commit()%0A    request.addfinalizer(fin)%0A%0A    return vals%0A%0A%0A@pytest.mark.usefixtures('db')%0A@pytest.mark.usefixtures('projects')%0Aclass TestPublicProjects(object):%0A    @pytest.mark.parametrize('url_prefix', %5B'', '/api/v1'%5D)%0A    @pytest.mark.parametrize('url,exp_status', %5B%0A        ('/projects/pp-pub1', 200),%0A        ('/projects/pp-pri1', 404),%0A        ('/projects/pp-pub2', 200),%0A        ('/projects/pp-pri2', 404),%0A    %5D)%0A    def test_project_guest(self,%0A                           client,%0A                           url_prefix,%0A                           url,%0A                           exp_status,%0A                           ):%0A        %22%22%22 Ensure only public projects accessible as guest %22%22%22%0A        full_url = '%25s%25s' %25 (url_prefix, url)%0A        response = client.get(full_url)%0A%0A        assert response.status_code == exp_status%0A%0A    @pytest.mark.parametrize('url_prefix', %5B'', '/api/v1'%5D)%0A    @pytest.mark.parametrize('url', %5B%0A        '/projects/pp-pub1',%0A        '/projects/pp-pri1',%0A        '/projects/pp-pub2',%0A        '/projects/pp-pri2',%0A    %5D)%0A    def test_project_user(self,%0A                          client,%0A                          user,%0A                          url_prefix,%0A                          url,%0A                          ):%0A        %22%22%22 Ensure all projects accessible as user %22%22%22%0A        full_url = '%25s%25s' %25 (url_prefix, url)%0A        response = client.get(full_url, headers=%7B%0A            'x_dockci_username': user.email,%0A            'x_dockci_password': 'testpass',%0A        %7D)%0A%0A        assert response.status_code == 200%0A

Add tests