haveapi 0.16.3 → 0.17.0

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
  SHA256:
3
- metadata.gz: ece538baf23fb6e02ef9ad1063930cc7b973e94fc530e4f96fa87f0e19ecd269
4
- data.tar.gz: 73b6713727754b11ce89e3c61017b4374ced36f50c740c9594f757d11685e640
3
+ metadata.gz: 4799af18ce8de3147686153493e32210e780c650bdcec3e18f5ff714da50ee03
4
+ data.tar.gz: 4cfe8ff071d7d4ea6adcb28e25ab0d491008e9402058c34293bdf70881bf13e2
5
5
  SHA512:
6
- metadata.gz: 6db1b965c6fac2ad2669709397e81d028e2e9828707dc6727b65b70cf0ceea5d8c8d38be82659a6c959687336529345b873c6fe2f81b779b83f96a86fe27c5c9
7
- data.tar.gz: a6e64201797808898c504837f4f867bb0f017735e1b6f5558414026e78fb637089482e1479525ba7d1f1885d3c72eb3f165239b3acc1d164de702ef8762c26f1
6
+ metadata.gz: 936f0c86ff2b766339c3dbc08d49c2ae46868002733124dad9987ad932f9232807160a6a36777fc6fe45b952682e89bf9b0a5856939d6a7a1775e94e9d8ffe4c
7
+ data.tar.gz: 3527985845485151a532aa42ce235eed35827f8d9f6a2aa053b208e7621ce4d93f578cd531f06aec8bcc27ecd1079c8023b7fc63f29bf36d4b6e38807121f0f6
data/haveapi.gemspec CHANGED
@@ -16,13 +16,13 @@ Gem::Specification.new do |s|
16
16
 
17
17
  s.add_runtime_dependency 'require_all', '~> 2.0.0'
18
18
  s.add_runtime_dependency 'json'
19
- s.add_runtime_dependency 'activesupport', '>= 6.0'
20
- s.add_runtime_dependency 'sinatra', '~> 3.0.4'
21
- s.add_runtime_dependency 'tilt', '~> 2.0.10'
22
- s.add_runtime_dependency 'redcarpet', '~> 3.5'
19
+ s.add_runtime_dependency 'activesupport', '>= 7.0'
20
+ s.add_runtime_dependency 'sinatra', '~> 3.1.0'
21
+ s.add_runtime_dependency 'tilt', '~> 2.3.0'
22
+ s.add_runtime_dependency 'redcarpet', '~> 3.6'
23
23
  s.add_runtime_dependency 'rake'
24
24
  s.add_runtime_dependency 'github-markdown'
25
25
  s.add_runtime_dependency 'nesty', '~> 1.0'
26
- s.add_runtime_dependency 'haveapi-client', '~> 0.16.3'
26
+ s.add_runtime_dependency 'haveapi-client', '~> 0.17.0'
27
27
  s.add_runtime_dependency 'mail'
28
28
  end
@@ -79,5 +79,28 @@ module HaveAPI
79
79
  def version_url
80
80
  File.join(base_url, "v#{version}", '/')
81
81
  end
82
+
83
+ protected
84
+ # @param password [Boolean] include password parameter
85
+ # @return [Hash<String, String>] parameter => example value
86
+ def auth_token_credentials(desc, password: true)
87
+ passwords = %i(password pass passwd)
88
+ params = desc[:resources][:token][:actions]['request'][:input][:parameters].keys - %i(lifetime interval)
89
+
90
+ unless password
91
+ params.reject! { |param| passwords.include?(param) }
92
+ end
93
+
94
+ Hash[params.map do |param|
95
+ value =
96
+ if passwords.include?(param)
97
+ 'secret'
98
+ else
99
+ param
100
+ end
101
+
102
+ [param, value]
103
+ end]
104
+ end
82
105
  end
83
106
  end
@@ -12,8 +12,6 @@ module HaveAPI::ClientExamples
12
12
  end
13
13
 
14
14
  def auth(method, desc)
15
- login = {user: 'user', password: 'password', lifetime: 'fixed'}
16
-
17
15
  case method
18
16
  when :basic
19
17
  <<END
@@ -30,6 +28,8 @@ $ curl --request OPTIONS \\
30
28
  END
31
29
 
32
30
  when :token
31
+ login = auth_token_credentials(desc).merge(lifetime: 'fixed')
32
+
33
33
  <<END
34
34
  # Acquire the token
35
35
  $ curl --request POST \\
@@ -28,12 +28,14 @@ Authorization: Basic dXNlcjpzZWNyZXQ=
28
28
  END
29
29
 
30
30
  when :token
31
+ login = auth_token_credentials(desc).merge(lifetime: 'fixed')
32
+
31
33
  <<END
