diff --git a/bin/record.js b/bin/record.js index a7fb9e34..4446f3bb 100755 --- a/bin/record.js +++ b/bin/record.js @@ -66,7 +66,10 @@ scenarios.reduce(async (promise, scenarioPath) => { if (fixturesDiffs[0][0] === '-') { if (doUpdate) { console.log(`📼 New fixtures recorded`) - return write(fixtureName, newNormalizedFixtures) + return write(fixtureName, { + normalized: newNormalizedFixtures, + raw: newRawFixtures + }) } console.log(`❌ "${fixtureName}" looks like a new fixture`) return @@ -74,7 +77,10 @@ scenarios.reduce(async (promise, scenarioPath) => { if (doUpdate) { console.log(`📼 Fixture updates recorded`) - return write(fixtureName, newNormalizedFixtures) + return write(fixtureName, { + normalized: newNormalizedFixtures, + raw: newRawFixtures + }) } console.log(`❌ Fixtures are not up-to-date`) diff --git a/lib/normalize/combined-status.js b/lib/normalize/combined-status.js new file mode 100644 index 00000000..cb8e3073 --- /dev/null +++ b/lib/normalize/combined-status.js @@ -0,0 +1,33 @@ +module.exports = normalizeCombinedStatus + +const normalizeRepository = require('./repository') +const normalizeStatus = require('./status') +const setIfExists = require('../set-if-exists') +const temporaryRepository = require('../temporary-repository') + +function normalizeCombinedStatus (response, fixture) { + // set all dates to Universe 2017 Keynote time + setIfExists(response, 'created_at', '2017-10-10T16:00:00Z') + setIfExists(response, 'updated_at', '2017-10-10T16:00:00Z') + + // zerofy sha + setIfExists(response, 'sha', '0000000000000000000000000000000000000000') + + // normalize temporary repository & zerofy sha in URLs + setIfExists(response, 'url', url => { + return url + .replace(temporaryRepository.regex, '$1') + .replace(/[0-9a-f]{40}\/status$/, '0000000000000000000000000000000000000000/status') + }) + setIfExists(response, 'commit_url', url => { + return url + .replace(temporaryRepository.regex, '$1') + .replace(/[0-9a-f]{40}$/, '0000000000000000000000000000000000000000') + }) + + response.statuses.forEach(normalizeStatus) + normalizeRepository(response.repository) + + // zerofy sha in fixture and location header if present + fixture.path = fixture.path.replace(/[0-9a-f]{40}\/status$/, '0000000000000000000000000000000000000000/status') +} diff --git a/lib/normalize/index.js b/lib/normalize/index.js index c0150b93..4c036adb 100644 --- a/lib/normalize/index.js +++ b/lib/normalize/index.js @@ -16,9 +16,7 @@ function normalize (fixture) { // rename temporary repositories // e.g. tmp-scenario-bar-20170924033013835 => bar - if (temporaryRepository.regex.test(fixture.path)) { - fixture.path = fixture.path.replace(temporaryRepository.regex, '$1') - } + fixture.path = fixture.path.replace(temporaryRepository.regex, '$1') if (fixture.headers.location && temporaryRepository.regex.test(fixture.headers.location)) { fixture.headers.location = fixture.headers.location.replace(temporaryRepository.regex, '$1') } @@ -83,7 +81,7 @@ function normalize (fixture) { responses.forEach(response => { const entityName = toEntityName(response) if (entityName) { - require(`./${entityName}`)(response) + require(`./${entityName}`)(response, fixture) } }) diff --git a/lib/normalize/status.js b/lib/normalize/status.js new file mode 100644 index 00000000..e7dc66cb --- /dev/null +++ b/lib/normalize/status.js @@ -0,0 +1,33 @@ +module.exports = normalizeStatus + +const normalizeUser = require('./user') +const setIfExists = require('../set-if-exists') +const temporaryRepository = require('../temporary-repository') + +function normalizeStatus (response, fixture) { + // set ID to 1 + setIfExists(response, 'id', 1) + + // set all dates to Universe 2017 Keynote time + setIfExists(response, 'created_at', '2017-10-10T16:00:00Z') + setIfExists(response, 'updated_at', '2017-10-10T16:00:00Z') + + // normalize temporary repository & zerofy sha + setIfExists(response, 'url', url => { + return url + .replace(temporaryRepository.regex, '$1') + .replace(/[0-9a-f]{40}$/, '0000000000000000000000000000000000000000') + }) + + normalizeUser(response.creator) + + // zerofy sha in fixture and location header if present + if (typeof fixture !== 'object') { + return + } + + fixture.path = fixture.path.replace(/[0-9a-f]{40}(\/statuses)?$/, '0000000000000000000000000000000000000000$1') + if (fixture.headers.location) { + fixture.headers.location = fixture.headers.location.replace(/[0-9a-f]{40}(\/statuses)?$/, '0000000000000000000000000000000000000000$1') + } +} diff --git a/lib/to-entity-name.js b/lib/to-entity-name.js index e2a790ca..f6cdbca7 100644 --- a/lib/to-entity-name.js +++ b/lib/to-entity-name.js @@ -22,4 +22,10 @@ function toEntityName (object) { if ('content' in object && 'commit' in object) { return 'file-change' } + if (/\/statuses\/[0-9a-f]{40}$/.test(object.url)) { + return 'status' + } + if (/\/commits\/[0-9a-f]{40}\/status$/.test(object.url)) { + return 'combined-status' + } } diff --git a/scenarios/api.github.com/create-status/normalized-fixture.json b/scenarios/api.github.com/create-status/normalized-fixture.json new file mode 100644 index 00000000..73788db8 --- /dev/null +++ b/scenarios/api.github.com/create-status/normalized-fixture.json @@ -0,0 +1,374 @@ +[ + { + "scope": "https://api.github.com:443", + "method": "post", + "path": "/repos/octokit-fixture-org/create-status/statuses/0000000000000000000000000000000000000000", + "body": { + "state": "failure", + "target_url": "https://example.com", + "description": "create-status failure test", + "context": "example/1" + }, + "status": 201, + "response": { + "url": "https://api.github.com/repos/octokit-fixture-org/create-status/statuses/0000000000000000000000000000000000000000", + "id": 1, + "state": "failure", + "description": "create-status failure test", + "target_url": "https://example.com", + "context": "example/1", + "created_at": "2017-10-10T16:00:00Z", + "updated_at": "2017-10-10T16:00:00Z", + "creator": { + "login": "octokit-fixture-user-a", + "id": 1, + "avatar_url": "https://avatars0.githubusercontent.com/u/1?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/octokit-fixture-user-a", + "html_url": "https://github.com/octokit-fixture-user-a", + "followers_url": "https://api.github.com/users/octokit-fixture-user-a/followers", + "following_url": "https://api.github.com/users/octokit-fixture-user-a/following{/other_user}", + "gists_url": "https://api.github.com/users/octokit-fixture-user-a/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octokit-fixture-user-a/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octokit-fixture-user-a/subscriptions", + "organizations_url": "https://api.github.com/users/octokit-fixture-user-a/orgs", + "repos_url": "https://api.github.com/users/octokit-fixture-user-a/repos", + "events_url": "https://api.github.com/users/octokit-fixture-user-a/events{/privacy}", + "received_events_url": "https://api.github.com/users/octokit-fixture-user-a/received_events", + "type": "User", + "site_admin": false + } + }, + "reqheaders": { + "accept": "application/vnd.github.v3+json", + "content-type": "application/json; charset=utf-8", + "authorization": "token 0000000000000000000000000000000000000000", + "content-length": 119, + "host": "api.github.com" + }, + "headers": { + "access-control-allow-origin": "*", + "access-control-expose-headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", + "cache-control": "private, max-age=60, s-maxage=60", + "connection": "close", + "content-length": "1359", + "content-security-policy": "default-src 'none'", + "content-type": "application/json; charset=utf-8", + "date": "Tue, 10 Oct 2017 16:00:00 GMT", + "etag": "\"00000000000000000000000000000000\"", + "location": "https://api.github.com/repos/octokit-fixture-org/create-status/statuses/0000000000000000000000000000000000000000", + "status": "201 Created", + "strict-transport-security": "max-age=31536000; includeSubdomains; preload", + "x-accepted-oauth-scopes": "", + "x-content-type-options": "nosniff", + "x-frame-options": "deny", + "x-github-media-type": "github.v3; format=json", + "x-github-request-id": "0000:00000:0000000:0000000:00000000", + "x-oauth-scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user", + "x-ratelimit-limit": "5000", + "x-ratelimit-remaining": "4999", + "x-ratelimit-reset": "1507651200000", + "x-runtime-rack": "0.000000", + "x-xss-protection": "1; mode=block" + } + }, + { + "scope": "https://api.github.com:443", + "method": "post", + "path": "/repos/octokit-fixture-org/create-status/statuses/0000000000000000000000000000000000000000", + "body": { + "state": "success", + "target_url": "https://example.com", + "description": "create-status success test", + "context": "example/2" + }, + "status": 201, + "response": { + "url": "https://api.github.com/repos/octokit-fixture-org/create-status/statuses/0000000000000000000000000000000000000000", + "id": 1, + "state": "success", + "description": "create-status success test", + "target_url": "https://example.com", + "context": "example/2", + "created_at": "2017-10-10T16:00:00Z", + "updated_at": "2017-10-10T16:00:00Z", + "creator": { + "login": "octokit-fixture-user-a", + "id": 1, + "avatar_url": "https://avatars0.githubusercontent.com/u/1?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/octokit-fixture-user-a", + "html_url": "https://github.com/octokit-fixture-user-a", + "followers_url": "https://api.github.com/users/octokit-fixture-user-a/followers", + "following_url": "https://api.github.com/users/octokit-fixture-user-a/following{/other_user}", + "gists_url": "https://api.github.com/users/octokit-fixture-user-a/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octokit-fixture-user-a/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octokit-fixture-user-a/subscriptions", + "organizations_url": "https://api.github.com/users/octokit-fixture-user-a/orgs", + "repos_url": "https://api.github.com/users/octokit-fixture-user-a/repos", + "events_url": "https://api.github.com/users/octokit-fixture-user-a/events{/privacy}", + "received_events_url": "https://api.github.com/users/octokit-fixture-user-a/received_events", + "type": "User", + "site_admin": false + } + }, + "reqheaders": { + "accept": "application/vnd.github.v3+json", + "content-type": "application/json; charset=utf-8", + "authorization": "token 0000000000000000000000000000000000000000", + "content-length": 119, + "host": "api.github.com" + }, + "headers": { + "access-control-allow-origin": "*", + "access-control-expose-headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", + "cache-control": "private, max-age=60, s-maxage=60", + "connection": "close", + "content-length": "1359", + "content-security-policy": "default-src 'none'", + "content-type": "application/json; charset=utf-8", + "date": "Tue, 10 Oct 2017 16:00:00 GMT", + "etag": "\"00000000000000000000000000000000\"", + "location": "https://api.github.com/repos/octokit-fixture-org/create-status/statuses/0000000000000000000000000000000000000000", + "status": "201 Created", + "strict-transport-security": "max-age=31536000; includeSubdomains; preload", + "x-accepted-oauth-scopes": "", + "x-content-type-options": "nosniff", + "x-frame-options": "deny", + "x-github-media-type": "github.v3; format=json", + "x-github-request-id": "0000:00000:0000000:0000000:00000000", + "x-oauth-scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user", + "x-ratelimit-limit": "5000", + "x-ratelimit-remaining": "4999", + "x-ratelimit-reset": "1507651200000", + "x-runtime-rack": "0.000000", + "x-xss-protection": "1; mode=block" + } + }, + { + "scope": "https://api.github.com:443", + "method": "get", + "path": "/repos/octokit-fixture-org/create-status/commits/0000000000000000000000000000000000000000/statuses", + "body": "", + "status": 200, + "response": [ + { + "url": "https://api.github.com/repos/octokit-fixture-org/create-status/statuses/0000000000000000000000000000000000000000", + "id": 1, + "state": "success", + "description": "create-status success test", + "target_url": "https://example.com", + "context": "example/2", + "created_at": "2017-10-10T16:00:00Z", + "updated_at": "2017-10-10T16:00:00Z", + "creator": { + "login": "octokit-fixture-user-a", + "id": 1, + "avatar_url": "https://avatars0.githubusercontent.com/u/1?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/octokit-fixture-user-a", + "html_url": "https://github.com/octokit-fixture-user-a", + "followers_url": "https://api.github.com/users/octokit-fixture-user-a/followers", + "following_url": "https://api.github.com/users/octokit-fixture-user-a/following{/other_user}", + "gists_url": "https://api.github.com/users/octokit-fixture-user-a/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octokit-fixture-user-a/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octokit-fixture-user-a/subscriptions", + "organizations_url": "https://api.github.com/users/octokit-fixture-user-a/orgs", + "repos_url": "https://api.github.com/users/octokit-fixture-user-a/repos", + "events_url": "https://api.github.com/users/octokit-fixture-user-a/events{/privacy}", + "received_events_url": "https://api.github.com/users/octokit-fixture-user-a/received_events", + "type": "User", + "site_admin": false + } + }, + { + "url": "https://api.github.com/repos/octokit-fixture-org/create-status/statuses/0000000000000000000000000000000000000000", + "id": 1, + "state": "failure", + "description": "create-status failure test", + "target_url": "https://example.com", + "context": "example/1", + "created_at": "2017-10-10T16:00:00Z", + "updated_at": "2017-10-10T16:00:00Z", + "creator": { + "login": "octokit-fixture-user-a", + "id": 1, + "avatar_url": "https://avatars0.githubusercontent.com/u/1?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/octokit-fixture-user-a", + "html_url": "https://github.com/octokit-fixture-user-a", + "followers_url": "https://api.github.com/users/octokit-fixture-user-a/followers", + "following_url": "https://api.github.com/users/octokit-fixture-user-a/following{/other_user}", + "gists_url": "https://api.github.com/users/octokit-fixture-user-a/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octokit-fixture-user-a/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octokit-fixture-user-a/subscriptions", + "organizations_url": "https://api.github.com/users/octokit-fixture-user-a/orgs", + "repos_url": "https://api.github.com/users/octokit-fixture-user-a/repos", + "events_url": "https://api.github.com/users/octokit-fixture-user-a/events{/privacy}", + "received_events_url": "https://api.github.com/users/octokit-fixture-user-a/received_events", + "type": "User", + "site_admin": false + } + } + ], + "reqheaders": { + "accept": "application/vnd.github.v3+json", + "authorization": "token 0000000000000000000000000000000000000000", + "host": "api.github.com" + }, + "headers": { + "access-control-allow-origin": "*", + "access-control-expose-headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", + "cache-control": "private, max-age=60, s-maxage=60", + "connection": "close", + "content-length": "2721", + "content-security-policy": "default-src 'none'", + "content-type": "application/json; charset=utf-8", + "date": "Tue, 10 Oct 2017 16:00:00 GMT", + "etag": "\"00000000000000000000000000000000\"", + "status": "200 OK", + "strict-transport-security": "max-age=31536000; includeSubdomains; preload", + "x-accepted-oauth-scopes": "repo, repo:status", + "x-content-type-options": "nosniff", + "x-frame-options": "deny", + "x-github-media-type": "github.v3; format=json", + "x-github-request-id": "0000:00000:0000000:0000000:00000000", + "x-oauth-scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user", + "x-ratelimit-limit": "5000", + "x-ratelimit-remaining": "4999", + "x-ratelimit-reset": "1507651200000", + "x-runtime-rack": "0.000000", + "x-xss-protection": "1; mode=block" + } + }, + { + "scope": "https://api.github.com:443", + "method": "get", + "path": "/repos/octokit-fixture-org/create-status/commits/0000000000000000000000000000000000000000/status", + "body": "", + "status": 200, + "response": { + "state": "failure", + "statuses": [ + { + "url": "https://api.github.com/repos/octokit-fixture-org/create-status/statuses/0000000000000000000000000000000000000000", + "id": 1, + "state": "failure", + "description": "create-status failure test", + "target_url": "https://example.com", + "context": "example/1", + "created_at": "2017-10-10T16:00:00Z", + "updated_at": "2017-10-10T16:00:00Z" + }, + { + "url": "https://api.github.com/repos/octokit-fixture-org/create-status/statuses/0000000000000000000000000000000000000000", + "id": 1, + "state": "success", + "description": "create-status success test", + "target_url": "https://example.com", + "context": "example/2", + "created_at": "2017-10-10T16:00:00Z", + "updated_at": "2017-10-10T16:00:00Z" + } + ], + "sha": "0000000000000000000000000000000000000000", + "total_count": 2, + "repository": { + "id": 1, + "name": "create-status", + "full_name": "octokit-fixture-org/create-status", + "owner": { + "login": "octokit-fixture-org", + "id": 1, + "avatar_url": "https://avatars2.githubusercontent.com/u/1?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/octokit-fixture-org", + "html_url": "https://github.com/octokit-fixture-org", + "followers_url": "https://api.github.com/users/octokit-fixture-org/followers", + "following_url": "https://api.github.com/users/octokit-fixture-org/following{/other_user}", + "gists_url": "https://api.github.com/users/octokit-fixture-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octokit-fixture-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octokit-fixture-org/subscriptions", + "organizations_url": "https://api.github.com/users/octokit-fixture-org/orgs", + "repos_url": "https://api.github.com/users/octokit-fixture-org/repos", + "events_url": "https://api.github.com/users/octokit-fixture-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/octokit-fixture-org/received_events", + "type": "Organization", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/octokit-fixture-org/create-status", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/octokit-fixture-org/create-status", + "forks_url": "https://api.github.com/repos/octokit-fixture-org/create-status/forks", + "keys_url": "https://api.github.com/repos/octokit-fixture-org/create-status/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/octokit-fixture-org/create-status/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/octokit-fixture-org/create-status/teams", + "hooks_url": "https://api.github.com/repos/octokit-fixture-org/create-status/hooks", + "issue_events_url": "https://api.github.com/repos/octokit-fixture-org/create-status/issues/events{/number}", + "events_url": "https://api.github.com/repos/octokit-fixture-org/create-status/events", + "assignees_url": "https://api.github.com/repos/octokit-fixture-org/create-status/assignees{/user}", + "branches_url": "https://api.github.com/repos/octokit-fixture-org/create-status/branches{/branch}", + "tags_url": "https://api.github.com/repos/octokit-fixture-org/create-status/tags", + "blobs_url": "https://api.github.com/repos/octokit-fixture-org/create-status/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/octokit-fixture-org/create-status/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/octokit-fixture-org/create-status/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/octokit-fixture-org/create-status/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/octokit-fixture-org/create-status/statuses/{sha}", + "languages_url": "https://api.github.com/repos/octokit-fixture-org/create-status/languages", + "stargazers_url": "https://api.github.com/repos/octokit-fixture-org/create-status/stargazers", + "contributors_url": "https://api.github.com/repos/octokit-fixture-org/create-status/contributors", + "subscribers_url": "https://api.github.com/repos/octokit-fixture-org/create-status/subscribers", + "subscription_url": "https://api.github.com/repos/octokit-fixture-org/create-status/subscription", + "commits_url": "https://api.github.com/repos/octokit-fixture-org/create-status/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/octokit-fixture-org/create-status/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/octokit-fixture-org/create-status/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/octokit-fixture-org/create-status/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/octokit-fixture-org/create-status/contents/{+path}", + "compare_url": "https://api.github.com/repos/octokit-fixture-org/create-status/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/octokit-fixture-org/create-status/merges", + "archive_url": "https://api.github.com/repos/octokit-fixture-org/create-status/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/octokit-fixture-org/create-status/downloads", + "issues_url": "https://api.github.com/repos/octokit-fixture-org/create-status/issues{/number}", + "pulls_url": "https://api.github.com/repos/octokit-fixture-org/create-status/pulls{/number}", + "milestones_url": "https://api.github.com/repos/octokit-fixture-org/create-status/milestones{/number}", + "notifications_url": "https://api.github.com/repos/octokit-fixture-org/create-status/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/octokit-fixture-org/create-status/labels{/name}", + "releases_url": "https://api.github.com/repos/octokit-fixture-org/create-status/releases{/id}", + "deployments_url": "https://api.github.com/repos/octokit-fixture-org/create-status/deployments" + }, + "commit_url": "https://api.github.com/repos/octokit-fixture-org/create-status/commits/0000000000000000000000000000000000000000", + "url": "https://api.github.com/repos/octokit-fixture-org/create-status/commits/0000000000000000000000000000000000000000/status" + }, + "reqheaders": { + "accept": "application/vnd.github.v3+json", + "authorization": "token 0000000000000000000000000000000000000000", + "host": "api.github.com" + }, + "headers": { + "access-control-allow-origin": "*", + "access-control-expose-headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", + "cache-control": "private, max-age=60, s-maxage=60", + "connection": "close", + "content-length": "5719", + "content-security-policy": "default-src 'none'", + "content-type": "application/json; charset=utf-8", + "date": "Tue, 10 Oct 2017 16:00:00 GMT", + "etag": "\"00000000000000000000000000000000\"", + "status": "200 OK", + "strict-transport-security": "max-age=31536000; includeSubdomains; preload", + "x-accepted-oauth-scopes": "repo, repo:status", + "x-content-type-options": "nosniff", + "x-frame-options": "deny", + "x-github-media-type": "github.v3; format=json", + "x-github-request-id": "0000:00000:0000000:0000000:00000000", + "x-oauth-scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user", + "x-ratelimit-limit": "5000", + "x-ratelimit-remaining": "4999", + "x-ratelimit-reset": "1507651200000", + "x-runtime-rack": "0.000000", + "x-xss-protection": "1; mode=block" + } + } +] diff --git a/scenarios/api.github.com/create-status/raw-fixture.json b/scenarios/api.github.com/create-status/raw-fixture.json new file mode 100644 index 00000000..82673926 --- /dev/null +++ b/scenarios/api.github.com/create-status/raw-fixture.json @@ -0,0 +1,844 @@ +[ + { + "scope": "https://api.github.com:443", + "method": "post", + "path": "/orgs/octokit-fixture-org/repos", + "body": { + "name": "tmp-scenario-create-status-20171002042133224" + }, + "status": 201, + "response": { + "id": 105497709, + "name": "tmp-scenario-create-status-20171002042133224", + "full_name": "octokit-fixture-org/tmp-scenario-create-status-20171002042133224", + "owner": { + "login": "octokit-fixture-org", + "id": 31898100, + "avatar_url": "https://avatars2.githubusercontent.com/u/31898100?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/octokit-fixture-org", + "html_url": "https://github.com/octokit-fixture-org", + "followers_url": "https://api.github.com/users/octokit-fixture-org/followers", + "following_url": "https://api.github.com/users/octokit-fixture-org/following{/other_user}", + "gists_url": "https://api.github.com/users/octokit-fixture-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octokit-fixture-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octokit-fixture-org/subscriptions", + "organizations_url": "https://api.github.com/users/octokit-fixture-org/orgs", + "repos_url": "https://api.github.com/users/octokit-fixture-org/repos", + "events_url": "https://api.github.com/users/octokit-fixture-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/octokit-fixture-org/received_events", + "type": "Organization", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/octokit-fixture-org/tmp-scenario-create-status-20171002042133224", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224", + "forks_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/forks", + "keys_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/teams", + "hooks_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/hooks", + "issue_events_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/issues/events{/number}", + "events_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/events", + "assignees_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/assignees{/user}", + "branches_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/branches{/branch}", + "tags_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/tags", + "blobs_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/statuses/{sha}", + "languages_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/languages", + "stargazers_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/stargazers", + "contributors_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/contributors", + "subscribers_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/subscribers", + "subscription_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/subscription", + "commits_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/contents/{+path}", + "compare_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/merges", + "archive_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/downloads", + "issues_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/issues{/number}", + "pulls_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/pulls{/number}", + "milestones_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/milestones{/number}", + "notifications_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/labels{/name}", + "releases_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/releases{/id}", + "deployments_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/deployments", + "created_at": "2017-10-02T04:21:33Z", + "updated_at": "2017-10-02T04:21:33Z", + "pushed_at": "2017-10-02T04:21:34Z", + "git_url": "git://github.com/octokit-fixture-org/tmp-scenario-create-status-20171002042133224.git", + "ssh_url": "git@github.com:octokit-fixture-org/tmp-scenario-create-status-20171002042133224.git", + "clone_url": "https://github.com/octokit-fixture-org/tmp-scenario-create-status-20171002042133224.git", + "svn_url": "https://github.com/octokit-fixture-org/tmp-scenario-create-status-20171002042133224", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 0, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "organization": { + "login": "octokit-fixture-org", + "id": 31898100, + "avatar_url": "https://avatars2.githubusercontent.com/u/31898100?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/octokit-fixture-org", + "html_url": "https://github.com/octokit-fixture-org", + "followers_url": "https://api.github.com/users/octokit-fixture-org/followers", + "following_url": "https://api.github.com/users/octokit-fixture-org/following{/other_user}", + "gists_url": "https://api.github.com/users/octokit-fixture-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octokit-fixture-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octokit-fixture-org/subscriptions", + "organizations_url": "https://api.github.com/users/octokit-fixture-org/orgs", + "repos_url": "https://api.github.com/users/octokit-fixture-org/repos", + "events_url": "https://api.github.com/users/octokit-fixture-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/octokit-fixture-org/received_events", + "type": "Organization", + "site_admin": false + }, + "network_count": 0, + "subscribers_count": 0 + }, + "rawHeaders": [ + "Date", + "Mon, 02 Oct 2017 04:21:34 GMT", + "Content-Type", + "application/json; charset=utf-8", + "Content-Length", + "7972", + "Connection", + "close", + "Server", + "GitHub.com", + "Status", + "201 Created", + "X-RateLimit-Limit", + "5000", + "X-RateLimit-Remaining", + "4999", + "X-RateLimit-Reset", + "1506921694", + "Cache-Control", + "private, max-age=60, s-maxage=60", + "Vary", + "Accept, Authorization, Cookie, X-GitHub-OTP", + "ETag", + "\"56809b5e3a9761c27079b90bd51ab04f\"", + "X-OAuth-Scopes", + "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user", + "X-Accepted-OAuth-Scopes", + "public_repo, repo", + "Location", + "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224", + "X-GitHub-Media-Type", + "github.v3; format=json", + "Access-Control-Expose-Headers", + "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", + "Access-Control-Allow-Origin", + "*", + "Content-Security-Policy", + "default-src 'none'", + "Strict-Transport-Security", + "max-age=31536000; includeSubdomains; preload", + "X-Content-Type-Options", + "nosniff", + "X-Frame-Options", + "deny", + "X-XSS-Protection", + "1; mode=block", + "X-Runtime-rack", + "0.616030", + "Vary", + "Accept-Encoding", + "X-GitHub-Request-Id", + "E311:3D1C:355A4FA:4612E08:59D1BECD" + ], + "reqheaders": { + "accept": "application/vnd.github.v3+json", + "content-type": "application/json;charset=utf-8", + "authorization": "token 0000000000000000000000000000000000000000", + "x-octokit-fixture-ignore": "true", + "content-length": 55, + "host": "api.github.com" + } + }, + { + "scope": "https://api.github.com:443", + "method": "put", + "path": "/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/contents/README.md", + "body": { + "message": "initial commit", + "content": "IyBjcmVhdGUtc3RhdHVz" + }, + "status": 201, + "response": { + "content": { + "name": "README.md", + "path": "README.md", + "sha": "4919c3a86330d02992776d8ac2a4c4d1c1a2a8ce", + "size": 15, + "url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/contents/README.md?ref=master", + "html_url": "https://github.com/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/blob/master/README.md", + "git_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/git/blobs/4919c3a86330d02992776d8ac2a4c4d1c1a2a8ce", + "download_url": "https://raw.githubusercontent.com/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/master/README.md", + "type": "file", + "_links": { + "self": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/contents/README.md?ref=master", + "git": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/git/blobs/4919c3a86330d02992776d8ac2a4c4d1c1a2a8ce", + "html": "https://github.com/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/blob/master/README.md" + } + }, + "commit": { + "sha": "35b6551f14ba995e3f6ce234ecc8fb9441dee42c", + "url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/git/commits/35b6551f14ba995e3f6ce234ecc8fb9441dee42c", + "html_url": "https://github.com/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/commit/35b6551f14ba995e3f6ce234ecc8fb9441dee42c", + "author": { + "name": "octokit-fixture-user-a", + "email": "31898046+octokit-fixture-user-a@users.noreply.github.com", + "date": "2017-10-02T04:21:34Z" + }, + "committer": { + "name": "octokit-fixture-user-a", + "email": "31898046+octokit-fixture-user-a@users.noreply.github.com", + "date": "2017-10-02T04:21:34Z" + }, + "tree": { + "sha": "1b5efd24a0ea8796f346874fc487e80331ae5b4a", + "url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/git/trees/1b5efd24a0ea8796f346874fc487e80331ae5b4a" + }, + "message": "initial commit", + "parents": [] + } + }, + "rawHeaders": [ + "Date", + "Mon, 02 Oct 2017 04:21:35 GMT", + "Content-Type", + "application/json; charset=utf-8", + "Content-Length", + "1971", + "Connection", + "close", + "Server", + "GitHub.com", + "Status", + "201 Created", + "X-RateLimit-Limit", + "5000", + "X-RateLimit-Remaining", + "4998", + "X-RateLimit-Reset", + "1506921694", + "Cache-Control", + "private, max-age=60, s-maxage=60", + "Vary", + "Accept, Authorization, Cookie, X-GitHub-OTP", + "ETag", + "\"a33271af70e3ba384089982b3aac84a0\"", + "X-OAuth-Scopes", + "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user", + "X-Accepted-OAuth-Scopes", + "", + "X-GitHub-Media-Type", + "github.v3; format=json", + "Access-Control-Expose-Headers", + "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", + "Access-Control-Allow-Origin", + "*", + "Content-Security-Policy", + "default-src 'none'", + "Strict-Transport-Security", + "max-age=31536000; includeSubdomains; preload", + "X-Content-Type-Options", + "nosniff", + "X-Frame-Options", + "deny", + "X-XSS-Protection", + "1; mode=block", + "X-Runtime-rack", + "0.730830", + "Vary", + "Accept-Encoding", + "X-GitHub-Request-Id", + "E314:3D1D:5E81912:7C7E940:59D1BECE" + ], + "reqheaders": { + "accept": "application/vnd.github.v3+json", + "content-type": "application/json;charset=utf-8", + "authorization": "token 0000000000000000000000000000000000000000", + "x-octokit-fixture-ignore": "true", + "content-length": 61, + "host": "api.github.com" + } + }, + { + "scope": "https://api.github.com:443", + "method": "post", + "path": "/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/statuses/35b6551f14ba995e3f6ce234ecc8fb9441dee42c", + "body": { + "state": "failure", + "target_url": "https://example.com", + "description": "create-status failure test", + "context": "example/1" + }, + "status": 201, + "response": { + "url": "https://api.github.com/repos/octokit-fixture-org/create-status/statuses/0000000000000000000000000000000000000000", + "id": 1595337065, + "state": "failure", + "description": "create-status failure test", + "target_url": "https://example.com", + "context": "example/1", + "created_at": "2017-10-10T16:00:00Z", + "updated_at": "2017-10-10T16:00:00Z", + "creator": { + "login": "octokit-fixture-user-a", + "id": 1, + "avatar_url": "https://avatars0.githubusercontent.com/u/1?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/octokit-fixture-user-a", + "html_url": "https://github.com/octokit-fixture-user-a", + "followers_url": "https://api.github.com/users/octokit-fixture-user-a/followers", + "following_url": "https://api.github.com/users/octokit-fixture-user-a/following{/other_user}", + "gists_url": "https://api.github.com/users/octokit-fixture-user-a/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octokit-fixture-user-a/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octokit-fixture-user-a/subscriptions", + "organizations_url": "https://api.github.com/users/octokit-fixture-user-a/orgs", + "repos_url": "https://api.github.com/users/octokit-fixture-user-a/repos", + "events_url": "https://api.github.com/users/octokit-fixture-user-a/events{/privacy}", + "received_events_url": "https://api.github.com/users/octokit-fixture-user-a/received_events", + "type": "User", + "site_admin": false + } + }, + "rawHeaders": [ + "Date", + "Mon, 02 Oct 2017 04:21:36 GMT", + "Content-Type", + "application/json; charset=utf-8", + "Content-Length", + "1413", + "Connection", + "close", + "Server", + "GitHub.com", + "Status", + "201 Created", + "X-RateLimit-Limit", + "5000", + "X-RateLimit-Remaining", + "4997", + "X-RateLimit-Reset", + "1506921694", + "Cache-Control", + "private, max-age=60, s-maxage=60", + "Vary", + "Accept, Authorization, Cookie, X-GitHub-OTP", + "ETag", + "\"3a75b693405f03f94ffebf8b0889892d\"", + "X-OAuth-Scopes", + "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user", + "X-Accepted-OAuth-Scopes", + "", + "Location", + "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/statuses/35b6551f14ba995e3f6ce234ecc8fb9441dee42c", + "X-GitHub-Media-Type", + "github.v3; format=json", + "Access-Control-Expose-Headers", + "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", + "Access-Control-Allow-Origin", + "*", + "Content-Security-Policy", + "default-src 'none'", + "Strict-Transport-Security", + "max-age=31536000; includeSubdomains; preload", + "X-Content-Type-Options", + "nosniff", + "X-Frame-Options", + "deny", + "X-XSS-Protection", + "1; mode=block", + "X-Runtime-rack", + "0.131626", + "Vary", + "Accept-Encoding", + "X-GitHub-Request-Id", + "E319:3D1C:355A542:4612E81:59D1BECF" + ], + "reqheaders": { + "accept": "application/vnd.github.v3+json", + "content-type": "application/json; charset=utf-8", + "authorization": "token 0000000000000000000000000000000000000000", + "content-length": 119, + "host": "api.github.com" + } + }, + { + "scope": "https://api.github.com:443", + "method": "post", + "path": "/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/statuses/35b6551f14ba995e3f6ce234ecc8fb9441dee42c", + "body": { + "state": "success", + "target_url": "https://example.com", + "description": "create-status success test", + "context": "example/2" + }, + "status": 201, + "response": { + "url": "https://api.github.com/repos/octokit-fixture-org/create-status/statuses/0000000000000000000000000000000000000000", + "id": 1595337071, + "state": "success", + "description": "create-status success test", + "target_url": "https://example.com", + "context": "example/2", + "created_at": "2017-10-10T16:00:00Z", + "updated_at": "2017-10-10T16:00:00Z", + "creator": { + "login": "octokit-fixture-user-a", + "id": 1, + "avatar_url": "https://avatars0.githubusercontent.com/u/1?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/octokit-fixture-user-a", + "html_url": "https://github.com/octokit-fixture-user-a", + "followers_url": "https://api.github.com/users/octokit-fixture-user-a/followers", + "following_url": "https://api.github.com/users/octokit-fixture-user-a/following{/other_user}", + "gists_url": "https://api.github.com/users/octokit-fixture-user-a/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octokit-fixture-user-a/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octokit-fixture-user-a/subscriptions", + "organizations_url": "https://api.github.com/users/octokit-fixture-user-a/orgs", + "repos_url": "https://api.github.com/users/octokit-fixture-user-a/repos", + "events_url": "https://api.github.com/users/octokit-fixture-user-a/events{/privacy}", + "received_events_url": "https://api.github.com/users/octokit-fixture-user-a/received_events", + "type": "User", + "site_admin": false + } + }, + "rawHeaders": [ + "Date", + "Mon, 02 Oct 2017 04:21:36 GMT", + "Content-Type", + "application/json; charset=utf-8", + "Content-Length", + "1413", + "Connection", + "close", + "Server", + "GitHub.com", + "Status", + "201 Created", + "X-RateLimit-Limit", + "5000", + "X-RateLimit-Remaining", + "4996", + "X-RateLimit-Reset", + "1506921694", + "Cache-Control", + "private, max-age=60, s-maxage=60", + "Vary", + "Accept, Authorization, Cookie, X-GitHub-OTP", + "ETag", + "\"c2aee83850efbdec77c478511692d747\"", + "X-OAuth-Scopes", + "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user", + "X-Accepted-OAuth-Scopes", + "", + "Location", + "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/statuses/35b6551f14ba995e3f6ce234ecc8fb9441dee42c", + "X-GitHub-Media-Type", + "github.v3; format=json", + "Access-Control-Expose-Headers", + "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", + "Access-Control-Allow-Origin", + "*", + "Content-Security-Policy", + "default-src 'none'", + "Strict-Transport-Security", + "max-age=31536000; includeSubdomains; preload", + "X-Content-Type-Options", + "nosniff", + "X-Frame-Options", + "deny", + "X-XSS-Protection", + "1; mode=block", + "X-Runtime-rack", + "0.058498", + "Vary", + "Accept-Encoding", + "X-GitHub-Request-Id", + "E31E:3D1D:5E8197E:7C7E9E0:59D1BED0" + ], + "reqheaders": { + "accept": "application/vnd.github.v3+json", + "content-type": "application/json; charset=utf-8", + "authorization": "token 0000000000000000000000000000000000000000", + "content-length": 119, + "host": "api.github.com" + } + }, + { + "scope": "https://api.github.com:443", + "method": "get", + "path": "/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/commits/35b6551f14ba995e3f6ce234ecc8fb9441dee42c/statuses", + "body": "", + "status": 200, + "response": [ + { + "url": "https://api.github.com/repos/octokit-fixture-org/create-status/statuses/0000000000000000000000000000000000000000", + "id": 1595337071, + "state": "success", + "description": "create-status success test", + "target_url": "https://example.com", + "context": "example/2", + "created_at": "2017-10-10T16:00:00Z", + "updated_at": "2017-10-10T16:00:00Z", + "creator": { + "login": "octokit-fixture-user-a", + "id": 1, + "avatar_url": "https://avatars0.githubusercontent.com/u/1?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/octokit-fixture-user-a", + "html_url": "https://github.com/octokit-fixture-user-a", + "followers_url": "https://api.github.com/users/octokit-fixture-user-a/followers", + "following_url": "https://api.github.com/users/octokit-fixture-user-a/following{/other_user}", + "gists_url": "https://api.github.com/users/octokit-fixture-user-a/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octokit-fixture-user-a/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octokit-fixture-user-a/subscriptions", + "organizations_url": "https://api.github.com/users/octokit-fixture-user-a/orgs", + "repos_url": "https://api.github.com/users/octokit-fixture-user-a/repos", + "events_url": "https://api.github.com/users/octokit-fixture-user-a/events{/privacy}", + "received_events_url": "https://api.github.com/users/octokit-fixture-user-a/received_events", + "type": "User", + "site_admin": false + } + }, + { + "url": "https://api.github.com/repos/octokit-fixture-org/create-status/statuses/0000000000000000000000000000000000000000", + "id": 1595337065, + "state": "failure", + "description": "create-status failure test", + "target_url": "https://example.com", + "context": "example/1", + "created_at": "2017-10-10T16:00:00Z", + "updated_at": "2017-10-10T16:00:00Z", + "creator": { + "login": "octokit-fixture-user-a", + "id": 1, + "avatar_url": "https://avatars0.githubusercontent.com/u/1?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/octokit-fixture-user-a", + "html_url": "https://github.com/octokit-fixture-user-a", + "followers_url": "https://api.github.com/users/octokit-fixture-user-a/followers", + "following_url": "https://api.github.com/users/octokit-fixture-user-a/following{/other_user}", + "gists_url": "https://api.github.com/users/octokit-fixture-user-a/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octokit-fixture-user-a/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octokit-fixture-user-a/subscriptions", + "organizations_url": "https://api.github.com/users/octokit-fixture-user-a/orgs", + "repos_url": "https://api.github.com/users/octokit-fixture-user-a/repos", + "events_url": "https://api.github.com/users/octokit-fixture-user-a/events{/privacy}", + "received_events_url": "https://api.github.com/users/octokit-fixture-user-a/received_events", + "type": "User", + "site_admin": false + } + } + ], + "rawHeaders": [ + "Date", + "Mon, 02 Oct 2017 04:21:36 GMT", + "Content-Type", + "application/json; charset=utf-8", + "Content-Length", + "2829", + "Connection", + "close", + "Server", + "GitHub.com", + "Status", + "200 OK", + "X-RateLimit-Limit", + "5000", + "X-RateLimit-Remaining", + "4995", + "X-RateLimit-Reset", + "1506921694", + "Cache-Control", + "private, max-age=60, s-maxage=60", + "Vary", + "Accept, Authorization, Cookie, X-GitHub-OTP", + "ETag", + "\"2d5ad4e947b684e37d20b29718706de7\"", + "X-OAuth-Scopes", + "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user", + "X-Accepted-OAuth-Scopes", + "repo, repo:status", + "X-GitHub-Media-Type", + "github.v3; format=json", + "Access-Control-Expose-Headers", + "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", + "Access-Control-Allow-Origin", + "*", + "Content-Security-Policy", + "default-src 'none'", + "Strict-Transport-Security", + "max-age=31536000; includeSubdomains; preload", + "X-Content-Type-Options", + "nosniff", + "X-Frame-Options", + "deny", + "X-XSS-Protection", + "1; mode=block", + "X-Runtime-rack", + "0.147619", + "Vary", + "Accept-Encoding", + "X-GitHub-Request-Id", + "E321:3D1D:5E8198B:7C7E9F0:59D1BED0" + ], + "reqheaders": { + "accept": "application/vnd.github.v3+json", + "authorization": "token 0000000000000000000000000000000000000000", + "host": "api.github.com" + } + }, + { + "scope": "https://api.github.com:443", + "method": "get", + "path": "/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/commits/35b6551f14ba995e3f6ce234ecc8fb9441dee42c/status", + "body": "", + "status": 200, + "response": { + "state": "failure", + "statuses": [ + { + "url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/statuses/35b6551f14ba995e3f6ce234ecc8fb9441dee42c", + "id": 1595337065, + "state": "failure", + "description": "create-status failure test", + "target_url": "https://example.com", + "context": "example/1", + "created_at": "2017-10-02T04:21:36Z", + "updated_at": "2017-10-02T04:21:36Z" + }, + { + "url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/statuses/35b6551f14ba995e3f6ce234ecc8fb9441dee42c", + "id": 1595337071, + "state": "success", + "description": "create-status success test", + "target_url": "https://example.com", + "context": "example/2", + "created_at": "2017-10-02T04:21:36Z", + "updated_at": "2017-10-02T04:21:36Z" + } + ], + "sha": "35b6551f14ba995e3f6ce234ecc8fb9441dee42c", + "total_count": 2, + "repository": { + "id": 105497709, + "name": "tmp-scenario-create-status-20171002042133224", + "full_name": "octokit-fixture-org/tmp-scenario-create-status-20171002042133224", + "owner": { + "login": "octokit-fixture-org", + "id": 31898100, + "avatar_url": "https://avatars2.githubusercontent.com/u/31898100?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/octokit-fixture-org", + "html_url": "https://github.com/octokit-fixture-org", + "followers_url": "https://api.github.com/users/octokit-fixture-org/followers", + "following_url": "https://api.github.com/users/octokit-fixture-org/following{/other_user}", + "gists_url": "https://api.github.com/users/octokit-fixture-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octokit-fixture-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octokit-fixture-org/subscriptions", + "organizations_url": "https://api.github.com/users/octokit-fixture-org/orgs", + "repos_url": "https://api.github.com/users/octokit-fixture-org/repos", + "events_url": "https://api.github.com/users/octokit-fixture-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/octokit-fixture-org/received_events", + "type": "Organization", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/octokit-fixture-org/tmp-scenario-create-status-20171002042133224", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224", + "forks_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/forks", + "keys_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/teams", + "hooks_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/hooks", + "issue_events_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/issues/events{/number}", + "events_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/events", + "assignees_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/assignees{/user}", + "branches_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/branches{/branch}", + "tags_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/tags", + "blobs_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/statuses/{sha}", + "languages_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/languages", + "stargazers_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/stargazers", + "contributors_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/contributors", + "subscribers_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/subscribers", + "subscription_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/subscription", + "commits_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/contents/{+path}", + "compare_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/merges", + "archive_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/downloads", + "issues_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/issues{/number}", + "pulls_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/pulls{/number}", + "milestones_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/milestones{/number}", + "notifications_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/labels{/name}", + "releases_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/releases{/id}", + "deployments_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/deployments" + }, + "commit_url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/commits/35b6551f14ba995e3f6ce234ecc8fb9441dee42c", + "url": "https://api.github.com/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224/commits/35b6551f14ba995e3f6ce234ecc8fb9441dee42c/status" + }, + "rawHeaders": [ + "Date", + "Mon, 02 Oct 2017 04:21:37 GMT", + "Content-Type", + "application/json; charset=utf-8", + "Content-Length", + "7123", + "Connection", + "close", + "Server", + "GitHub.com", + "Status", + "200 OK", + "X-RateLimit-Limit", + "5000", + "X-RateLimit-Remaining", + "4994", + "X-RateLimit-Reset", + "1506921694", + "Cache-Control", + "private, max-age=60, s-maxage=60", + "Vary", + "Accept, Authorization, Cookie, X-GitHub-OTP", + "ETag", + "\"d4f728266696c30e66bef413b9308fab\"", + "X-OAuth-Scopes", + "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user", + "X-Accepted-OAuth-Scopes", + "repo, repo:status", + "X-GitHub-Media-Type", + "github.v3; format=json", + "Access-Control-Expose-Headers", + "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", + "Access-Control-Allow-Origin", + "*", + "Content-Security-Policy", + "default-src 'none'", + "Strict-Transport-Security", + "max-age=31536000; includeSubdomains; preload", + "X-Content-Type-Options", + "nosniff", + "X-Frame-Options", + "deny", + "X-XSS-Protection", + "1; mode=block", + "X-Runtime-rack", + "0.033214", + "Vary", + "Accept-Encoding", + "X-GitHub-Request-Id", + "E324:3D1C:355A563:4612EAE:59D1BED0" + ], + "reqheaders": { + "accept": "application/vnd.github.v3+json", + "authorization": "token 0000000000000000000000000000000000000000", + "host": "api.github.com" + } + }, + { + "scope": "https://api.github.com:443", + "method": "delete", + "path": "/repos/octokit-fixture-org/tmp-scenario-create-status-20171002042133224", + "body": "", + "status": 204, + "response": "", + "rawHeaders": [ + "Date", + "Mon, 02 Oct 2017 04:21:37 GMT", + "Content-Type", + "application/octet-stream", + "Connection", + "close", + "Server", + "GitHub.com", + "Status", + "204 No Content", + "X-RateLimit-Limit", + "5000", + "X-RateLimit-Remaining", + "4993", + "X-RateLimit-Reset", + "1506921694", + "X-OAuth-Scopes", + "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user", + "X-Accepted-OAuth-Scopes", + "delete_repo", + "X-GitHub-Media-Type", + "github.v3; format=json", + "Access-Control-Expose-Headers", + "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", + "Access-Control-Allow-Origin", + "*", + "Content-Security-Policy", + "default-src 'none'", + "Strict-Transport-Security", + "max-age=31536000; includeSubdomains; preload", + "X-Content-Type-Options", + "nosniff", + "X-Frame-Options", + "deny", + "X-XSS-Protection", + "1; mode=block", + "X-Runtime-rack", + "0.074289", + "Vary", + "Accept-Encoding", + "X-GitHub-Request-Id", + "E325:3D1D:5E819B6:7C7EA2E:59D1BED1" + ], + "reqheaders": { + "accept": "application/vnd.github.v3+json", + "authorization": "token 0000000000000000000000000000000000000000", + "x-octokit-fixture-ignore": "true", + "host": "api.github.com" + } + } +] \ No newline at end of file diff --git a/scenarios/api.github.com/create-status/record.js b/scenarios/api.github.com/create-status/record.js new file mode 100644 index 00000000..81460609 --- /dev/null +++ b/scenarios/api.github.com/create-status/record.js @@ -0,0 +1,93 @@ +module.exports = createStatus + +const env = require('../../../lib/env') +const getTemporaryRepository = require('../../../lib/temporary-repository') + +async function createStatus (state) { + let error + // create a temporary repository + const temporaryRepository = getTemporaryRepository({ + request: state.request, + token: env.FIXTURES_USER_A_TOKEN_FULL_ACCESS, + org: 'octokit-fixture-org', + name: 'create-status' + }) + + await temporaryRepository.create() + + try { + // https://developer.github.com/v3/repos/contents/#create-a-file + // (this request gets ignored, we need an existing commit to set status on) + const {data: {commit: {sha}}} = await state.request({ + method: 'put', + url: `/repos/octokit-fixture-org/${temporaryRepository.name}/contents/README.md`, + headers: { + Accept: 'application/vnd.github.v3+json', + Authorization: `token ${env.FIXTURES_USER_A_TOKEN_FULL_ACCESS}`, + 'X-Octokit-Fixture-Ignore': 'true' + }, + data: { + message: 'initial commit', + content: Buffer.from('# create-status').toString('base64') + } + }) + + // https://developer.github.com/v3/repos/statuses/#create-a-status + await state.request({ + method: 'post', + url: `/repos/octokit-fixture-org/${temporaryRepository.name}/statuses/${sha}`, + headers: { + Accept: 'application/vnd.github.v3+json', + Authorization: `token ${env.FIXTURES_USER_A_TOKEN_FULL_ACCESS}` + }, + data: { + state: 'failure', + target_url: 'https://example.com', + description: 'create-status failure test', + context: 'example/1' + } + }) + await state.request({ + method: 'post', + url: `/repos/octokit-fixture-org/${temporaryRepository.name}/statuses/${sha}`, + headers: { + Accept: 'application/vnd.github.v3+json', + Authorization: `token ${env.FIXTURES_USER_A_TOKEN_FULL_ACCESS}` + }, + data: { + state: 'success', + target_url: 'https://example.com', + description: 'create-status success test', + context: 'example/2' + } + }) + + // https://developer.github.com/v3/repos/statuses/#list-statuses-for-a-specific-ref + await state.request({ + method: 'get', + url: `/repos/octokit-fixture-org/${temporaryRepository.name}/commits/${sha}/statuses`, + headers: { + Accept: 'application/vnd.github.v3+json', + Authorization: `token ${env.FIXTURES_USER_A_TOKEN_FULL_ACCESS}` + } + }) + + // https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref + await state.request({ + method: 'get', + url: `/repos/octokit-fixture-org/${temporaryRepository.name}/commits/${sha}/status`, + headers: { + Accept: 'application/vnd.github.v3+json', + Authorization: `token ${env.FIXTURES_USER_A_TOKEN_FULL_ACCESS}` + } + }) + } catch (_error) { + error = _error + } + + await temporaryRepository.delete() + + if (error) { + return Promise.reject(error) + } +} diff --git a/scenarios/api.github.com/create-status/test.js b/scenarios/api.github.com/create-status/test.js new file mode 100644 index 00000000..98d1bd5e --- /dev/null +++ b/scenarios/api.github.com/create-status/test.js @@ -0,0 +1,66 @@ +const axios = require('axios') +const {test} = require('tap') + +const fixtures = require('../../..') + +test('Create status', async (t) => { + const mock = fixtures.mock('api.github.com/create-status') + + // create failure status + await axios({ + method: 'post', + url: 'https://api.github.com/repos/octokit-fixture-org/create-status/statuses/0000000000000000000000000000000000000000', + headers: { + Accept: 'application/vnd.github.v3+json', + Authorization: `token 0000000000000000000000000000000000000000`, + 'Content-Type': 'application/json; charset=utf-8' + }, + data: { + state: 'failure', + target_url: 'https://example.com', + description: 'create-status failure test', + context: 'example/1' + } + }).catch(mock.explain) + + // create success status + await axios({ + method: 'post', + url: 'https://api.github.com/repos/octokit-fixture-org/create-status/statuses/0000000000000000000000000000000000000000', + headers: { + Accept: 'application/vnd.github.v3+json', + Authorization: `token 0000000000000000000000000000000000000000`, + 'Content-Type': 'application/json; charset=utf-8' + }, + data: { + state: 'success', + target_url: 'https://example.com', + description: 'create-status success test', + context: 'example/2' + } + }).catch(mock.explain) + + // get all statuses + await axios({ + method: 'get', + url: 'https://api.github.com/repos/octokit-fixture-org/create-status/commits/0000000000000000000000000000000000000000/statuses', + headers: { + Accept: 'application/vnd.github.v3+json', + Authorization: `token 0000000000000000000000000000000000000000` + } + }) + + // get combined status + const {data} = await axios({ + method: 'get', + url: 'https://api.github.com/repos/octokit-fixture-org/create-status/commits/0000000000000000000000000000000000000000/status', + headers: { + Accept: 'application/vnd.github.v3+json', + Authorization: `token 0000000000000000000000000000000000000000` + } + }) + + t.is(data.state, 'failure', 'combined state is failure') + t.doesNotThrow(mock.done.bind(mock), 'satisfies all mocks') + t.end() +})