authlete 1.0.22 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +2 -1
  3. data/Makefile +40 -0
  4. data/Rakefile +5 -0
  5. data/authlete.gemspec +2 -2
  6. data/lib/authlete.rb +28 -9
  7. data/lib/authlete/api.rb +153 -322
  8. data/lib/authlete/authentication-server.rb +2 -2
  9. data/lib/authlete/exception.rb +14 -15
  10. data/lib/authlete/model/base.rb +30 -0
  11. data/lib/authlete/model/client-extension.rb +17 -119
  12. data/lib/authlete/model/client.rb +205 -342
  13. data/lib/authlete/model/hashable.rb +13 -33
  14. data/lib/authlete/model/named-uri.rb +13 -74
  15. data/lib/authlete/model/pair.rb +13 -74
  16. data/lib/authlete/model/param-initializer.rb +45 -0
  17. data/lib/authlete/model/property.rb +15 -85
  18. data/lib/authlete/model/request/authentication-callback-request.rb +63 -55
  19. data/lib/authlete/model/request/authorization-fail-request.rb +14 -75
  20. data/lib/authlete/model/request/authorization-issue-request.rb +38 -119
  21. data/lib/authlete/model/request/authorization-request.rb +8 -73
  22. data/lib/authlete/model/request/backchannel-authentication-complete-request.rb +97 -0
  23. data/lib/authlete/model/request/backchannel-authentication-fail-request.rb +55 -0
  24. data/lib/authlete/model/request/backchannel-authentication-issue-request.rb +37 -0
  25. data/lib/authlete/model/request/backchannel-authentication-request.rb +63 -0
  26. data/lib/authlete/model/request/base.rb +26 -0
  27. data/lib/authlete/model/request/client-authorization-delete-request.rb +7 -93
  28. data/lib/authlete/model/request/client-authorization-get-list-request.rb +17 -89
  29. data/lib/authlete/model/request/client-authorization-update-request.rb +11 -86
  30. data/lib/authlete/model/request/client-registration-request.rb +49 -0
  31. data/lib/authlete/model/request/client-secret-update-request.rb +7 -89
  32. data/lib/authlete/model/request/developer-authentication-callback-request.rb +40 -43
  33. data/lib/authlete/model/request/device-authorization-request.rb +63 -0
  34. data/lib/authlete/model/request/device-complete-request.rb +99 -0
  35. data/lib/authlete/model/request/device-verification-request.rb +40 -0
  36. data/lib/authlete/model/request/granted-scopes-request.rb +8 -74
  37. data/lib/authlete/model/request/introspection-request.rb +24 -83
  38. data/lib/authlete/model/request/pushed-auth-req-request.rb +64 -0
  39. data/lib/authlete/model/request/revocation-request.rb +14 -88
  40. data/lib/authlete/model/request/standard-introspection-request.rb +8 -73
  41. data/lib/authlete/model/request/token-create-request.rb +52 -183
  42. data/lib/authlete/model/request/token-fail-request.rb +12 -74
  43. data/lib/authlete/model/request/token-issue-request.rb +22 -80
  44. data/lib/authlete/model/request/token-request.rb +44 -81
  45. data/lib/authlete/model/request/token-update-request.rb +35 -121
  46. data/lib/authlete/model/request/user-info-issue-request.rb +14 -80
  47. data/lib/authlete/model/request/user-info-request.rb +25 -70
  48. data/lib/authlete/model/response/access-token.rb +96 -0
  49. data/lib/authlete/model/response/authentication-callback-response.rb +24 -19
  50. data/lib/authlete/model/response/authorization-fail-response.rb +13 -15
  51. data/lib/authlete/model/response/authorization-issue-response.rb +29 -32
  52. data/lib/authlete/model/response/authorization-response.rb +97 -123
  53. data/lib/authlete/model/response/authorized-client-list-response.rb +37 -0
  54. data/lib/authlete/model/response/backchannel-authentication-complete-response.rb +143 -0
  55. data/lib/authlete/model/response/backchannel-authentication-fail-response.rb +47 -0
  56. data/lib/authlete/model/response/backchannel-authentication-issue-response.rb +63 -0
  57. data/lib/authlete/model/response/backchannel-authentication-response.rb +160 -0
  58. data/lib/authlete/model/response/client-list-response.rb +58 -0
  59. data/lib/authlete/model/response/client-registration-response.rb +50 -0
  60. data/lib/authlete/model/response/client-secret-refresh-response.rb +12 -12
  61. data/lib/authlete/model/response/client-secret-update-response.rb +12 -12
  62. data/lib/authlete/model/response/developer-authentication-callback-response.rb +24 -19
  63. data/lib/authlete/model/response/device-authorization-response.rb +134 -0
  64. data/lib/authlete/model/response/device-complete-response.rb +39 -0
  65. data/lib/authlete/model/response/device-verification-response.rb +96 -0
  66. data/lib/authlete/model/response/granted-scopes-get-response.rb +27 -19
  67. data/lib/authlete/model/response/introspection-response.rb +64 -58
  68. data/lib/authlete/model/response/pushed-auth-req-response.rb +59 -0
  69. data/lib/authlete/model/response/revocation-response.rb +12 -15
  70. data/lib/authlete/model/response/service-list-response.rb +54 -0
  71. data/lib/authlete/model/response/standard-introspection-response.rb +13 -15
  72. data/lib/authlete/model/response/token-create-response.rb +50 -55
  73. data/lib/authlete/model/response/token-fail-response.rb +14 -17
  74. data/lib/authlete/model/response/token-issue-response.rb +49 -62
  75. data/lib/authlete/model/response/token-list-response.rb +64 -0
  76. data/lib/authlete/model/response/token-response.rb +59 -79
  77. data/lib/authlete/model/response/token-update-response.rb +28 -23
  78. data/lib/authlete/model/response/user-info-issue-response.rb +16 -16
  79. data/lib/authlete/model/response/user-info-response.rb +48 -42
  80. data/lib/authlete/model/result.rb +14 -13
  81. data/lib/authlete/model/scope.rb +29 -119
  82. data/lib/authlete/model/service-owner.rb +32 -116
  83. data/lib/authlete/model/service.rb +491 -666
  84. data/lib/authlete/model/sns-credentials.rb +18 -91
  85. data/lib/authlete/model/tagged-value.rb +14 -69
  86. data/lib/authlete/utility.rb +3 -32
  87. data/lib/authlete/version.rb +3 -3
  88. data/test/authlete/model/request/test_authentication-callback-request.rb +100 -0
  89. data/test/authlete/model/request/test_authorization-fail-request.rb +67 -0
  90. data/test/authlete/model/request/test_authorization-issue-request.rb +94 -0
  91. data/test/authlete/model/request/test_authorization-request.rb +57 -0
  92. data/test/authlete/model/request/test_backchannel-authentication-complete-request.rb +102 -0
  93. data/test/authlete/model/request/test_backchannel-authentication-fail-request.rb +71 -0
  94. data/test/authlete/model/request/test_backchannel-authentication-issue-request.rb +57 -0
  95. data/test/authlete/model/request/test_backchannel-authentication-request.rb +75 -0
  96. data/test/authlete/model/request/test_client-authorization-delete-request.rb +57 -0
  97. data/test/authlete/model/request/test_client-authorization-get-list-request.rb +71 -0
  98. data/test/authlete/model/request/test_client-authorization-update-request.rb +63 -0
  99. data/test/authlete/model/request/test_client-registration-request.rb +68 -0
  100. data/test/authlete/model/request/test_device-authorization-request.rb +75 -0
  101. data/test/authlete/model/request/test_device-complete-request.rb +102 -0
  102. data/test/authlete/model/request/test_device-verification-request.rb +57 -0
  103. data/test/authlete/model/request/test_granted-scopes-request.rb +57 -0
  104. data/test/authlete/model/request/test_introspection-request.rb +79 -0
  105. data/test/authlete/model/request/test_pushed-auth-req-request.rb +75 -0
  106. data/test/authlete/model/request/test_revocation-request.rb +67 -0
  107. data/test/authlete/model/request/test_standard-introspection-request.rb +57 -0
  108. data/test/authlete/model/request/test_token-create-request.rb +110 -0
  109. data/test/authlete/model/request/test_token-fail-request.rb +63 -0
  110. data/test/authlete/model/request/test_token-issue-request.rb +70 -0
  111. data/test/authlete/model/request/test_token-request.rb +94 -0
  112. data/test/authlete/model/request/test_token-update-request.rb +82 -0
  113. data/test/authlete/model/request/test_user-info-issue-request.rb +67 -0
  114. data/test/authlete/model/request/test_user-info-request.rb +75 -0
  115. data/test/authlete/model/response/test_access-token.rb +101 -0
  116. data/test/authlete/model/response/test_authorization-fail-response.rb +68 -0
  117. data/test/authlete/model/response/test_authorization-issue-response.rb +92 -0
  118. data/test/authlete/model/response/test_authorization-response.rb +145 -0
  119. data/test/authlete/model/response/test_authorized-client-list-response.rb +83 -0
  120. data/test/authlete/model/response/test_backchannel-authentication-complete-response.rb +132 -0
  121. data/test/authlete/model/response/test_backchannel-authentication-fail-response.rb +68 -0
  122. data/test/authlete/model/response/test_backchannel-authentication-issue-response.rb +80 -0
  123. data/test/authlete/model/response/test_backchannel-authentication-response.rb +156 -0
  124. data/test/authlete/model/response/test_client-list-response.rb +79 -0
  125. data/test/authlete/model/response/test_client-secret-refresh-response.rb +68 -0
  126. data/test/authlete/model/response/test_client-secret-update-response.rb +68 -0
  127. data/test/authlete/model/response/test_device-authorization-response.rb +140 -0
  128. data/test/authlete/model/response/test_device-complete-response.rb +64 -0
  129. data/test/authlete/model/response/test_device-verification-response.rb +112 -0
  130. data/test/authlete/model/response/test_granted-scopes-get-response.rb +84 -0
  131. data/test/authlete/model/response/test_introspection-response.rb +127 -0
  132. data/test/authlete/model/response/test_pushed-auth-req-response.rb +76 -0
  133. data/test/authlete/model/response/test_revocation-response.rb +68 -0
  134. data/test/authlete/model/response/test_service-list-response.rb +72 -0
  135. data/test/authlete/model/response/test_standard-introspection-response.rb +68 -0
  136. data/test/authlete/model/response/test_token-create-response.rb +107 -0
  137. data/test/authlete/model/response/test_token-fail-response.rb +68 -0
  138. data/test/authlete/model/response/test_token-issue-response.rb +127 -0
  139. data/test/authlete/model/response/test_token-list-response.rb +84 -0
  140. data/test/authlete/model/response/test_token-response.rb +147 -0
  141. data/test/authlete/model/response/test_token-update-response.rb +87 -0
  142. data/test/authlete/model/response/test_user-info-issue-response.rb +68 -0
  143. data/test/authlete/model/response/test_user-info-response.rb +107 -0
  144. data/test/authlete/model/test_client-extension.rb +93 -0
  145. data/test/authlete/model/test_client.rb +469 -0
  146. data/test/authlete/model/test_named-uri.rb +83 -0
  147. data/test/authlete/model/test_pair.rb +83 -0
  148. data/test/authlete/model/test_property.rb +88 -0
  149. data/test/authlete/model/test_result.rb +68 -0
  150. data/test/authlete/model/test_scope.rb +104 -0
  151. data/test/authlete/model/test_service-owner.rb +80 -0
  152. data/test/authlete/model/test_service.rb +630 -0
  153. data/test/authlete/model/test_sns-credentials.rb +88 -0
  154. data/test/authlete/model/test_tagged-value.rb +83 -0
  155. data/test/authlete/test_exception.rb +70 -0
  156. metadata +173 -12
  157. data/lib/authlete/model/client-list.rb +0 -129
  158. data/lib/authlete/model/response/client-authorization-get-list-response.rb +0 -60
  159. data/lib/authlete/model/response/service-creatable-response.rb +0 -51
  160. data/lib/authlete/model/service-list.rb +0 -128