32
34
  POST /_auth/token/tokens HTTP/1.1
33
35
  Host: #{host}
34
36
  Content-Type: application/json
35
37
 
36
- #{JSON.pretty_generate({token: {user: 'user', password: 'secret', lifetime: 'fixed'}})}
38
+ #{JSON.pretty_generate({token: login})}
37
39
  END
38
40
  end
39
41
  end
@@ -21,7 +21,7 @@ END
21
21
  #{init}
22
22
 
23
23
  api.authenticate("basic", {
24
- username: "user",
24
+ user: "user",
25
25
  password: "secret"
26
26
  }, function (client, status) {
27
27
  console.log("Authenticated?", status);
@@ -34,8 +34,7 @@ END
34
34
 
35
35
  // Request a new token
36
36
  api.authenticate("token", {
37
- username: "user",
38
- password: "secret"
37
+ #{auth_token_credentials(desc).map { |k, v| "#{k}: \"#{v}\"" }.join(",\n ")}
39
38
  }, function (client, status) {
40
39
  console.log("Authenticated?", status);
41
40
 
@@ -18,7 +18,7 @@ END
18
18
  <<END
19
19
  #{init}
20
20
 
21
- $api->authenticate("basic", ["username" => "user", "password" => "secret"]);
21
+ $api->authenticate("basic", ["user" => "user", "password" => "secret"]);
22
22
  END
23
23
 
24
24
  when :token
@@ -26,7 +26,7 @@ END
26
26
  #{init}
27
27
 
28
28
  // Get token using username and password
29
- $api->authenticate("token", ["username" => "user", "password" => "secret"]);
29
+ $api->authenticate("token", [#{auth_token_credentials(desc).map { |k, v| "\"#{k}\" => \"#{v}\"" }.join(', ')}]);
30
30
 
31
31
  echo "Token = ".$api->getAuthenticationProvider()->getToken();
32
32
 
@@ -20,10 +20,10 @@ module HaveAPI::ClientExamples
20
20
  when :basic
21
21
  <<END
22
22
  # Provide credentials on command line
23
- #{init} --auth basic --username user --password secret
23
+ #{init} --auth basic --user user --password secret
24
24
 
25
25
  # If username or password isn't provided, the user is asked on stdin
26
- #{init} --auth basic --username user
26
+ #{init} --auth basic --user user
27
27
  Password: secret
28
28
  END
29
29
 
@@ -33,7 +33,7 @@ END
33
33
  # Note that the client always has to call some action. APIs should provide
34
34
  # an action to get information about the current user, so that's what we're
35
35
  # calling now.
36
- #{init} --auth token --username user --save user current
36
+ #{init} --auth token #{auth_token_credentials(desc, password: false).map { |k, v| "--#{k} #{v}" }.join(' ')} --save user current
37
37
  Password: secret
38
38
 
39
39
  # Now the token is read from disk and the user does not have to provide username
@@ -21,7 +21,7 @@ END
21
21
  <<END
22
22
  #{init}
23
23
 
24
- client.authenticate(:basic, username: "user", password: "secret")
24
+ client.authenticate(:basic, user: "user", password: "secret")
25
25
  END
26
26
 
27
27
  when :token
@@ -29,7 +29,7 @@ END
29
29
  #{init}
30
30
 
31
31
  # Get token using username and password
32
- client.authenticate(:token, username: "user", password: "secret")
32
+ client.authenticate(:token, #{auth_token_credentials(desc).map { |k, v| "#{k}: \"#{v}\"" }.join(', ')})
33
33
 
34
34
  puts "Token = \#{client.auth.token}"
35
35
 
@@ -1,4 +1,4 @@
1
1
  module HaveAPI
2
2
  PROTOCOL_VERSION = '2.0'
3
- VERSION = '0.16.3'
3
+ VERSION = '0.17.0'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haveapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.3
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakub Skokan
@@ -44,56 +44,56 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '6.0'
47
+ version: '7.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '6.0'
54
+ version: '7.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: sinatra
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 3.0.4
61
+ version: 3.1.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 3.0.4
68
+ version: 3.1.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: tilt
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 2.0.10
75
+ version: 2.3.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 2.0.10
82
+ version: 2.3.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: redcarpet
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '3.5'
89
+ version: '3.6'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '3.5'
96
+ version: '3.6'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 0.16.3
145
+ version: 0.17.0
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 0.16.3
152
+ version: 0.17.0
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: mail
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -315,7 +315,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
315
315
  - !ruby/object:Gem::Version
316
316
  version: '0'
317
317
  requirements: []
318
- rubygems_version: 3.3.20
318
+ rubygems_version: 3.4.13
319
319
  signing_key:
320
320
  specification_version: 4
321
321
  summary: Framework for creating self-describing APIs