Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Pins JWT to ~> 1.0.0 and fixes tests. #97

Merged
merged 1 commit into from

2 participants

@philnash
Owner

JWT started to return both the payload and a header when decoding a token since
this pull request. This has
since become part of the version 1.0 release, so this gem might as well
encourage usage of 1.0 and get fixed tests for that.

@philnash philnash Pins JWT to ~> 1.0.0 and fixes tests.
JWT started to return both the payload and a header when decoding a token since
[this pull request](jwt/ruby-jwt#35). This has
since become part of the version 1.0 release, so this gem might as well
encourage usage of 1.0 and get fixed tests for that.
6778a9a
@carlosdp
Owner

:+1: Looks like the failing tests on Travis are unrelated and only affect Rubinius because the worker did not install bundler.

@carlosdp carlosdp merged commit a826563 into twilio:master

1 check failed

Details continuous-integration/travis-ci The Travis CI build could not complete due to an error
@carlosdp
Owner

Thank you!

@philnash philnash referenced this pull request
Merged

Bumps JWT again. #98

@philnash philnash deleted the philnash:jwt-test-failures branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 21, 2014
  1. @philnash

    Pins JWT to ~> 1.0.0 and fixes tests.

    philnash authored
    JWT started to return both the payload and a header when decoding a token since
    [this pull request](jwt/ruby-jwt#35). This has
    since become part of the version 1.0 release, so this gem might as well
    encourage usage of 1.0 and get fixed tests for that.
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 13 deletions.
  1. +12 −12 spec/util/capability_spec.rb
  2. +1 −1  twilio-ruby.gemspec
View
24 spec/util/capability_spec.rb
@@ -11,7 +11,7 @@ def queries(q)
it 'should return a valid jwt when #generate is called' do
token = @capability.generate
- decoded = JWT.decode token, 'myAuthToken'
+ decoded, header = JWT.decode token, 'myAuthToken'
decoded['scope'].should_not be_nil
decoded['iss'].should_not be_nil
decoded['exp'].should_not be_nil
@@ -19,14 +19,14 @@ def queries(q)
it 'should properly set the iss key in the payload' do
token = @capability.generate
- decoded = JWT.decode token, 'myAuthToken'
+ decoded, header = JWT.decode token, 'myAuthToken'
decoded['iss'].should == 'myAccountSid'
end
it 'should properly set the exp key based on the default hour ttl' do
seconds = Time.now.to_i
token = @capability.generate
- decoded = JWT.decode token, 'myAuthToken'
+ decoded, header = JWT.decode token, 'myAuthToken'
decoded['exp'].should == seconds + 3600
end
@@ -34,14 +34,14 @@ def queries(q)
ttl = rand 10000
seconds = Time.now.to_i
token = @capability.generate ttl
- decoded = JWT.decode token, 'myAuthToken'
+ decoded, header = JWT.decode token, 'myAuthToken'
decoded['exp'].should == seconds + ttl
end
it 'should generate a proper incoming client scope string' do
@capability.allow_client_incoming 'andrew'
token = @capability.generate
- decoded = JWT.decode token, 'myAuthToken'
+ decoded, header = JWT.decode token, 'myAuthToken'
queries(decoded['scope']).should == [['incoming', {'clientName' => 'andrew'}]]
end
@@ -49,7 +49,7 @@ def queries(q)
@capability.allow_client_incoming 'andrew'
@capability.allow_client_incoming 'bridget'
token = @capability.generate
- decoded = JWT.decode token, 'myAuthToken'
+ decoded, header = JWT.decode token, 'myAuthToken'
queries(decoded['scope']).should == [
['incoming', {'clientName' => 'andrew'}],
['incoming', {'clientName' => 'bridget'}]
@@ -59,7 +59,7 @@ def queries(q)
it 'should generate a proper outgoing client scope string' do
@capability.allow_client_outgoing 'myAppSid'
token = @capability.generate
- decoded = JWT.decode token, 'myAuthToken'
+ decoded, header = JWT.decode token, 'myAuthToken'
queries(decoded['scope']).should == [['outgoing', {'appSid' => 'myAppSid'}]]
end
@@ -70,7 +70,7 @@ def queries(q)
params_hash = {'appSid' => 'myAppSid', 'appParams' => app_params}
@capability.instance_eval {url_encode(params_hash)}
token = @capability.generate
- decoded = JWT.decode token, 'myAuthToken'
+ decoded, header = JWT.decode token, 'myAuthToken'
queries(decoded['scope']).should == [['outgoing', params_hash]]
end
@@ -79,7 +79,7 @@ def queries(q)
@capability.allow_client_incoming 'andrew'
@capability.allow_client_outgoing 'myAppSid'
token = @capability.generate
- decoded = JWT.decode token, 'myAuthToken'
+ decoded, header = JWT.decode token, 'myAuthToken'
queries(decoded['scope']).should == [
['incoming', {'clientName' => 'andrew'}],
['outgoing', {'clientName' => 'andrew', 'appSid' => 'myAppSid'}]
@@ -91,7 +91,7 @@ def queries(q)
@capability.allow_client_outgoing 'myAppSid'
@capability.allow_client_incoming 'andrew'
token = @capability.generate
- decoded = JWT.decode token, 'myAuthToken'
+ decoded, header = JWT.decode token, 'myAuthToken'
queries(decoded['scope']).should == [["incoming", {"clientName"=>"andrew"}], ["outgoing", {"clientName"=>"andrew", "appSid"=>"myAppSid"}]]
end
@@ -104,7 +104,7 @@ def queries(q)
params_hash = {'appSid' => 'myAppSid', 'appParams' => app_params, 'clientName' => 'andrew'}
@capability.instance_eval {url_encode(params_hash)}
token = @capability.generate
- decoded = JWT.decode token, 'myAuthToken'
+ decoded, header = JWT.decode token, 'myAuthToken'
scopes = queries(decoded['scope'])
scopes.shift.should == ["incoming", {"clientName"=>"andrew"}]
scope = scopes.shift
@@ -124,7 +124,7 @@ def queries(q)
params_hash = {'appSid' => 'myAppSid', 'appParams' => app_params, 'clientName' => 'andrew'}
@capability.instance_eval {url_encode(params_hash)}
token = @capability.generate
- decoded = JWT.decode token, 'myAuthToken'
+ decoded, header = JWT.decode token, 'myAuthToken'
scopes = queries(decoded['scope'])
scopes.shift.should == ["incoming", {"clientName"=>"andrew"}]
scope = scopes.shift
View
2  twilio-ruby.gemspec
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
s.add_dependency('multi_json', '>= 1.3.0')
s.add_dependency('builder', '>= 2.1.2')
- s.add_dependency('jwt', '>= 0.1.2')
+ s.add_dependency('jwt', '~> 1.0.0')
s.add_dependency('jruby-openssl') if RUBY_PLATFORM == 'java'
# Workaround for RBX <= 2.2.1, should be fixed in next version
s.add_dependency('rubysl') if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
Something went wrong with that request. Please try again.