示例#1
0
 def test_auth_normal(self, client):
     url = reverse("retina:home")
     user, _ = get_retina_user_with_token()
     client.force_login(user=user)
     try:
         response = client.get(url)
         assert response.status_code == status.HTTP_200_OK
     except ValueError as e:
         assert "Missing staticfiles manifest entry for" in str(e)
示例#2
0
 def test_auth_normal(self, client):
     url = reverse("retina:home")
     user, _ = get_retina_user_with_token()
     client.force_login(user=user)
     try:
         response = client.get(url)
         assert response.status_code == status.HTTP_200_OK
     except ValueError as e:
         assert "Missing staticfiles manifest entry for" in str(e)
示例#3
0
    def test_auth_staff(self, client):
        url = reverse("retina:home")
        user, _ = get_retina_user_with_token()
        client.force_login(user=user)

        try:
            response = client.get(url)
            assert response.status_code == status.HTTP_200_OK
        except ValueError as e:
            # On Travis a ValueError will be raised because django can't find all static files
            # since the static files are in a closed source submodule (DIAGNijmegen/retina-frontend)
            assert "Missing staticfiles manifest entry for" in str(e)
示例#4
0
    def test_auth_staff(self, client):
        url = reverse("retina:home")
        user, _ = get_retina_user_with_token()
        client.force_login(user=user)

        try:
            response = client.get(url)
            assert response.status_code == status.HTTP_200_OK
        except ValueError as e:
            # On Travis a ValueError will be raised because django can't find all static files
            # since the static files are in a closed source submodule (DIAGNijmegen/retina-frontend)
            assert "Missing staticfiles manifest entry for" in str(e)
示例#5
0
    def test_redirect_no_perm(self, client):
        ds = create_some_datastructure_data()
        url = reverse(
            "retina:api:image-api-view",
            args=[
                image_type,
                ds["patient"].name,
                ds["study"].name,
                ds["image_cf"].name,
                "default",
            ],
        )

        user, _ = get_retina_user_with_token()
        client.force_login(user=user)
        response = client.get(url, follow=True)
        expected_redirect_url = django_reverse(reverse_name,
                                               args=[ds["image_cf"].id])
        assert status.HTTP_302_FOUND == response.redirect_chain[0][1]
        assert expected_redirect_url == response.redirect_chain[0][0]
        assert status.HTTP_403_FORBIDDEN == response.status_code
示例#6
0
    def test_redirect_no_perm(self, client):
        ds = create_some_datastructure_data()
        url = reverse(
            "retina:api:image-api-view",
            args=[
                image_type,
                ds["patient"].name,
                ds["study"].name,
                ds["image_cf"].name,
                "default",
            ],
        )

        user, _ = get_retina_user_with_token()
        client.force_login(user=user)
        response = client.get(url, follow=True)
        expected_redirect_url = django_reverse(
            reverse_name, args=[ds["image_cf"].id]
        )
        assert status.HTTP_302_FOUND == response.redirect_chain[0][1]
        assert expected_redirect_url == response.redirect_chain[0][0]
        assert status.HTTP_403_FORBIDDEN == response.status_code
示例#7
0
    def test_redirect_kappa(self, client):
        ds = create_some_datastructure_data(archive_pars={"name": "kappadata"})
        url = reverse(
            "retina:api:image-api-view",
            args=[
                image_type,
                "Archives",
                ds["archive"].name,
                ds["image_cf"].name,
                "default",
            ],
        )
        user, _ = get_retina_user_with_token()
        client.force_login(user=user)
        ds["image_cf"].permit_viewing_by_retina_users()

        response = client.get(url, follow=True)
        expected_redirect_url = django_reverse(reverse_name,
                                               args=[ds["image_cf"].id])
        assert response.redirect_chain[0][1] == status.HTTP_302_FOUND
        assert expected_redirect_url == response.redirect_chain[0][0]
        assert status.HTTP_200_OK == response.status_code
示例#8
0
    def test_redirect_kappa(self, client):
        ds = create_some_datastructure_data(archive_pars={"name": "kappadata"})
        url = reverse(
            "retina:api:image-api-view",
            args=[
                image_type,
                "Archives",
                ds["archive"].name,
                ds["image_cf"].name,
                "default",
            ],
        )
        user, _ = get_retina_user_with_token()
        client.force_login(user=user)
        ds["image_cf"].permit_viewing_by_retina_users()

        response = client.get(url, follow=True)
        expected_redirect_url = django_reverse(
            reverse_name, args=[ds["image_cf"].id]
        )
        assert response.redirect_chain[0][1] == status.HTTP_302_FOUND
        assert expected_redirect_url == response.redirect_chain[0][0]
        assert status.HTTP_200_OK == response.status_code