keen 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 71233f3a2e9ddc96e83f3da3dafa0039cedecda5
4
- data.tar.gz: 42310b5093a4e6521f18bd42216054e5559ea0c1
3
+ metadata.gz: 7f3ca87ca38420ae7e1f6a5eedb518cd15ea8dff
4
+ data.tar.gz: 80f93a25b21544455b44e72201ce0aad31b71300
5
5
  SHA512:
6
- metadata.gz: ba7604df56cd05a57e56d2faa1f357356302d5769c1ceab719047cff3ed9882d192384855e6f3567260724ec535842b901b18b3ba4301cc90c5531d4d3390672
7
- data.tar.gz: 3e7b5fb538b3102842823aeec35224c371e7f47cee570bdf5f912645520dcdf0dad44560bf828285d864240b0a8798aa6e7e2fef29b85f3b19733bef2a621599
6
+ metadata.gz: 3ed597078e79fc3ea6f039b9932f3272d60bf14982fe71276d163bd4b250699410a4cc05ca07f1864d74c30235675726784bff7338d6508248980d60b3e7a18c
7
+ data.tar.gz: 400daed8bfbbc1cc4a978650a6e435655c35943169bd15089f4a83179eed3443b80b62880fb521dd2c7382600194b25de43713d34e0cb41e8129a9cf702e074c
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
1
  --format progress
2
2
  --color
3
+ --tty
@@ -5,7 +5,7 @@ require "keen/version"
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "keen"
7
7
  s.version = Keen::VERSION
8
- s.authors = ["Alex Kleissner", "Josh Dzielak", "Joe Wegner"]
8
+ s.authors = ["Alex Kleissner", "Joe Wegner"]
9
9
  s.email = "opensource@keen.io"
10
10
  s.homepage = "https://github.com/keenlabs/keen-gem"
11
11
  s.summary = "Keen IO API Client"
@@ -7,11 +7,12 @@ module Keen
7
7
 
8
8
  BLOCK_SIZE = 32
9
9
 
10
- def aes256_encrypt(key, plaintext)
10
+ def aes256_encrypt(key, plaintext, iv = nil)
11
11
  aes = OpenSSL::Cipher::AES.new(256, :CBC)
12
12
  aes.encrypt
13
13
  aes.key = key
14
- iv = aes.random_iv
14
+ aes.iv = iv unless iv.nil?
15
+ iv ||= aes.random_iv
15
16
  [aes.update(plaintext) + aes.final, iv]
16
17
  end
17
18
 
@@ -40,4 +41,4 @@ module Keen
40
41
  padded
41
42
  end
42
43
  end
43
- end
44
+ end
@@ -100,6 +100,8 @@ module Keen
100
100
  end
101
101
 
102
102
  def preprocess_params(params)
103
+ params = params.delete_if {|key, val| val.nil?}
104
+
103
105
  preprocess_encodables(params)
104
106
  preprocess_timeframe(params)
105
107
  preprocess_group_by(params)
@@ -24,10 +24,10 @@ module Keen
24
24
  self.data = data
25
25
  end
26
26
 
27
- def encrypt!
27
+ def encrypt!(iv = nil)
28
28
  json_str = MultiJson.dump(self.data)
29
29
  padded_api_key = pad(self.api_key)
30
- encrypted, iv = aes256_encrypt(padded_api_key, json_str)
30
+ encrypted, iv = aes256_encrypt(padded_api_key, json_str, iv)
31
31
  hexlify(iv) + hexlify(encrypted)
32
32
  end
33
33
  end
@@ -1,3 +1,3 @@
1
1
  module Keen
2
- VERSION = "0.9.0"
2
+ VERSION = "0.9.1"
3
3
  end
@@ -86,4 +86,36 @@ describe Keen::Client do
86
86
  }.to raise_error(Keen::HttpError, exception_body)
87
87
  end
88
88
  end
