shared-secret-authentication 0.1.6 → 0.2.0

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.6
1
+ 0.2.0
@@ -15,12 +15,14 @@ module SharedSecretAuthentication
15
15
  d = Digest::SHA2.new
16
16
  string_keys = hash.keys.inject({}) {|keys, key| keys.merge!(key.to_s => key) }
17
17
  string_keys.keys.sort.each do |key|
18
+ puts key.inspect
18
19
  d.update key
19
20
  value = hash[string_keys[key]]
20
21
  if value.instance_of? Hash
21
22
  value = value.collect {|k,v|
22
23
  if v.respond_to? :strftime
23
24
  if v.respond_to? :utc
25
+
24
26
  k.to_s + v.utc.strftime('%a %b %m %H:%M:%S %Y')
25
27
  else
26
28
  k.to_s + v.strftime('%a %b %m %H:%M:%S %Y')
@@ -32,10 +34,27 @@ module SharedSecretAuthentication
32
34
  end
33
35
 
34
36
  if value.instance_of? Array
37
+ puts value.inspect
35
38
  value = value.sort
39
+ value = value.collect {|v|
40
+ if v.respond_to? :strftime
41
+ if v.respond_to? :utc
42
+ puts 'here in utc'
43
+ v.utc.strftime('%a %b %m %H:%M:%S %Y')
44
+ else
45
+ puts 'not in utc'
46
+ v.strftime('%a %b %m %H:%M:%S %Y')
47
+ end
48
+ else
49
+ v.to_s
50
+ end
51
+
52
+ }
36
53
  elsif value.respond_to? :strftime
37
54
  value = value.strftime('%a %b %m %H:%M:%S %Y')
38
55
  end
56
+ puts 'in here'
57
+ puts value.to_s.inspect
39
58
  d.update value.to_s
40
59
  end
41
60
  d.update SHARED_SECRET
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{shared-secret-authentication}
8
- s.version = "0.1.6"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Josh Moore"]
12
- s.date = %q{2011-01-20}
12
+ s.date = %q{2011-09-27}
13
13
  s.description = %q{helper methods to make shared secret authentication easier}
14
14
  s.email = %q{joshsmoore@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -31,7 +31,6 @@ Gem::Specification.new do |s|
31
31
  "spec/shared-secret-authentication/generator_spec.rb",
32
32
  "spec/shared-secret-authentication/hash_signatures_spec.rb",
33
33
  "spec/shared-secret-authentication/load_secret_spec.rb",
34
- "spec/shared-secret-authentication_spec.rb",
35
34
  "spec/spec.opts",
36
35
  "spec/spec_helper.rb",
37
36
  "watchr.rb"
@@ -44,7 +43,6 @@ Gem::Specification.new do |s|
44
43
  "spec/shared-secret-authentication/generator_spec.rb",
45
44
  "spec/shared-secret-authentication/hash_signatures_spec.rb",
46
45
  "spec/shared-secret-authentication/load_secret_spec.rb",
47
- "spec/shared-secret-authentication_spec.rb",
48
46
  "spec/spec_helper.rb"
49
47
  ]
50
48
 
@@ -8,6 +8,7 @@ describe SharedSecretAuthentication do
8
8
 
9
9
  describe '.standarize_string' do
10
10
  it 'should produce the same hash for all arrays no matter what the order'
11
+
11
12
  end
12
13
 
13
14
  describe '.sign_hash' do
@@ -60,7 +61,33 @@ describe SharedSecretAuthentication do
60
61
  SharedSecretAuthentication.hash_signature_correct?({'visits' => {'visit_date' => Time.parse('2010-06-04T16:48:46Z'), 'mysql_id' => 1}, 'signature' => "d461a73c904fe4cd55b0eaa7212a89973f3126067bccf97775767575a26a148f"}).should be_true
61
62
  end
62
63
 
64
+ it 'should work in different timezones or top level times' do
65
+ SharedSecretAuthentication.hash_signature_correct?({'visit_date' => Time.parse('2010-06-04T16:48:46Z'), 'signature' => "dc951a85cde77e5c10154e6284f2facc61393324ce84a9b5ecfe18d950a1e119"}).should be_true
66
+ end
67
+
68
+ it 'should convert dates in the array to strings' do
69
+ date = Date.today
70
+
71
+ d = Digest::SHA2.new
72
+ d.update 'eval_dates'
73
+ puts 'in test'
74
+ puts date.strftime('%a %b %m %H:%M:%S %Y').inspect
75
+ d.update date.strftime('%a %b %m %H:%M:%S %Y')
76
+
77
+ puts ''
78
+ puts 'here'
79
+ puts ''
80
+ SharedSecretAuthentication.hash_signature({'eval_dates' => [date]}).should == d.to_s
81
+ end
82
+
63
83
  context 'edge cases' do
84
+
85
+ it 'should produce the same signature for date objects if the date is converted into a time' do
86
+ hash1 = {"cases" => {'last_date_seen' => Date.parse("Thu, 22 Apr 2010")}}
87
+ hash2 = {"cases" => {'last_date_seen' => Time.parse("Thu, 22 Apr 2010")}}
88
+
89
+ SharedSecretAuthentication.hash_signature(hash1).should == SharedSecretAuthentication.hash_signature(hash2)
90
+ end
64
91
  it 'should produce the same signature for both hashes' do
65
92
  hash1 = {"practices"=>{"name"=>"Body Image Physical Therapy & Fitness P.C.", "mysql_updated_at"=>Time.parse("Thu, 03 Jun 2010 19:15:03 UTC +00:00"), "mysql_id"=>79}}
66
93
  hash2 = {"practices"=>{"mysql_updated_at"=>Time.parse("2010-06-03T19:15:03Z"), "name"=>"Body Image Physical Therapy & Fitness P.C.", "mysql_id"=>79}}
@@ -7,12 +7,9 @@ describe 'load shared secret' do
7
7
  end
8
8
 
9
9
  it 'should load the shared_secret from config/shared_secret.yml' do
10
- puts 'starting test'
11
- file = StringIO.new(":shared_secret : my_shared_secret")
10
+ file = StringIO.new("shared_secret : my_shared_secret")
12
11
  File.stub!(:new).and_return(file)
13
-
14
12
  require 'lib/shared-secret-authentication/load_secret'
15
- #file.should_receive(:read).once.and_return(file.read)
16
13
 
17
14
  SHARED_SECRET.should == 'my_shared_secret'
18
15
  end
@@ -5,10 +5,5 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
5
 
6
6
  require 'shared-secret-authentication'
7
7
  require 'rspec'
8
- require 'rspec/autorun'
9
8
  require 'time'
10
9
 
11
-
12
- RSpec.configure do |config|
13
-
14
- end
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 6
10
- version: 0.1.6
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Josh Moore
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-20 00:00:00 -10:00
18
+ date: 2011-09-27 00:00:00 +08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -58,7 +58,6 @@ files:
58
58
  - spec/shared-secret-authentication/generator_spec.rb
59
59
  - spec/shared-secret-authentication/hash_signatures_spec.rb
60
60
  - spec/shared-secret-authentication/load_secret_spec.rb
61
- - spec/shared-secret-authentication_spec.rb
62
61
  - spec/spec.opts
63
62
  - spec/spec_helper.rb
64
63
  - watchr.rb
@@ -100,5 +99,4 @@ test_files:
100
99
  - spec/shared-secret-authentication/generator_spec.rb
101
100
  - spec/shared-secret-authentication/hash_signatures_spec.rb
102
101
  - spec/shared-secret-authentication/load_secret_spec.rb
103
- - spec/shared-secret-authentication_spec.rb
104
102
  - spec/spec_helper.rb
@@ -1,7 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "SharedSecretAuthentication" do
4
- it "fails" do
5
- fail "hey buddy, you should probably rename this file and start specing for real"
6
- end
7
- end