def test_no_auth_on_non_public_project(self): self.project.is_public = False self.project.save() unauthenticated_client = Client() resp = unauthenticated_client.get('/api/data/mygroup/myproject?metric=foo&metric=bar/baz&environment=env1') self.assertEqual(401, resp.status_code)
def test_auth_from_web_ui(self): self.project.is_public = False self.project.save() web_client = Client() user = User.objects.create(username='******') self.group.add_admin(user) web_client.force_login(user) resp = web_client.get('/api/data/mygroup/myproject?metric=foo&metric=bar/baz&environment=env1') self.assertEqual(200, resp.status_code)