@@ -1,6 +1,6 @@
1
1
  # :nodoc:
2
2
  #
3
- # Copyright (C) 2014-2018 Authlete, Inc.
3
+ # Copyright (C) 2014-2020 Authlete, Inc.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -15,110 +15,37 @@
15
15
  # limitations under the License.
16
16
 
17
17
 
18
- require 'set'
19
-
20
-
21
18
  module Authlete
22
19
  module Model
23
- class SnsCredentials < Authlete::Model::Hashable
24
- # The API key. (String)
20
+ class SnsCredentials < Authlete::Model::Base
21
+ include Authlete::Model::Hashable
22
+ include Authlete::Utility
23
+
24
+ attr_accessor :sns
25
+
25
26
  attr_accessor :apiKey
26
27
  alias_method :api_key, :apiKey
27
28
  alias_method :api_key=, :apiKey=
28
29
 
29
- # The API secret. (String)
30
30
  attr_accessor :apiSecret
31
31
  alias_method :api_secret, :apiSecret
32
32
  alias_method :api_secret=, :apiSecret=
33
33
 
34
- # The SNS. (String)
35
- #
36
- # Currently, the only valid value is "FACEBOOK".
37
- attr_accessor :sns
38
-
39
34
  private
40
35
 
41
- # String attributes.
42
- STRING_ATTRIBUTES = ::Set.new([ :apiKey, :apiSecret, :sns ])
43
-
44
- # Mapping from snake cases to camel cases.
45
- SNAKE_TO_CAMEL = {
46
- :api_key => :apiKey,
47
- :api_secret => :apiSecret
48
- }
49
-
50
- # The constructor.
51
- def initialize(hash = nil)
52
- # Set default values to string attributes.
53
- STRING_ATTRIBUTES.each do |attr|
54
- send("#{attr}=", nil)
55
- end
56
-
57
- # Set attribute values using the given hash.
58
- authlete_model_update(hash)
59
- end
60
-
61
- def authlete_model_convert_key(key)
62
- key = key.to_sym
63
-
64
- # Convert snakecase to camelcase, if necessary.
65
- if SNAKE_TO_CAMEL.has_key?(key)
66
- key = SNAKE_TO_CAMEL[key]
67
- end
68
-
69
- key
70
- end
71
-
72
- def authlete_model_simple_attribute?(key)
73
- STRING_ATTRIBUTES.include?(key)
74
- end
75
-
76
- def authlete_model_update(hash)
77
- return if hash.nil?
78
-
79
- hash.each do |key, value|
80
- key = authlete_model_convert_key(key)
81
-
82
- if authlete_model_simple_attribute?(key)
83
- send("#{key}=", value)
84
- end
85
- end
86
-
87
- self
36
+ def defaults
37
+ {
38
+ sns: nil,
39
+ apiKey: nil,
40
+ apiSecret: nil
41
+ }
88
42
  end
