git_hub_bub 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/git_hub_bub.gemspec +1 -0
- data/lib/git_hub_bub.rb +1 -1
- data/lib/git_hub_bub/request.rb +7 -2
- data/lib/git_hub_bub/version.rb +1 -1
- data/test/fixtures/vcr_cassettes/PATCH_user.yml +1 -1
- data/test/git_hub_bub/valid_token_test.rb +21 -0
- data/test/test_helper.rb +11 -1
- metadata +17 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d31891a90b22df2a157da85e2158361b8205e2b
|
4
|
+
data.tar.gz: 9520dc67097429c0d153f0157431330a1385a9d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f64c2a1f22a8fb729643473d982218a00d76f35b5f6955ed564f3951048b80d984b22148d01d2140047bd63d1ed8d02e409f1e7c9f4363d4ea380a850e22371
|
7
|
+
data.tar.gz: 5998e107923099f197273716ef8fbe106f00782793e4a45ef80a78f857026a22296f4b1edfe7282a4772f8833fd3bae6ca816aeea7d50b2a1d5f5aadbc0360fa
|
data/git_hub_bub.gemspec
CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |gem|
|
|
20
20
|
|
21
21
|
gem.add_dependency "rrrretry"
|
22
22
|
gem.add_dependency "excon"
|
23
|
+
gem.add_development_dependency "mocha"
|
23
24
|
gem.add_development_dependency "rake"
|
24
25
|
gem.add_development_dependency "vcr", '~> 2.5.0'
|
25
26
|
gem.add_development_dependency "webmock", '~> 1.11.0'
|
data/lib/git_hub_bub.rb
CHANGED
@@ -13,7 +13,7 @@ module GitHubBub
|
|
13
13
|
class << self
|
14
14
|
|
15
15
|
def valid_token?(token)
|
16
|
-
Request.get("https://#{ENV['GITHUB_APP_ID']}:#{ENV['GITHUB_APP_SECRET']}@api.github.com/applications/#{ENV['GITHUB_APP_ID']}/tokens/#{token}", {
|
16
|
+
Request.get("https://#{ENV['GITHUB_APP_ID']}:#{ENV['GITHUB_APP_SECRET']}@api.github.com/applications/#{ENV['GITHUB_APP_ID']}/tokens/#{token}", {}, {skip_token: true})
|
17
17
|
true
|
18
18
|
rescue GitHubBub::RequestError
|
19
19
|
false
|
data/lib/git_hub_bub/request.rb
CHANGED
@@ -13,11 +13,16 @@ module GitHubBub
|
|
13
13
|
|
14
14
|
def initialize(url, query = {}, options = {})
|
15
15
|
self.url = url =~ /^http(\w?)\:\/\// ? url : File.join(BASE_URI, url)
|
16
|
+
@skip_token = options.delete(:skip_token)
|
16
17
|
self.options = BASE_OPTIONS.merge(options || {})
|
17
|
-
self.options[:query] = query
|
18
|
+
self.options[:query] = query if query && !query.empty?
|
18
19
|
self.options[:headers] = BASE_HEADERS.merge(options[:headers]|| {})
|
19
20
|
end
|
20
21
|
|
22
|
+
def skip_token?
|
23
|
+
@skip_token
|
24
|
+
end
|
25
|
+
|
21
26
|
def self.head(url, query = {}, options = {})
|
22
27
|
self.new(url, query, options).head
|
23
28
|
end
|
@@ -82,7 +87,7 @@ module GitHubBub
|
|
82
87
|
|
83
88
|
def wrap_request(&block)
|
84
89
|
before_callbacks!
|
85
|
-
set_auth_from_token!
|
90
|
+
set_auth_from_token! unless skip_token?
|
86
91
|
query_to_json_body!
|
87
92
|
response = RETRIES.times.retry do
|
88
93
|
GitHubBub::Response.create(yield)
|
data/lib/git_hub_bub/version.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ValidTokenTest < Test::Unit::TestCase
|
4
|
+
include WebMock::API
|
5
|
+
|
6
|
+
def teardown
|
7
|
+
GitHubBub::Request.clear_callbacks
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_does_not_add_token_to_header
|
11
|
+
token = "foo"
|
12
|
+
url = "https://#{ENV['GITHUB_APP_ID']}:#{ENV['GITHUB_APP_SECRET']}@api.github.com/applications/#{ENV['GITHUB_APP_ID']}/tokens/#{token}"
|
13
|
+
stub_get = stub_request(:get, url)
|
14
|
+
|
15
|
+
GitHubBub::Request.any_instance.expects(:token).never
|
16
|
+
|
17
|
+
GitHubBub.valid_token?(token)
|
18
|
+
assert_requested stub_get
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -5,6 +5,8 @@ Dotenv.load
|
|
5
5
|
|
6
6
|
require 'git_hub_bub'
|
7
7
|
require 'test/unit'
|
8
|
+
require 'mocha/test_unit'
|
9
|
+
require 'webmock'
|
8
10
|
|
9
11
|
def schneems_orgs_data
|
10
12
|
{:body=>"[{\"login\":\"gowalla\",\"id\":317884,\"url\":\"https://api.github.com/orgs/gowalla\",\"repos_url\":\"https://api.github.com/orgs/gowalla/repos\",\"events_url\":\"https://api.github.com/orgs/gowalla/events\",\"members_url\":\"https://api.github.com/orgs/gowalla/members{/member}\",\"public_members_url\":\"https://api.github.com/orgs/gowalla/public_members{/member}\",\"avatar_url\":\"https://secure.gravatar.com/avatar/72746c59eaafb328456c345dc3b95999?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-org-420.png\"},{\"login\":\"austinonrails\",\"id\":43000,\"url\":\"https://api.github.com/orgs/austinonrails\",\"repos_url\":\"https://api.github.com/orgs/austinonrails/repos\",\"events_url\":\"https://api.github.com/orgs/austinonrails/events\",\"members_url\":\"https://api.github.com/orgs/austinonrails/members{/member}\",\"public_members_url\":\"https://api.github.com/orgs/austinonrails/public_members{/member}\",\"avatar_url\":\"https://secure.gravatar.com/avatar/da3ed72ff4f24a1670a5497d7b588bf4?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-org-420.png\"},{\"login\":\"heroku\",\"id\":23211,\"url\":\"https://api.github.com/orgs/heroku\",\"repos_url\":\"https://api.github.com/orgs/heroku/repos\",\"events_url\":\"https://api.github.com/orgs/heroku/events\",\"members_url\":\"https://api.github.com/orgs/heroku/members{/member}\",\"public_members_url\":\"https://api.github.com/orgs/heroku/public_members{/member}\",\"avatar_url\":\"https://secure.gravatar.com/avatar/e327d6043ba309e2bfc8b56110b6dbbe?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-org-420.png\"},{\"login\":\"opro\",\"id\":2106073,\"url\":\"https://api.github.com/orgs/opro\",\"repos_url\":\"https://api.github.com/orgs/opro/repos\",\"events_url\":\"https://api.github.com/orgs/opro/events\",\"members_url\":\"https://api.github.com/orgs/opro/members{/member}\",\"public_members_url\":\"https://api.github.com/orgs/opro/public_members{/member}\",\"avatar_url\":\"https://secure.gravatar.com/avatar/f1fd003752171548706b5a3a9e820f31?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-org-420.png\"},{\"login\":\"codetriage\",\"id\":2896855,\"url\":\"https://api.github.com/orgs/codetriage\",\"repos_url\":\"https://api.github.com/orgs/codetriage/repos\",\"events_url\":\"https://api.github.com/orgs/codetriage/events\",\"members_url\":\"https://api.github.com/orgs/codetriage/members{/member}\",\"public_members_url\":\"https://api.github.com/orgs/codetriage/public_members{/member}\",\"avatar_url\":\"https://secure.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-org-420.png\"},{\"login\":\"sumodocs\",\"id\":3372962,\"url\":\"https://api.github.com/orgs/sumodocs\",\"repos_url\":\"https://api.github.com/orgs/sumodocs/repos\",\"events_url\":\"https://api.github.com/orgs/sumodocs/events\",\"members_url\":\"https://api.github.com/orgs/sumodocs/members{/member}\",\"public_members_url\":\"https://api.github.com/orgs/sumodocs/public_members{/member}\",\"avatar_url\":\"https://secure.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-org-420.png\"},{\"login\":\"rails\",\"id\":4223,\"url\":\"https://api.github.com/orgs/rails\",\"repos_url\":\"https://api.github.com/orgs/rails/repos\",\"events_url\":\"https://api.github.com/orgs/rails/events\",\"members_url\":\"https://api.github.com/orgs/rails/members{/member}\",\"public_members_url\":\"https://api.github.com/orgs/rails/public_members{/member}\",\"avatar_url\":\"https://secure.gravatar.com/avatar/30f39a09e233e8369dddf6feb4be0308?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-org-420.png\"},{\"login\":\"sharpstone\",\"id\":3969584,\"url\":\"https://api.github.com/orgs/sharpstone\",\"repos_url\":\"https://api.github.com/orgs/sharpstone/repos\",\"events_url\":\"https://api.github.com/orgs/sharpstone/events\",\"members_url\":\"https://api.github.com/orgs/sharpstone/members{/member}\",\"public_members_url\":\"https://api.github.com/orgs/sharpstone/public_members{/member}\",\"avatar_url\":\"https://secure.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-org-420.png\"},{\"login\":\"centerforstudents\",\"id\":4041835,\"url\":\"https://api.github.com/orgs/centerforstudents\",\"repos_url\":\"https://api.github.com/orgs/centerforstudents/repos\",\"events_url\":\"https://api.github.com/orgs/centerforstudents/events\",\"members_url\":\"https://api.github.com/orgs/centerforstudents/members{/member}\",\"public_members_url\":\"https://api.github.com/orgs/centerforstudents/public_members{/member}\",\"avatar_url\":\"https://secure.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-org-420.png\"},{\"login\":\"railsgirls\",\"id\":1641104,\"url\":\"https://api.github.com/orgs/railsgirls\",\"repos_url\":\"https://api.github.com/orgs/railsgirls/repos\",\"events_url\":\"https://api.github.com/orgs/railsgirls/events\",\"members_url\":\"https://api.github.com/orgs/railsgirls/members{/member}\",\"public_members_url\":\"https://api.github.com/orgs/railsgirls/public_members{/member}\",\"avatar_url\":\"https://secure.gravatar.com/avatar/ae1295e0d53f3b81def634344b6644c1?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-org-420.png\"},{\"login\":\"ruby-no-kai\",\"id\":207834,\"url\":\"https://api.github.com/orgs/ruby-no-kai\",\"repos_url\":\"https://api.github.com/orgs/ruby-no-kai/repos\",\"events_url\":\"https://api.github.com/orgs/ruby-no-kai/events\",\"members_url\":\"https://api.github.com/orgs/ruby-no-kai/members{/member}\",\"public_members_url\":\"https://api.github.com/orgs/ruby-no-kai/public_members{/member}\",\"avatar_url\":\"https://secure.gravatar.com/avatar/ea5efa6071bc5fd5f9f74949cc743407?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-org-420.png\"}]", :headers=>{"Server"=>"GitHub.com", "Date"=>"Mon, 20 May 2013 19:49:07 GMT", "Content-Type"=>"application/json; charset=utf-8", "Connection"=>"keep-alive", "Status"=>"200 OK", "X-RateLimit-Limit"=>"5000", "X-RateLimit-Remaining"=>"4993", "Vary"=>"Accept, Authorization, Cookie, Accept-Encoding", "Cache-Control"=>"private, max-age=60, s-maxage=60", "Last-Modified"=>"Mon, 20 May 2013 19:42:52 GMT", "ETag"=>"\"0ecbc232dd0a0b86c82ad92050ea38aa\"", "X-OAuth-Scopes"=>"user:email", "X-Accepted-OAuth-Scopes"=>"repo, user", "X-GitHub-Media-Type"=>"github.beta; param=3.raw; format=json", "X-Content-Type-Options"=>"nosniff", "Content-Length"=>"5812", "Access-Control-Allow-Credentials"=>"true", "Access-Control-Expose-Headers"=>"Link, X-RateLimit-Limit, X-RateLimit-Remaining, X-OAuth-Scopes, X-Accepted-OAuth-Scopes", "Access-Control-Allow-Origin"=>"*"}, :status=>200, :remote_ip=>"207.97.227.243"}
|
@@ -30,7 +32,15 @@ VCR.configure do |c|
|
|
30
32
|
c.cassette_library_dir = 'test/fixtures/vcr_cassettes'
|
31
33
|
c.hook_into :webmock # or :fakeweb
|
32
34
|
|
33
|
-
|
35
|
+
%W{
|
36
|
+
GITHUB_API_KEY
|
37
|
+
OWNER REPO
|
38
|
+
USER_NAME
|
39
|
+
WATCH_OWNER
|
40
|
+
WATCH_REPO
|
41
|
+
GITHUB_APP_ID
|
42
|
+
GITHUB_APP_SECRET
|
43
|
+
}.each do |secure|
|
34
44
|
sensitive = ENV[secure] ||= secure
|
35
45
|
c.filter_sensitive_data("<#{secure}>") { sensitive }
|
36
46
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_hub_bub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Schneeman
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mocha
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,6 +136,7 @@ files:
|
|
122
136
|
- test/fixtures/vcr_cassettes/PUT_/repos/_owner/_repo/subscription.yml
|
123
137
|
- test/git_hub_bub/request_test.rb
|
124
138
|
- test/git_hub_bub/response_test.rb
|
139
|
+
- test/git_hub_bub/valid_token_test.rb
|
125
140
|
- test/test_helper.rb
|
126
141
|
homepage: https://github.com/schneems/git_hub_bub
|
127
142
|
licenses:
|
@@ -157,4 +172,5 @@ test_files:
|
|
157
172
|
- test/fixtures/vcr_cassettes/PUT_/repos/_owner/_repo/subscription.yml
|
158
173
|
- test/git_hub_bub/request_test.rb
|
159
174
|
- test/git_hub_bub/response_test.rb
|
175
|
+
- test/git_hub_bub/valid_token_test.rb
|
160
176
|
- test/test_helper.rb
|