def test_unavailable_indexd_upload_file( client, oauth_client, encoded_jwt, user_client, unauthorized_indexd_client, kid, rsa_private_key, google_proxy_group, primary_google_service_account, cloud_manager, google_signed_url, ): """ Test ``GET /data/upload/1``. """ path = "/data/upload/1" headers = { "Authorization": "Bearer " + jwt.encode( utils.unauthorized_context_claims(user_client.username, user_client.user_id), key=rsa_private_key, headers={"kid": kid}, algorithm="RS256", ) } response = client.get(path, headers=headers) assert response.status_code == 401 # response should not be JSON, should be HTML error page with pytest.raises(ValueError): response.json
def test_unavailable_indexd_upload_file( client, oauth_client, encoded_jwt, user_client, unauthorized_indexd_client, kid, rsa_private_key, google_proxy_group, primary_google_service_account, cloud_manager, google_signed_url, ): """ Test ``GET /data/upload/1``. """ path = "/data/upload/1" did = str(uuid.uuid4()) index_document = { "did": did, "baseid": "", "rev": "", "size": 10, "file_name": "file1", "urls": ["s3://bucket1/key-{}".format(did[:8])], "acl": ["phs000789"], "hashes": {}, "metadata": {}, "form": "", "created_date": "", "updated_date": "", } mock_index_document = mock.patch( "fence.blueprints.data.indexd.IndexedFile.index_document", index_document) mock_index_document.start() headers = { "Authorization": "Bearer " + jwt.encode( utils.unauthorized_context_claims(user_client.username, user_client.user_id), key=rsa_private_key, headers={ "kid": kid }, algorithm="RS256", ).decode("utf-8") } response = client.get(path, headers=headers) assert response.status_code == 401 # response should not be JSON, should be HTML error page assert response.mimetype == "text/html" assert not response.json mock_index_document.stop()