89
43
 
90
- public
91
-
92
- # Construct an instance from the given hash.
93
- #
94
- # If the given argument is nil or is not a Hash, nil is returned.
95
- # Otherwise, SnsCredentials.new(hash) is returned.
96
- def self.parse(hash)
97
- if hash.nil? or (hash.kind_of?(Hash) == false)
98
- return nil
99
- end
100
-
101
- Authlete::Model::SnsCredentials.new(hash)
102
- end
103
-
104
- # Set attribute values using the given hash.
105
- def update(hash)
106
- authlete_model_update(hash)
107
- end
108
-
109
- # Convert this object into a hash.
110
- def to_hash
111
- hash = {}
112
-
113
- instance_variables.each do |var|
114
- key = var.to_s.delete("@").to_sym
115
- val = instance_variable_get(var)
116
-
117
- hash[key] = val
118
- end
119
-
120
- hash
44
+ def set_params(hash)
45
+ @sns = hash[:sns]
46
+ @apiKey = hash[:apiKey]
47
+ @apiSecret = hash[:apiSecret]
121
48
  end
122
49
  end
123
50
  end
124
- end
51
+ end
@@ -1,6 +1,6 @@
1
1
  # :nodoc:
2
2
  #
3
- # Copyright (C) 2014-2018 Authlete, Inc.
3
+ # Copyright (C) 2014-2020 Authlete, Inc.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -15,84 +15,29 @@
15
15
  # limitations under the License.
