noms-command 0.5.0 → 2.1.1

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.
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env rspec
2
+
3
+ require 'spec_helper'
4
+
5
+ require 'noms/command/useragent'
6
+
7
+ describe NOMS::Command::UserAgent do
8
+
9
+ describe '.get' do
10
+
11
+ before(:all) do
12
+ setup_fixture
13
+ start_server
14
+ end
15
+
16
+ after(:all) do
17
+ stop_server
18
+ teardown_fixture
19
+ end
20
+
21
+ before(:each) do
22
+ @input = StringIO.new
23
+ @input.truncate(@input.rewind)
24
+ @output = StringIO.new
25
+ @output.truncate(@output.rewind)
26
+ @auth = NOMS::Command::Auth.new :prompt_input => @input, :prompt_output => @output, :force_prompt => true
27
+ Dir[NOMS::Command::Auth::Identity.identity_dir + '/*'].each { |f| File.unlink f }
28
+ File.unlink NOMS::Command::Auth::Identity.vault_keyfile if File.exist? NOMS::Command::Auth::Identity.vault_keyfile
29
+ @ua = NOMS::Command::UserAgent.new 'http://localhost:8787/', :auth => @auth
30
+ end
31
+
32
+ it "does basic authentication with user input" do
33
+ @input << "testuser\ntestpass\n"
34
+ @input.rewind
35
+ response, = @ua.get 'http://localhost:8787/auth/ok'
36
+ expect(response.success?).to be_truthy
37
+ expect(@output.string).to include %q(http://localhost:8787/ (Authorization Required) username:)
38
+ end
39
+
40
+ it "prompts three times for authentication" do
41
+ @input << "testuser\nfailure\ntestuser\nfailure\ntestuser\ntestpass\n"
42
+ @input.rewind
43
+ response, = @ua.get 'http://localhost:8787/auth/ok'
44
+ pat = %r{http://localhost:8787/ \(Authorization Required\) username:.*?$}
45
+ expect(@output.string.scan(pat).size).to eq 3
46
+ expect(response.success?).to be_truthy
47
+ end
48
+
49
+ it "saves authentication identity for subsequent uses" do
50
+ @input << "testuser\ntestpass\n"
51
+ @input.rewind
52
+ response0, = @ua.get 'http://localhost:8787/auth/ok'
53
+ expect(response0.success?).to be_truthy
54
+
55
+ @input.truncate(@input.rewind)
56
+
57
+ response1, = @ua.get 'http://localhost:8787/auth/ok'
58
+ expect(response1.success?).to be_truthy
59
+ end
60
+
61
+ it "does basic authentication with identity file" do
62
+ auth = NOMS::Command::Auth.new :specified_identities => ['test/identity']
63
+ ua = NOMS::Command::UserAgent.new 'http://localhost:8787', :auth => auth
64
+ response, = ua.get 'http://localhost:8787/auth/ok'
65
+ expect(response.success?).to be_truthy
66
+ end
67
+
68
+ it "saves a plaintext identity in specified file" do
69
+ ua = NOMS::Command::UserAgent.new 'http://localhost:8787/', :auth => @auth,
70
+ :plaintext_identity => 'test/testuser.id'
71
+ @input << "testuser\ntestpass\n"
72
+ @input.rewind
73
+ response, = ua.get 'http://localhost:8787/auth/ok'
74
+ expect(response.success?).to be_truthy
75
+ expect(File.exist? 'test/testuser.id').to be_truthy
76
+ expect(File.read('test/testuser.id')).to include %q{Authorization+Required=http://localhost:8787/}
77
+ end
78
+
79
+ it "doesn't save an identity for a specified identity" do
80
+ auth = NOMS::Command::Auth.new :prompt_input => @input, :prompt_output => @output,
81
+ :force_prompt => true, :specified_identities => ['test/identity']
82
+ ua = NOMS::Command::UserAgent.new 'http://localhost:8787', :auth => auth
83
+ response0, = ua.get 'http://localhost:8787/auth/ok'
84
+ expect(response0.success?).to be_truthy
85
+ expect(File.exist? NOMS::Command::Auth::Identity.vault_keyfile).to be_falsey
86
+ end
87
+
88
+ end
89
+
90
+ end
data/spec/spec_helper.rb CHANGED
@@ -13,6 +13,7 @@ end
13
13
 
14
14
  def setup_fixture(dir='test')
15
15
  system "cp -R fixture #{dir}" unless File.directory? dir
16
+ File.chmod 0600, 'test/identity'
16
17
  end
17
18
 
18
19
  def start_server(dir='test')
@@ -38,3 +39,7 @@ def teardown_fixture(dir='test')
38
39
  FileUtils.rm_r dir
39
40
  end
40
41
  end
42
+
43
+ def get_generated(r)
44
+ Time.httpdate(JSON.parse(r.body)['generated'])
45
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noms-command
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Brinkley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-19 00:00:00.000000000 Z
11
+ date: 2015-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: therubyracer
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: httpclient
42
+ name: typhoeus
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '>='
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: bcrypt
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: bundler
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +136,20 @@ dependencies:
122
136
  - - ~>
123
137
  - !ruby/object:Gem::Version
124
138
  version: '10.0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
125
153
  - !ruby/object:Gem::Dependency
126
154
  name: sinatra
127
155
  requirement: !ruby/object:Gem::Requirement
@@ -159,7 +187,7 @@ files:
159
187
  - fixture/public/files/data.json
160
188
  - fixture/public/files/foo.json
161
189
  - fixture/public/lib/dnc.js
162
- - fixture/public/lib/noms-args.js
190
+ - fixture/public/lib/nomsargs.js
163
191
  - fixture/public/lib/showopt.js
164
192
  - fixture/public/location.json
165
193
  - fixture/public/showopt.json
@@ -172,9 +200,17 @@ files:
172
200
  - lib/noms/command/document.rb
173
201
  - lib/noms/command/error.rb
174
202
  - lib/noms/command/formatter.rb
203
+ - lib/noms/command/home.rb
175
204
  - lib/noms/command/urinion.rb
176
205
  - lib/noms/command/urinion/data.rb
177
206
  - lib/noms/command/useragent.rb
207
+ - lib/noms/command/useragent/cache.rb
208
+ - lib/noms/command/useragent/requester.rb
209
+ - lib/noms/command/useragent/requester/httpclient.rb
210
+ - lib/noms/command/useragent/requester/typhoeus.rb
211
+ - lib/noms/command/useragent/response.rb
212
+ - lib/noms/command/useragent/response/httpclient.rb
213
+ - lib/noms/command/useragent/response/typhoeus.rb
178
214
  - lib/noms/command/version.rb
179
215
  - lib/noms/command/window.rb
180
216
  - lib/noms/command/xmlhttprequest.rb
@@ -189,6 +225,9 @@ files:
189
225
  - spec/08xhr_spec.rb
190
226
  - spec/09bookmarks_spec.rb
191
227
  - spec/10auth_spec.rb
228
+ - spec/11useragent_cache_spec.rb
229
+ - spec/12useragent_auth_cookie_spec.rb
230
+ - spec/13useragent_auth_spec.rb
192
231
  - spec/spec_helper.rb
193
232
  homepage: http://github.com/en-jbrinkley/noms-command
194
233
  licenses:
@@ -225,4 +264,7 @@ test_files:
225
264
  - spec/08xhr_spec.rb
226
265
  - spec/09bookmarks_spec.rb
227
266
  - spec/10auth_spec.rb
267
+ - spec/11useragent_cache_spec.rb
268
+ - spec/12useragent_auth_cookie_spec.rb
269
+ - spec/13useragent_auth_spec.rb
228
270
  - spec/spec_helper.rb
@@ -1,13 +0,0 @@
1
- var nomsargs = { };
2
-
3
- (function (self) {
4
- function kwargs() {
5
- var result = { };
6
- for (i = 0; i < arguments.length; i++) {
7
- pair = arguments[i].split("=", 2);
8
- result[pair[0]] = pair[1];
9
- }
10
- return result;
11
- }
12
-
13
- })(nomsargs);