jedlik 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/jedlik.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'jedlik'
5
- s.version = '0.0.4'
5
+ s.version = '0.0.5'
6
6
  s.summary = "Communicate with Amazon DynamoDB."
7
7
  s.description = "Communicate with Amazon DynamoDB. Raw access to the full API without having to handle temporary credentials or HTTP requests by yourself."
8
8
  s.authors = ["Hashmal", "Brandon Keene"]
@@ -68,7 +68,8 @@ module Jedlik
68
68
  # credentials were previously obtained, no request is made until they
69
69
  # expire.
70
70
  def obtain_credentials
71
- if not @expiration or @expiration <= Time.now.utc
71
+ @time = Time.now.utc
72
+ if not @expiration or @expiration <= @time
72
73
  params = {
73
74
  :AWSAccessKeyId => @_access_key_id,
74
75
  :SignatureMethod => 'HmacSHA256',
@@ -87,13 +88,14 @@ module Jedlik
87
88
  raise "credential errors: #{response.inspect}"
88
89
  end
89
90
  end
91
+ @time = nil
90
92
  end
91
93
 
92
94
  def authorization_params
93
95
  {
94
- :Action => 'GetSessionToken',
95
- :Timestamp => Time.now.utc.iso8601,
96
- :Version => '2011-06-15',
96
+ :Action => 'GetSessionToken',
97
+ :Timestamp => (@time || Time.now.utc).iso8601,
98
+ :Version => '2011-06-15',
97
99
  }
98
100
  end
99
101
 
@@ -63,27 +63,27 @@ module Jedlik
63
63
  # expire and new ones are requested.
64
64
  it "updates the timestamp for different requests" do
65
65
  s = SecurityTokenService.new("access_key_id", "secret_access_key")
66
- s.string_to_sign.should == [
67
- "GET",
68
- "sts.amazonaws.com",
69
- "/",
70
- "AWSAccessKeyId=access_key_id&Action=GetSessionToken&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-03-24T22%3A10%3A38Z&Version=2011-06-15"
71
- ].join("\n")
66
+ s.session_token
72
67
 
73
68
  Time.stub(:now).and_return(Time.parse("2012-03-24T23:11:38Z"))
74
- s.string_to_sign.should == [
75
- "GET",
76
- "sts.amazonaws.com",
77
- "/",
78
- "AWSAccessKeyId=access_key_id&Action=GetSessionToken&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-03-24T23%3A11%3A38Z&Version=2011-06-15"
79
- ].join("\n")
69
+ stub_request(:get, "https://sts.amazonaws.com/").
70
+ with(:query => {
71
+ "AWSAccessKeyId" => "access_key_id",
72
+ "Action" => "GetSessionToken",
73
+ "Signature" => "TRVf5kuncW+c7y3amXH1WWR+Mf9Y+KzVNmUQ9vDRgNQ=",
74
+ "SignatureMethod" => "HmacSHA256",
75
+ "SignatureVersion" => "2",
76
+ "Timestamp" => "2012-03-24T23:11:38Z",
77
+ "Version" => "2011-06-15"
78
+ }).to_return(:status => 200, :body => VALID_RESPONSE_BODY)
79
+ s.session_token
80
80
  end
81
81
 
82
82
  it "does not update the timestamp for the same request" do
83
- Time.stub(:now).and_return(
84
- Time.parse("2012-03-24T22:10:38Z"),
85
- Time.parse("2012-03-24T22:10:39Z")
86
- )
83
+ t1 = Time.parse("2012-03-24T22:10:38Z")
84
+ t2 = Time.parse("2012-03-24T22:10:39Z")
85
+ Time.stub(:now).and_return(t1, t2)
86
+
87
87
  sts.session_token
88
88
  end
89
89
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jedlik
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-03-27 00:00:00.000000000Z
13
+ date: 2012-03-28 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: typhoeus