16
16
 
17
17
 
18
- require 'set'
19
-
20
-
21
18
  module Authlete
22
19
  module Model
23
- class TaggedValue < Authlete::Model::Hashable
24
- # The language tag part. (String)
20
+ class TaggedValue < Authlete::Model::Base
21
+ include Authlete::Model::Hashable
22
+ include Authlete::Utility
23
+
25
24
  attr_accessor :tag
26
25
 
27
- # The value part. (String)
28
26
  attr_accessor :value
29
27
 
30
28
  private
31
29
 
32
- # String attributes.
33
- STRING_ATTRIBUTES = ::Set.new([ :tag, :value ])
34
-
35
- # The constructor
36
- def initialize(hash = nil)
37
- # Set default values to string attributes.
38
- STRING_ATTRIBUTES.each do |attr|
39
- send("#{attr}=", nil)
40
- end
41
-
42
- # Set attribute values using the given hash.
43
- authlete_model_update(hash)
30
+ def defaults
31
+ {
32
+ tag: nil,
33
+ value: nil
34
+ }
44
35
  end
45
36
 
46
- def authlete_model_convert_key(key)
47
- key.to_sym
48
- end
49
-
50
- def authlete_model_simple_attribute?(key)
51
- STRING_ATTRIBUTES.include?(key)
52
- end
53
-
54
- def authlete_model_update(hash)
55
- return if hash.nil?
56
-
57
- hash.each do |key, value|
58
- key = authlete_model_convert_key(key)
59
-
60
- # If the attribute is a simple one.
61
- if authlete_model_simple_attribute?(key)
62
- send("#{key}=", value)
63
- end
64
- end
65
-
66
- self
67
- end
68
-
69
- public
70
-
71
- # Construct an instance from the given hash.
72
- #
73
- # If the given argument is nil or is not a Hash, nil is returned.
74
- # Otherwise, TaggedValue.new(hash) is returned.
75
- def self.parse(hash)
76
- if hash.nil? or (hash.kind_of?(Hash) == false)
77
- return nil
78
- end
79
-
80
- Authlete::Model::TaggedValue.new(hash)
81
- end
82
-
83
- # Convert this object into a hash.
84
- def to_hash
85
- hash = {}
86
-
87
- instance_variables.each do |var|
88
- key = var.to_s.delete("@").to_sym
89
- val = instance_variable_get(var)
90
-
91
- hash[key] = val
92
- end
93
-
94
- hash
37
+ def set_params(hash)
38
+ @tag = hash[:tag]
39
+ @value = hash[:value]
95
40
  end
