{"action":"opened","number":393,"pull_request":{"url":"https://api.github.com/repos/alphagov/stagecraft/pulls/393","id":40359101,"html_url":"https://github.com/alphagov/stagecraft/pull/393","diff_url":"https://github.com/alphagov/stagecraft/pull/393.diff","patch_url":"https://github.com/alphagov/stagecraft/pull/393.patch","issue_url":"https://api.github.com/repos/alphagov/stagecraft/issues/393","number":393,"state":"open","locked":false,"title":"Collectors models and tests","user":{"login":"tombooth","id":108382,"avatar_url":"https://avatars.githubusercontent.com/u/108382?v=3","gravatar_id":"","url":"https://api.github.com/users/tombooth","html_url":"https://github.com/tombooth","followers_url":"https://api.github.com/users/tombooth/followers","following_url":"https://api.github.com/users/tombooth/following{/other_user}","gists_url":"https://api.github.com/users/tombooth/gists{/gist_id}","starred_url":"https://api.github.com/users/tombooth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tombooth/subscriptions","organizations_url":"https://api.github.com/users/tombooth/orgs","repos_url":"https://api.github.com/users/tombooth/repos","events_url":"https://api.github.com/users/tombooth/events{/privacy}","received_events_url":"https://api.github.com/users/tombooth/received_events","type":"User","site_admin":false},"body":"We have built the underlying data model for collectors in the\r\nPerformance Platform.\r\n\r\nhttps://drive.google.com/open?id=0B4BcZ31U-tWQVjZmQVd4UUNXT0t2bXQyQk9pR0RGWUpDUGF3\r\n\r\nThis uses Fernet to encrypt the credentials we store for 3rd party\r\nservices. This is to protect data that has a reasonable impact potential\r\nif leaked when the data is at rest. Fernet uses AES and HMAC under the\r\nhood and should provide adequate protection for our data.\r\n\r\nAlong side all of the schema tests for the options/query/credentials we\r\nenforce some ownership constraints and some provider constraints. We\r\nwant to be sure that a collector uses a type and data source for the\r\nsame provider, so we don't end up with a GA collector talking to a Piwik\r\nsource. We also want to be sure that the user interacting with the\r\nCollector is associated with both the data set and the data source, so\r\nthey don't end up using someones random data source and pulling their\r\njuicy data.\r\n\r\nBecause of the constraint on providers needing to be the same between\r\nthe type and data source, when creating a collector through a factory we\r\nhave to pull the provider from the type into the data source. If we\r\ndidn't do this then it would create two different providers for the type\r\nand the data source\r\n\r\nWe are relying on a git tag of django-field-cryptography as this was not\r\nreleased into pypi correctly and we need some of the features - ie to de-encrypt\r\nthe data returned from the database.  We are using a specific version of\r\ncryptography in the requirements:\r\n\r\nhttps://github.com/pyca/cryptography/blob/0.9.3/src/cryptography/fernet.py#L84\r\n\r\nThis change correctly identifies invalid tokens, whereas 0.6.* would fail\r\nwhen data was falsy.","created_at":"2015-07-20T14:43:29Z","updated_at":"2015-07-20T14:43:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/alphagov/stagecraft/pulls/393/commits","review_comments_url":"https://api.github.com/repos/alphagov/stagecraft/pulls/393/comments","review_comment_url":"https://api.github.com/repos/alphagov/stagecraft/pulls/comments{/number}","comments_url":"https://api.github.com/repos/alphagov/stagecraft/issues/393/comments","statuses_url":"https://api.github.com/repos/alphagov/stagecraft/statuses/e7a09048e359484ce4d4c64e64fe95c2cf50a040","head":{"label":"alphagov:collector-models","ref":"collector-models","sha":"e7a09048e359484ce4d4c64e64fe95c2cf50a040","user":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"repo":{"id":13295877,"name":"stagecraft","full_name":"alphagov/stagecraft","owner":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alphagov/stagecraft","description":"A configuration service for the Performance Platform","fork":false,"url":"https://api.github.com/repos/alphagov/stagecraft","forks_url":"https://api.github.com/repos/alphagov/stagecraft/forks","keys_url":"https://api.github.com/repos/alphagov/stagecraft/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/stagecraft/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/stagecraft/teams","hooks_url":"https://api.github.com/repos/alphagov/stagecraft/hooks","issue_events_url":"https://api.github.com/repos/alphagov/stagecraft/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/stagecraft/events","assignees_url":"https://api.github.com/repos/alphagov/stagecraft/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/stagecraft/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/stagecraft/tags","blobs_url":"https://api.github.com/repos/alphagov/stagecraft/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/stagecraft/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/stagecraft/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/stagecraft/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/stagecraft/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/stagecraft/languages","stargazers_url":"https://api.github.com/repos/alphagov/stagecraft/stargazers","contributors_url":"https://api.github.com/repos/alphagov/stagecraft/contributors","subscribers_url":"https://api.github.com/repos/alphagov/stagecraft/subscribers","subscription_url":"https://api.github.com/repos/alphagov/stagecraft/subscription","commits_url":"https://api.github.com/repos/alphagov/stagecraft/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/stagecraft/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/stagecraft/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/stagecraft/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphagov/stagecraft/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/stagecraft/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/stagecraft/merges","archive_url":"https://api.github.com/repos/alphagov/stagecraft/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/stagecraft/downloads","issues_url":"https://api.github.com/repos/alphagov/stagecraft/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/stagecraft/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/stagecraft/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/stagecraft/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/stagecraft/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/stagecraft/releases{/id}","created_at":"2013-10-03T11:08:32Z","updated_at":"2015-05-05T13:06:09Z","pushed_at":"2015-07-20T14:43:29Z","git_url":"git://github.com/alphagov/stagecraft.git","ssh_url":"git@github.com:alphagov/stagecraft.git","clone_url":"https://github.com/alphagov/stagecraft.git","svn_url":"https://github.com/alphagov/stagecraft","homepage":"","size":7610,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":4,"forks":4,"open_issues":4,"watchers":2,"default_branch":"master"}},"base":{"label":"alphagov:master","ref":"master","sha":"936a6a9dce9d14fb82fcc4e4c445d36998808023","user":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"repo":{"id":13295877,"name":"stagecraft","full_name":"alphagov/stagecraft","owner":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alphagov/stagecraft","description":"A configuration service for the Performance Platform","fork":false,"url":"https://api.github.com/repos/alphagov/stagecraft","forks_url":"https://api.github.com/repos/alphagov/stagecraft/forks","keys_url":"https://api.github.com/repos/alphagov/stagecraft/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/stagecraft/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/stagecraft/teams","hooks_url":"https://api.github.com/repos/alphagov/stagecraft/hooks","issue_events_url":"https://api.github.com/repos/alphagov/stagecraft/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/stagecraft/events","assignees_url":"https://api.github.com/repos/alphagov/stagecraft/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/stagecraft/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/stagecraft/tags","blobs_url":"https://api.github.com/repos/alphagov/stagecraft/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/stagecraft/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/stagecraft/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/stagecraft/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/stagecraft/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/stagecraft/languages","stargazers_url":"https://api.github.com/repos/alphagov/stagecraft/stargazers","contributors_url":"https://api.github.com/repos/alphagov/stagecraft/contributors","subscribers_url":"https://api.github.com/repos/alphagov/stagecraft/subscribers","subscription_url":"https://api.github.com/repos/alphagov/stagecraft/subscription","commits_url":"https://api.github.com/repos/alphagov/stagecraft/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/stagecraft/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/stagecraft/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/stagecraft/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphagov/stagecraft/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/stagecraft/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/stagecraft/merges","archive_url":"https://api.github.com/repos/alphagov/stagecraft/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/stagecraft/downloads","issues_url":"https://api.github.com/repos/alphagov/stagecraft/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/stagecraft/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/stagecraft/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/stagecraft/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/stagecraft/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/stagecraft/releases{/id}","created_at":"2013-10-03T11:08:32Z","updated_at":"2015-05-05T13:06:09Z","pushed_at":"2015-07-20T14:43:29Z","git_url":"git://github.com/alphagov/stagecraft.git","ssh_url":"git@github.com:alphagov/stagecraft.git","clone_url":"https://github.com/alphagov/stagecraft.git","svn_url":"https://github.com/alphagov/stagecraft","homepage":"","size":7610,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":4,"forks":4,"open_issues":4,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/alphagov/stagecraft/pulls/393"},"html":{"href":"https://github.com/alphagov/stagecraft/pull/393"},"issue":{"href":"https://api.github.com/repos/alphagov/stagecraft/issues/393"},"comments":{"href":"https://api.github.com/repos/alphagov/stagecraft/issues/393/comments"},"review_comments":{"href":"https://api.github.com/repos/alphagov/stagecraft/pulls/393/comments"},"review_comment":{"href":"https://api.github.com/repos/alphagov/stagecraft/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/alphagov/stagecraft/pulls/393/commits"},"statuses":{"href":"https://api.github.com/repos/alphagov/stagecraft/statuses/e7a09048e359484ce4d4c64e64fe95c2cf50a040"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":473,"deletions":3,"changed_files":12}}