{"action":"created","comment":{"url":"https://api.github.com/repos/elifesciences/fastly-iiif/pulls/comments/217038694","pull_request_review_id":154650429,"id":217038694,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxNzAzODY5NA==","diff_hunk":"@@ -0,0 +1,443 @@\n+import expect from 'expect';\n+import fs from 'promise-fs';\n+import pathTool from 'path';\n+import request from 'request-promise-native';\n+import uuid from 'uuid/v1';\n+\n+const { URLSearchParams } = require('url');\n+\n+const api = request.defaults({\n+  baseUrl: `https://api.fastly.com/service/${process.env.FASTLY_SERVICE_ID}/`,\n+  headers: {\n+    Accept: 'application/json',\n+    'Fastly-Key': process.env.FASTLY_API_KEY,\n+  },\n+});\n+\n+const domain = process.env.FASTLY_DOMAIN;\n+const baseUrl = `https://${domain}`;\n+const http = request.defaults({\n+  baseUrl,\n+  headers: {\n+    'Fastly-Debug': '1',\n+    'X-Test-Run': uuid(),\n+  },\n+  resolveWithFullResponse: true,\n+});\n+\n+const root = pathTool.resolve(__dirname, '../');\n+\n+beforeAll(async () => {\n+  const version = await api.post('version')\n+    .then(response => JSON.parse(response).number);\n+\n+  await Promise.all([\n+    api.post(`version/${version}/backend`).form({\n+      hostname: `${process.env.S3_BUCKET_NAME}.s3.amazonaws.com`,\n+      name: 'bucket',\n+      shield: 'dca-dc-us',\n+    }),\n+    api.post(`version/${version}/condition`).form({\n+      name: 'cats-prefix',\n+      statement: 'req.http.X-IIIF-Prefix == \"kittehs\"',\n+      type: 'REQUEST',\n+    }).then(() => api.post(`version/${version}/header`).form({\n+      name: 'cats-prefix',\n+      type: 'request',\n+      request_condition: 'cats-prefix',\n+      action: 'set',\n+      dst: 'url',\n+      src: '\"/cats/\" req.http.X-IIIF-Identifier \"?\" req.url.qs',\n+    })),\n+    api.post(`version/${version}/domain`).form({\n+      name: domain,\n+    }),\n+    api.post(`version/${version}/header`).form({\n+      name: 'vary-test-run',\n+      type: 'cache',\n+      action: 'append',\n+      dst: 'http.Vary',\n+      src: '\"X-Test-Run\"',\n+    }),\n+    api.post(`version/${version}/snippet`).form({\n+      name: 'IIIF config',\n+      dynamic: 0,\n+      type: 'init',\n+      content: `\n+sub iiif_config {\n+\n+  set req.http.X-IIIF-Version = if(req.http.X-Test-IIIF-Version, req.http.X-Test-IIIF-Version, \"2\");\n+\n+}\n+`,\n+    }),\n+    fs.readFile(`${root}/iiif.vcl`)\n+      .then((contents) => {\n+        api.post(`version/${version}/vcl`).form({\n+          name: 'IIIF',\n+          content: contents,\n+          main: true,\n+        });\n+      }),\n+  ]);\n+\n+  return api.put(`version/${version}/activate`);\n+});\n+\n+const imageUri = (originalParts) => {\n+  const parts = Object.assign({\n+    prefix: '',\n+    identifier: 'pug-life.jpg',\n+    region: 'full',\n+    size: 'full',\n+    rotation: 0,\n+    quality: 'default',\n+    format: 'jpg',\n+  }, originalParts);\n+\n+  return `${parts.prefix}/${parts.identifier}/${parts.region}/${parts.size}/${parts.rotation}/${parts.quality}.${parts.format}`;\n+};\n+\n+describe('Image request', () => {\n+  const ok = (iiifParameters, requestedIoParameters = {}, method = 'GET') => {\n+    const ioParameters = Object.assign({\n+      format: 'pjpg',\n+    }, requestedIoParameters);\n+\n+    const ioQueryParameters = new URLSearchParams(ioParameters);\n+\n+    expect.assertions(2);\n+\n+    return http({\n+      method,\n+      uri: imageUri(iiifParameters),\n+    })\n+      .then((response) => {\n+        expect(response.statusCode).toBe(200);\n+        expect(response.headers['x-fastly-io-url']).toBe(`/pug-life.jpg?${ioQueryParameters.toString()}`);\n+      });\n+  };\n+\n+  const error = (iiifParameters, statusCode, method = 'GET') => {\n+    expect.assertions(1);\n+\n+    return http({\n+      method,\n+      uri: imageUri(iiifParameters),\n+    })\n+      .catch(exception => expect(exception).toHaveProperty('statusCode', statusCode));\n+  };\n+\n+  const badRequest = iiifParameters => error(iiifParameters, 400);","path":"tests/v2.test.js","position":131,"original_position":131,"commit_id":"9de2627f8587a59028a40dd0fbf8287b9ccbc1b0","original_commit_id":"9de2627f8587a59028a40dd0fbf8287b9ccbc1b0","user":{"login":"tamlyn","id":115310,"node_id":"MDQ6VXNlcjExNTMxMA==","avatar_url":"https://avatars2.githubusercontent.com/u/115310?v=4","gravatar_id":"","url":"https://api.github.com/users/tamlyn","html_url":"https://github.com/tamlyn","followers_url":"https://api.github.com/users/tamlyn/followers","following_url":"https://api.github.com/users/tamlyn/following{/other_user}","gists_url":"https://api.github.com/users/tamlyn/gists{/gist_id}","starred_url":"https://api.github.com/users/tamlyn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tamlyn/subscriptions","organizations_url":"https://api.github.com/users/tamlyn/orgs","repos_url":"https://api.github.com/users/tamlyn/repos","events_url":"https://api.github.com/users/tamlyn/events{/privacy}","received_events_url":"https://api.github.com/users/tamlyn/received_events","type":"User","site_admin":false},"body":"You probably already know this, and it's not a problem here, but pointing it out as it's a common error: code in `describe` is executed immediately when the file is loaded. Illustration https://gist.github.com/tamlyn/dd6d54cdbe6eccd51a4bc61f5844bec4","created_at":"2018-09-12T13:50:49Z","updated_at":"2018-09-12T13:51:43Z","html_url":"https://github.com/elifesciences/fastly-iiif/pull/1#discussion_r217038694","pull_request_url":"https://api.github.com/repos/elifesciences/fastly-iiif/pulls/1","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/elifesciences/fastly-iiif/pulls/comments/217038694"},"html":{"href":"https://github.com/elifesciences/fastly-iiif/pull/1#discussion_r217038694"},"pull_request":{"href":"https://api.github.com/repos/elifesciences/fastly-iiif/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/elifesciences/fastly-iiif/pulls/1","id":206414027,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA2NDE0MDI3","html_url":"https://github.com/elifesciences/fastly-iiif/pull/1","diff_url":"https://github.com/elifesciences/fastly-iiif/pull/1.diff","patch_url":"https://github.com/elifesciences/fastly-iiif/pull/1.patch","issue_url":"https://api.github.com/repos/elifesciences/fastly-iiif/issues/1","number":1,"state":"open","locked":false,"title":"[WIP] Add minimum possible v2 implementation","user":{"login":"thewilkybarkid","id":1784740,"node_id":"MDQ6VXNlcjE3ODQ3NDA=","avatar_url":"https://avatars0.githubusercontent.com/u/1784740?v=4","gravatar_id":"","url":"https://api.github.com/users/thewilkybarkid","html_url":"https://github.com/thewilkybarkid","followers_url":"https://api.github.com/users/thewilkybarkid/followers","following_url":"https://api.github.com/users/thewilkybarkid/following{/other_user}","gists_url":"https://api.github.com/users/thewilkybarkid/gists{/gist_id}","starred_url":"https://api.github.com/users/thewilkybarkid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thewilkybarkid/subscriptions","organizations_url":"https://api.github.com/users/thewilkybarkid/orgs","repos_url":"https://api.github.com/users/thewilkybarkid/repos","events_url":"https://api.github.com/users/thewilkybarkid/events{/privacy}","received_events_url":"https://api.github.com/users/thewilkybarkid/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-08-06T14:19:02Z","updated_at":"2018-09-12T13:51:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6d3136f0063b152c3a2d9042a3b082b120b4fe70","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/elifesciences/fastly-iiif/pulls/1/commits","review_comments_url":"https://api.github.com/repos/elifesciences/fastly-iiif/pulls/1/comments","review_comment_url":"https://api.github.com/repos/elifesciences/fastly-iiif/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elifesciences/fastly-iiif/issues/1/comments","statuses_url":"https://api.github.com/repos/elifesciences/fastly-iiif/statuses/9de2627f8587a59028a40dd0fbf8287b9ccbc1b0","head":{"label":"elifesciences:v2-minimum","ref":"v2-minimum","sha":"9de2627f8587a59028a40dd0fbf8287b9ccbc1b0","user":{"login":"elifesciences","id":1777367,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3NzczNjc=","avatar_url":"https://avatars2.githubusercontent.com/u/1777367?v=4","gravatar_id":"","url":"https://api.github.com/users/elifesciences","html_url":"https://github.com/elifesciences","followers_url":"https://api.github.com/users/elifesciences/followers","following_url":"https://api.github.com/users/elifesciences/following{/other_user}","gists_url":"https://api.github.com/users/elifesciences/gists{/gist_id}","starred_url":"https://api.github.com/users/elifesciences/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elifesciences/subscriptions","organizations_url":"https://api.github.com/users/elifesciences/orgs","repos_url":"https://api.github.com/users/elifesciences/repos","events_url":"https://api.github.com/users/elifesciences/events{/privacy}","received_events_url":"https://api.github.com/users/elifesciences/received_events","type":"Organization","site_admin":false},"repo":{"id":143728050,"node_id":"MDEwOlJlcG9zaXRvcnkxNDM3MjgwNTA=","name":"fastly-iiif","full_name":"elifesciences/fastly-iiif","owner":{"login":"elifesciences","id":1777367,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3NzczNjc=","avatar_url":"https://avatars2.githubusercontent.com/u/1777367?v=4","gravatar_id":"","url":"https://api.github.com/users/elifesciences","html_url":"https://github.com/elifesciences","followers_url":"https://api.github.com/users/elifesciences/followers","following_url":"https://api.github.com/users/elifesciences/following{/other_user}","gists_url":"https://api.github.com/users/elifesciences/gists{/gist_id}","starred_url":"https://api.github.com/users/elifesciences/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elifesciences/subscriptions","organizations_url":"https://api.github.com/users/elifesciences/orgs","repos_url":"https://api.github.com/users/elifesciences/repos","events_url":"https://api.github.com/users/elifesciences/events{/privacy}","received_events_url":"https://api.github.com/users/elifesciences/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elifesciences/fastly-iiif","description":"IIIF image API implemented using Fastly IO","fork":false,"url":"https://api.github.com/repos/elifesciences/fastly-iiif","forks_url":"https://api.github.com/repos/elifesciences/fastly-iiif/forks","keys_url":"https://api.github.com/repos/elifesciences/fastly-iiif/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elifesciences/fastly-iiif/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elifesciences/fastly-iiif/teams","hooks_url":"https://api.github.com/repos/elifesciences/fastly-iiif/hooks","issue_events_url":"https://api.github.com/repos/elifesciences/fastly-iiif/issues/events{/number}","events_url":"https://api.github.com/repos/elifesciences/fastly-iiif/events","assignees_url":"https://api.github.com/repos/elifesciences/fastly-iiif/assignees{/user}","branches_url":"https://api.github.com/repos/elifesciences/fastly-iiif/branches{/branch}","tags_url":"https://api.github.com/repos/elifesciences/fastly-iiif/tags","blobs_url":"https://api.github.com/repos/elifesciences/fastly-iiif/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elifesciences/fastly-iiif/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elifesciences/fastly-iiif/git/refs{/sha}","trees_url":"https://api.github.com/repos/elifesciences/fastly-iiif/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elifesciences/fastly-iiif/statuses/{sha}","languages_url":"https://api.github.com/repos/elifesciences/fastly-iiif/languages","stargazers_url":"https://api.github.com/repos/elifesciences/fastly-iiif/stargazers","contributors_url":"https://api.github.com/repos/elifesciences/fastly-iiif/contributors","subscribers_url":"https://api.github.com/repos/elifesciences/fastly-iiif/subscribers","subscription_url":"https://api.github.com/repos/elifesciences/fastly-iiif/subscription","commits_url":"https://api.github.com/repos/elifesciences/fastly-iiif/commits{/sha}","git_commits_url":"https://api.github.com/repos/elifesciences/fastly-iiif/git/commits{/sha}","comments_url":"https://api.github.com/repos/elifesciences/fastly-iiif/comments{/number}","issue_comment_url":"https://api.github.com/repos/elifesciences/fastly-iiif/issues/comments{/number}","contents_url":"https://api.github.com/repos/elifesciences/fastly-iiif/contents/{+path}","compare_url":"https://api.github.com/repos/elifesciences/fastly-iiif/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elifesciences/fastly-iiif/merges","archive_url":"https://api.github.com/repos/elifesciences/fastly-iiif/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elifesciences/fastly-iiif/downloads","issues_url":"https://api.github.com/repos/elifesciences/fastly-iiif/issues{/number}","pulls_url":"https://api.github.com/repos/elifesciences/fastly-iiif/pulls{/number}","milestones_url":"https://api.github.com/repos/elifesciences/fastly-iiif/milestones{/number}","notifications_url":"https://api.github.com/repos/elifesciences/fastly-iiif/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elifesciences/fastly-iiif/labels{/name}","releases_url":"https://api.github.com/repos/elifesciences/fastly-iiif/releases{/id}","deployments_url":"https://api.github.com/repos/elifesciences/fastly-iiif/deployments","created_at":"2018-08-06T12:51:23Z","updated_at":"2018-08-06T12:55:51Z","pushed_at":"2018-09-12T08:12:24Z","git_url":"git://github.com/elifesciences/fastly-iiif.git","ssh_url":"git@github.com:elifesciences/fastly-iiif.git","clone_url":"https://github.com/elifesciences/fastly-iiif.git","svn_url":"https://github.com/elifesciences/fastly-iiif","homepage":null,"size":144,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"elifesciences:master","ref":"master","sha":"73f5421d4a79a231e5692ff268b736a3e537f9f4","user":{"login":"elifesciences","id":1777367,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3NzczNjc=","avatar_url":"https://avatars2.githubusercontent.com/u/1777367?v=4","gravatar_id":"","url":"https://api.github.com/users/elifesciences","html_url":"https://github.com/elifesciences","followers_url":"https://api.github.com/users/elifesciences/followers","following_url":"https://api.github.com/users/elifesciences/following{/other_user}","gists_url":"https://api.github.com/users/elifesciences/gists{/gist_id}","starred_url":"https://api.github.com/users/elifesciences/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elifesciences/subscriptions","organizations_url":"https://api.github.com/users/elifesciences/orgs","repos_url":"https://api.github.com/users/elifesciences/repos","events_url":"https://api.github.com/users/elifesciences/events{/privacy}","received_events_url":"https://api.github.com/users/elifesciences/received_events","type":"Organization","site_admin":false},"repo":{"id":143728050,"node_id":"MDEwOlJlcG9zaXRvcnkxNDM3MjgwNTA=","name":"fastly-iiif","full_name":"elifesciences/fastly-iiif","owner":{"login":"elifesciences","id":1777367,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3NzczNjc=","avatar_url":"https://avatars2.githubusercontent.com/u/1777367?v=4","gravatar_id":"","url":"https://api.github.com/users/elifesciences","html_url":"https://github.com/elifesciences","followers_url":"https://api.github.com/users/elifesciences/followers","following_url":"https://api.github.com/users/elifesciences/following{/other_user}","gists_url":"https://api.github.com/users/elifesciences/gists{/gist_id}","starred_url":"https://api.github.com/users/elifesciences/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elifesciences/subscriptions","organizations_url":"https://api.github.com/users/elifesciences/orgs","repos_url":"https://api.github.com/users/elifesciences/repos","events_url":"https://api.github.com/users/elifesciences/events{/privacy}","received_events_url":"https://api.github.com/users/elifesciences/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elifesciences/fastly-iiif","description":"IIIF image API implemented using Fastly IO","fork":false,"url":"https://api.github.com/repos/elifesciences/fastly-iiif","forks_url":"https://api.github.com/repos/elifesciences/fastly-iiif/forks","keys_url":"https://api.github.com/repos/elifesciences/fastly-iiif/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elifesciences/fastly-iiif/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elifesciences/fastly-iiif/teams","hooks_url":"https://api.github.com/repos/elifesciences/fastly-iiif/hooks","issue_events_url":"https://api.github.com/repos/elifesciences/fastly-iiif/issues/events{/number}","events_url":"https://api.github.com/repos/elifesciences/fastly-iiif/events","assignees_url":"https://api.github.com/repos/elifesciences/fastly-iiif/assignees{/user}","branches_url":"https://api.github.com/repos/elifesciences/fastly-iiif/branches{/branch}","tags_url":"https://api.github.com/repos/elifesciences/fastly-iiif/tags","blobs_url":"https://api.github.com/repos/elifesciences/fastly-iiif/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elifesciences/fastly-iiif/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elifesciences/fastly-iiif/git/refs{/sha}","trees_url":"https://api.github.com/repos/elifesciences/fastly-iiif/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elifesciences/fastly-iiif/statuses/{sha}","languages_url":"https://api.github.com/repos/elifesciences/fastly-iiif/languages","stargazers_url":"https://api.github.com/repos/elifesciences/fastly-iiif/stargazers","contributors_url":"https://api.github.com/repos/elifesciences/fastly-iiif/contributors","subscribers_url":"https://api.github.com/repos/elifesciences/fastly-iiif/subscribers","subscription_url":"https://api.github.com/repos/elifesciences/fastly-iiif/subscription","commits_url":"https://api.github.com/repos/elifesciences/fastly-iiif/commits{/sha}","git_commits_url":"https://api.github.com/repos/elifesciences/fastly-iiif/git/commits{/sha}","comments_url":"https://api.github.com/repos/elifesciences/fastly-iiif/comments{/number}","issue_comment_url":"https://api.github.com/repos/elifesciences/fastly-iiif/issues/comments{/number}","contents_url":"https://api.github.com/repos/elifesciences/fastly-iiif/contents/{+path}","compare_url":"https://api.github.com/repos/elifesciences/fastly-iiif/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elifesciences/fastly-iiif/merges","archive_url":"https://api.github.com/repos/elifesciences/fastly-iiif/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elifesciences/fastly-iiif/downloads","issues_url":"https://api.github.com/repos/elifesciences/fastly-iiif/issues{/number}","pulls_url":"https://api.github.com/repos/elifesciences/fastly-iiif/pulls{/number}","milestones_url":"https://api.github.com/repos/elifesciences/fastly-iiif/milestones{/number}","notifications_url":"https://api.github.com/repos/elifesciences/fastly-iiif/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elifesciences/fastly-iiif/labels{/name}","releases_url":"https://api.github.com/repos/elifesciences/fastly-iiif/releases{/id}","deployments_url":"https://api.github.com/repos/elifesciences/fastly-iiif/deployments","created_at":"2018-08-06T12:51:23Z","updated_at":"2018-08-06T12:55:51Z","pushed_at":"2018-09-12T08:12:24Z","git_url":"git://github.com/elifesciences/fastly-iiif.git","ssh_url":"git@github.com:elifesciences/fastly-iiif.git","clone_url":"https://github.com/elifesciences/fastly-iiif.git","svn_url":"https://github.com/elifesciences/fastly-iiif","homepage":null,"size":144,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elifesciences/fastly-iiif/pulls/1"},"html":{"href":"https://github.com/elifesciences/fastly-iiif/pull/1"},"issue":{"href":"https://api.github.com/repos/elifesciences/fastly-iiif/issues/1"},"comments":{"href":"https://api.github.com/repos/elifesciences/fastly-iiif/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/elifesciences/fastly-iiif/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/elifesciences/fastly-iiif/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elifesciences/fastly-iiif/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/elifesciences/fastly-iiif/statuses/9de2627f8587a59028a40dd0fbf8287b9ccbc1b0"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"tamlyn"}}