96
41
  end
97
42
  end
98
- end
43
+ end
@@ -1,6 +1,6 @@
1
1
  # :nodoc:
2
2
  #
3
- # Copyright (C) 2014-2018 Authlete, Inc.
3
+ # Copyright (C) 2014-2020 Authlete, Inc.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -17,33 +17,6 @@
17
17
 
18
18
  module Authlete
19
19
  module Utility
20
- def extract_value(hash, key)
21
- if hash.has_key?(key)
22
- hash[key]
23
- else
24
- hash[key.to_s]
25
- end
26
- end
27
-
28
- def extract_integer_value(hash, key)
29
- extract_value(hash, key).to_i
30
- end
31
-
32
- def extract_boolean_value(hash, key)
33
- value = extract_value(hash, key)
34
- (value == true || value == 'true')
35
- end
36
-
37
- def extract_array_value(hash, key)
38
- array = extract_value(hash, key)
39
-
40
- # Parse each of the elements in the array.
41
- # Then, put them into an array.
42
- get_parsed_array(array) do |element|
43
- yield(element)
44
- end
45
- end
46
-
47
20
  # Extract an access token (RFC 6750)
48
21
  def extract_access_token(request)
49
22
  header = request.env['HTTP_AUTHORIZATION']
@@ -56,9 +29,7 @@ module Authlete
56
29
  end
57
30
 
58
31
  def get_parsed_array(array)
59
- if array.nil? or (array.kind_of?(Array) == false) or (array.empty?)
60
- return nil
61
- end
32
+ return nil if !array.kind_of?(Array) or array.empty?
62
33
 
63
34
  elements = []
64
35
 
@@ -96,4 +67,4 @@ module Authlete
96
67
  ]
97
68
  end
98
69
  end
99
- end
70
+ end
@@ -1,6 +1,6 @@
1
1
  # :nodoc:
2
2
  #
3
- # Copyright (C) 2014-2019 Authlete, Inc.
3
+ # Copyright (C) 2014-2020 Authlete, Inc.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -16,5 +16,5 @@
16
16
 
17
17
 
18
18
  module Authlete