89
+
90
+ describe "preprocess_params" do
91
+ it "returns an empty string with no parameters" do
92
+ params = {}
93
+ expect(
94
+ client.instance_eval{preprocess_params(params)}
95
+ ).to eq("")
96
+ end
97
+
98
+ it "strips out nil parameters" do
99
+ params = { :timeframe => nil, :group_by => "foo.bar" }
100
+ expect(
101
+ client.instance_eval{preprocess_params(params)}
102
+ ).to eq("group_by=foo.bar")
103
+ end
104
+ end
105
+
106
+ describe "preprocess_timeframe" do
107
+ it "does nothing for string values" do
108
+ params = { :timeframe => 'this_3_days' }
109
+ expect {
110
+ client.instance_eval{preprocess_timeframe(params)}
111
+ }.to_not change { params }
112
+ end
113
+
114
+ it "multi encodes for hash values" do
115
+ params = {:timeframe => {:start => '2012-08-13T19:00:00.000Z', :end => '2013-09-20T19:00:00.000Z'} }
116
+ expect {
117
+ client.instance_eval{preprocess_timeframe(params)}
118
+ }.to change {params}.to({:timeframe => "{\"start\":\"2012-08-13T19:00:00.000Z\",\"end\":\"2013-09-20T19:00:00.000Z\"}"})
119
+ end
120
+ end
89
121
  end
@@ -29,6 +29,24 @@ describe Keen::ScopedKey do
29
29
  other_api_key.data.should == data
30
30
  end
31
31
 
32
+ describe "when an IV is not provided" do
33
+ it "should not produce the same encrypted key text" do
34
+ new_scoped_key.encrypt!.should_not == (new_scoped_key.encrypt!)
35
+ end
36
+ end
37
+
38
+ describe "when an IV is provided" do
39
+ it "should produce the same encrypted key text for a " do
40
+ iv = "\0" * 32
41
+ new_scoped_key.encrypt!(iv).should == (new_scoped_key.encrypt!(iv))
42
+ end
43
+
44
+ it "should raise error when an invalid IV is supplied" do
45
+ iv = "fakeiv"
46
+ expect { new_scoped_key.encrypt!(iv) }.to raise_error(OpenSSL::Cipher::CipherError)
47
+ end
48
+ end
49
+
32
50
  it "should not decrypt the scoped key with a bad api key" do
33
51
  encrypted_str = new_scoped_key.encrypt!
34
52
  expect {
@@ -67,5 +67,9 @@ end
67
67
 
68
68
  RSpec.configure do |config|
69
69
  config.include(Keen::SpecHelpers)
70
+
71
+ config.color = true
72
+ config.tty = true
73
+ config.formatter = :progress # :progress, :documentation, :html, :textmate
70
74
  end
71
75
 
metadata CHANGED
@@ -1,141 +1,140 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Kleissner
8
- - Josh Dzielak
9
8
  - Joe Wegner
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2015-06-02 00:00:00.000000000 Z
12
+ date: 2015-07-07 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: multi_json
17
16
  requirement: !ruby/object:Gem::Requirement
18
17
  requirements:
19
- - - ~>
18
+ - - "~>"
20
19
  - !ruby/object:Gem::Version
21
20
  version: '1.3'
22
21
  type: :runtime
23
22
  prerelease: false
24
23
  version_requirements: !ruby/object:Gem::Requirement
25
24
  requirements:
26
- - - ~>
25
+ - - "~>"
27
26
  - !ruby/object:Gem::Version
28
27
  version: '1.3'
29
28
  - !ruby/object:Gem::Dependency
30
29
  name: addressable
31
30
  requirement: !ruby/object:Gem::Requirement
32
31
  requirements:
33
- - - ~>
32
+ - - "~>"
34
33
  - !ruby/object:Gem::Version
35
34
  version: 2.3.5
36
35
  type: :runtime
37
36
  prerelease: false
38
37
  version_requirements: !ruby/object:Gem::Requirement
39
38
  requirements:
40
- - - ~>
39
+ - - "~>"
41
40
  - !ruby/object:Gem::Version
42
41
  version: 2.3.5
43
42
  - !ruby/object:Gem::Dependency
44
43
  name: guard
45
44
  requirement: !ruby/object:Gem::Requirement
46
45
  requirements:
47
- - - '>='
46
+ - - ">="
48
47
  - !ruby/object:Gem::Version
49
48
  version: '0'
50
49
  type: :development
51
50
  prerelease: false
52
51
  version_requirements: !ruby/object:Gem::Requirement
53
52
  requirements:
54
- - - '>='
53
+ - - ">="
55
54
  - !ruby/object:Gem::Version
56
55
  version: '0'
57
56
  - !ruby/object:Gem::Dependency
58
57
  name: guard-rspec
59
58
  requirement: !ruby/object:Gem::Requirement
60
59
  requirements:
61
- - - '>='
60
+ - - ">="
62
61
  - !ruby/object:Gem::Version
63
62
  version: '0'
64
63
  type: :development
65
64
  prerelease: false
66
65
  version_requirements: !ruby/object:Gem::Requirement
67
66
  requirements:
68
- - - '>='
67
+ - - ">="
69
68
  - !ruby/object:Gem::Version
70
69
  version: '0'
71
70
  - !ruby/object:Gem::Dependency
72
71
  name: rb-inotify
73
72
  requirement: !ruby/object:Gem::Requirement
74
73
  requirements:
75
- - - '>='
74
+ - - ">="
76
75
  - !ruby/object:Gem::Version
77
76
  version: '0'
78
77
  type: :development
79
78
  prerelease: false
80
79
  version_requirements: !ruby/object:Gem::Requirement
81
80
  requirements:
82
- - - '>='
81
+ - - ">="
83
82
  - !ruby/object:Gem::Version
84
83
  version: '0'
85
84
  - !ruby/object:Gem::Dependency
86
85
  name: rb-fsevent
87
86
  requirement: !ruby/object:Gem::Requirement
88
87
  requirements:
89
- - - '>='
88
+ - - ">="
90
89
  - !ruby/object:Gem::Version
91
90
  version: '0'
92
91
  type: :development
93
92
  prerelease: false
94
93
  version_requirements: !ruby/object:Gem::Requirement
95
94
  requirements:
96
- - - '>='
95
+ - - ">="
97
96
  - !ruby/object:Gem::Version
98
97
  version: '0'
99
98
  - !ruby/object:Gem::Dependency
100
99
  name: rb-fchange
101
100
  requirement: !ruby/object:Gem::Requirement
102
101
  requirements:
103
- - - '>='
102
+ - - ">="
104
103
  - !ruby/object:Gem::Version
105
104
  version: '0'
106
105
  type: :development
107
106
  prerelease: false
108
107
  version_requirements: !ruby/object:Gem::Requirement
109
108
  requirements:
110
- - - '>='
109
+ - - ">="
111
110
  - !ruby/object:Gem::Version
112
111
  version: '0'
113
112
  - !ruby/object:Gem::Dependency
114
113
  name: ruby_gntp
115
114
  requirement: !ruby/object:Gem::Requirement
116
115
  requirements:
117
- - - '>='
116
+ - - ">="
118
117
  - !ruby/object:Gem::Version
119
118
  version: '0'
120
119
  type: :development
121
120
  prerelease: false
122
121
  version_requirements: !ruby/object:Gem::Requirement
123
122
  requirements:
124
- - - '>='
123
+ - - ">="
125
124
  - !ruby/object:Gem::Version
126
125
  version: '0'
127
126
  - !ruby/object:Gem::Dependency
128
127
  name: rb-readline
129
128
  requirement: !ruby/object:Gem::Requirement
130
129
  requirements:
131
- - - '>='
130
+ - - ">="
132
131
  - !ruby/object:Gem::Version
133
132
  version: '0'
134
133
  type: :development
135
134
  prerelease: false
136
135
  version_requirements: !ruby/object:Gem::Requirement
137
136
  requirements:
138
- - - '>='
137
+ - - ">="
139
138
  - !ruby/object:Gem::Version
140
139
  version: '0'
141
140
  description: Send events and build analytics features into your Ruby applications.
@@ -144,9 +143,9 @@ executables: []
144
143
  extensions: []
145
144
  extra_rdoc_files: []
146
145
  files:
147
- - .gitignore
148
- - .rspec
149
- - .travis.yml
146
+ - ".gitignore"
147
+ - ".rspec"
148
+ - ".travis.yml"
150
149
  - Gemfile
151
150
  - Guardfile
152
151
  - LICENSE
@@ -185,17 +184,17 @@ require_paths:
185
184
  - lib
186
185
  required_ruby_version: !ruby/object:Gem::Requirement
187
186
  requirements:
188
- - - '>='
187
+ - - ">="
189
188
  - !ruby/object:Gem::Version
190
189
  version: '0'
191
190
  required_rubygems_version: !ruby/object:Gem::Requirement
192
191
  requirements:
193
- - - '>='
192
+ - - ">="
194
193
  - !ruby/object:Gem::Version
195
194
  version: '0'
196
195
  requirements: []
197
196
  rubyforge_project:
198
- rubygems_version: 2.0.14
197
+ rubygems_version: 2.2.2
199
198
  signing_key:
200
199
  specification_version: 4
201
200
  summary: Keen IO API Client