19
- VERSION = "1.0.22"
20
- end
19
+ VERSION = "1.3.0"
20
+ end
@@ -0,0 +1,100 @@
1
+ # :nodoc:
2
+ #
3
+ # Copyright (C) 2014-2020 Authlete, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+
18
+ require 'authlete'
19
+ require 'minitest/autorun'
20
+
21
+
22
+ class AuthenticationCallbackRequestTest < Minitest::Test
23
+ SERVICE_API_KEY = '<service-api-key>'
24
+ CLIENT_ID = 12345
25
+ ID = '<id>'
26
+ PASSWORD = '<password>'
27
+ CLAIMS = [ 'claim0', 'claim1' ]
28
+ CLAIMS_LOCALES = [ 'en', 'ja' ]
29
+ SNS = 'FACEBOOK'
30
+ ACCESS_TOKEN = '<access-token>'
31
+ REFRESH_TOKEN = '<refresh-token>'
32
+ EXPIRES_IN = 30000
33
+ RAW_TOKEN_RESPONSE = '<raw-token-response>'
34
+
35
+
36
+ def set_params(obj)
37
+ obj.service_api_key = SERVICE_API_KEY
38
+ obj.client_id = CLIENT_ID
39
+ obj.id = ID
40
+ obj.password = PASSWORD
41
+ obj.claims = CLAIMS
42
+ obj.claims_locales = CLAIMS_LOCALES
43
+ obj.sns = SNS
44
+ obj.access_token = ACCESS_TOKEN
45
+ obj.refresh_token = REFRESH_TOKEN
46
+ obj.expires_in = EXPIRES_IN
47
+ obj.raw_token_response = RAW_TOKEN_RESPONSE
48
+ end
49
+
50
+
51
+ def match(obj)
52
+ assert_equal SERVICE_API_KEY, obj.serviceApiKey
53
+ assert_equal CLIENT_ID, obj.clientId
54
+ assert_equal ID, obj.id
55
+ assert_equal PASSWORD, obj.password
56
+ assert_equal CLAIMS, obj.claims
57
+ assert_equal CLAIMS_LOCALES, obj.claimsLocales
58
+ assert_equal SNS, obj.sns
59
+ assert_equal ACCESS_TOKEN, obj.accessToken
60
+ assert_equal REFRESH_TOKEN, obj.refreshToken
61
+ assert_equal EXPIRES_IN, obj.expiresIn
62
+ assert_equal RAW_TOKEN_RESPONSE, obj.rawTokenResponse
63
+ end
64
+
65
+
66
+ def generate_hash
67
+ {
68
+ serviceApiKey: '<service-api-key>',
69
+ clientId: 12345,
70
+ id: '<id>',
71
+ password: '<password>',
72
+ claims: [ 'claim0', 'claim1' ],
73
+ claimsLocales: [ 'en', 'ja' ],
74
+ sns: 'FACEBOOK',
75
+ accessToken: '<access-token>',
76
+ refreshToken: '<refresh-token>',
77
+ expiresIn: 30000,
78
+ rawTokenResponse: '<raw-token-response>'
79
+ }
80
+ end
81
+
82
+
83
+ def test_setters
84
+ actual = Authlete::Model::Request::AuthenticationCallbackRequest.new
85
+ set_params(actual)
86
+
87
+ match(actual)
88
+ end
89
+
90
+
91
+ def test_to_hash
92
+ obj = Authlete::Model::Request::AuthenticationCallbackRequest.new
93
+ set_params(obj)
94
+ actual = obj.to_hash
95
+ expected = generate_hash
96
+
97
+ assert_equal expected, actual
98
+ end
99
+ end
100
+
@@ -0,0 +1,67 @@
1
+ # :nodoc:
2
+ #
3
+ # Copyright (C) 2014-2020 Authlete, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+
18
+ require 'authlete'
19
+ require 'minitest/autorun'
20
+
21
+
22
+ class AuthorizationFailRequestTest < Minitest::Test
23
+ TICKET = '<ticket>'
24
+ REASON = 'DENIED'
25
+ DESCRIPTION = '<description>'
26
+
27
+
28
+ def set_params(obj)
29
+ obj.ticket = TICKET
30
+ obj.reason = REASON
31
+ obj.description = DESCRIPTION
32
+ end
33
+
34
+
35
+ def match(obj)
36
+ assert_equal TICKET, obj.ticket
37
+ assert_equal REASON, obj.reason
38
+ assert_equal DESCRIPTION, obj.description
39
+ end
40
+
41
+
42
+ def generate_hash
43
+ {
44
+ ticket: '<ticket>',
45
+ reason: 'DENIED',
46
+ description: '<description>'
47
+ }
48
+ end
49
+
50
+
51
+ def test_setters
52
+ actual = Authlete::Model::Request::AuthorizationFailRequest.new
53
+ set_params(actual)
54
+
55
+ match(actual)
56
+ end
57
+
58
+
59
+ def test_to_hash
60
+ obj = Authlete::Model::Request::AuthorizationFailRequest.new
61
+ set_params(obj)
62
+ actual = obj.to_hash
63
+ expected = generate_hash
64
+
65
+ assert_equal expected, actual
66
+ end
67
+ end