authlete 1.0.21 → 1.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.
Files changed (161) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/Makefile +40 -0
  4. data/README.md +20 -20
  5. data/Rakefile +5 -0
  6. data/authlete.gemspec +2 -2
  7. data/lib/authlete.rb +28 -9
  8. data/lib/authlete/api.rb +153 -322
  9. data/lib/authlete/authentication-server.rb +230 -230
  10. data/lib/authlete/exception.rb +14 -15
  11. data/lib/authlete/model/base.rb +30 -0
  12. data/lib/authlete/model/client-extension.rb +17 -119
  13. data/lib/authlete/model/client.rb +203 -338
  14. data/lib/authlete/model/hashable.rb +13 -33
  15. data/lib/authlete/model/named-uri.rb +13 -74
  16. data/lib/authlete/model/pair.rb +13 -74
  17. data/lib/authlete/model/param-initializer.rb +45 -0
  18. data/lib/authlete/model/property.rb +15 -85
  19. data/lib/authlete/model/request/authentication-callback-request.rb +63 -55
  20. data/lib/authlete/model/request/authorization-fail-request.rb +14 -75
  21. data/lib/authlete/model/request/authorization-issue-request.rb +38 -119
  22. data/lib/authlete/model/request/authorization-request.rb +8 -73
  23. data/lib/authlete/model/request/backchannel-authentication-complete-request.rb +97 -0
  24. data/lib/authlete/model/request/backchannel-authentication-fail-request.rb +55 -0
  25. data/lib/authlete/model/request/backchannel-authentication-issue-request.rb +37 -0
  26. data/lib/authlete/model/request/backchannel-authentication-request.rb +63 -0
  27. data/lib/authlete/model/request/base.rb +26 -0
  28. data/lib/authlete/model/request/client-authorization-delete-request.rb +7 -93
  29. data/lib/authlete/model/request/client-authorization-get-list-request.rb +17 -89
  30. data/lib/authlete/model/request/client-authorization-update-request.rb +11 -86
  31. data/lib/authlete/model/request/client-registration-request.rb +49 -0
  32. data/lib/authlete/model/request/client-secret-update-request.rb +7 -89
  33. data/lib/authlete/model/request/developer-authentication-callback-request.rb +40 -43
  34. data/lib/authlete/model/request/device-authorization-request.rb +63 -0
  35. data/lib/authlete/model/request/device-complete-request.rb +99 -0
  36. data/lib/authlete/model/request/device-verification-request.rb +40 -0
  37. data/lib/authlete/model/request/granted-scopes-request.rb +8 -74
  38. data/lib/authlete/model/request/introspection-request.rb +24 -83
  39. data/lib/authlete/model/request/pushed-auth-req-request.rb +64 -0
  40. data/lib/authlete/model/request/revocation-request.rb +14 -88
  41. data/lib/authlete/model/request/standard-introspection-request.rb +8 -73
  42. data/lib/authlete/model/request/token-create-request.rb +52 -183
  43. data/lib/authlete/model/request/token-fail-request.rb +12 -74
  44. data/lib/authlete/model/request/token-issue-request.rb +22 -80
  45. data/lib/authlete/model/request/token-request.rb +44 -81
  46. data/lib/authlete/model/request/token-update-request.rb +35 -121
  47. data/lib/authlete/model/request/user-info-issue-request.rb +14 -80
  48. data/lib/authlete/model/request/user-info-request.rb +25 -70
  49. data/lib/authlete/model/response/access-token.rb +96 -0
  50. data/lib/authlete/model/response/authentication-callback-response.rb +24 -19
  51. data/lib/authlete/model/response/authorization-fail-response.rb +13 -15
  52. data/lib/authlete/model/response/authorization-issue-response.rb +29 -32
  53. data/lib/authlete/model/response/authorization-response.rb +97 -123
  54. data/lib/authlete/model/response/authorized-client-list-response.rb +37 -0
  55. data/lib/authlete/model/response/backchannel-authentication-complete-response.rb +143 -0
  56. data/lib/authlete/model/response/backchannel-authentication-fail-response.rb +47 -0
  57. data/lib/authlete/model/response/backchannel-authentication-issue-response.rb +63 -0
  58. data/lib/authlete/model/response/backchannel-authentication-response.rb +160 -0
  59. data/lib/authlete/model/response/client-list-response.rb +58 -0
  60. data/lib/authlete/model/response/client-registration-response.rb +50 -0
  61. data/lib/authlete/model/response/client-secret-refresh-response.rb +12 -12
  62. data/lib/authlete/model/response/client-secret-update-response.rb +12 -12
  63. data/lib/authlete/model/response/developer-authentication-callback-response.rb +24 -19
  64. data/lib/authlete/model/response/device-authorization-response.rb +134 -0
  65. data/lib/authlete/model/response/device-complete-response.rb +39 -0
  66. data/lib/authlete/model/response/device-verification-response.rb +96 -0
  67. data/lib/authlete/model/response/granted-scopes-get-response.rb +27 -19
  68. data/lib/authlete/model/response/introspection-response.rb +64 -58
  69. data/lib/authlete/model/response/pushed-auth-req-response.rb +59 -0
  70. data/lib/authlete/model/response/revocation-response.rb +12 -15
  71. data/lib/authlete/model/response/service-list-response.rb +54 -0
  72. data/lib/authlete/model/response/standard-introspection-response.rb +13 -15
  73. data/lib/authlete/model/response/token-create-response.rb +50 -55
  74. data/lib/authlete/model/response/token-fail-response.rb +14 -17
  75. data/lib/authlete/model/response/token-issue-response.rb +49 -62
  76. data/lib/authlete/model/response/token-list-response.rb +64 -0
  77. data/lib/authlete/model/response/token-response.rb +59 -79
  78. data/lib/authlete/model/response/token-update-response.rb +28 -23
  79. data/lib/authlete/model/response/user-info-issue-response.rb +16 -16
  80. data/lib/authlete/model/response/user-info-response.rb +48 -42
  81. data/lib/authlete/model/result.rb +14 -13
  82. data/lib/authlete/model/scope.rb +68 -158
  83. data/lib/authlete/model/service-owner.rb +32 -116
  84. data/lib/authlete/model/service.rb +672 -837
  85. data/lib/authlete/model/sns-credentials.rb +51 -124
  86. data/lib/authlete/model/tagged-value.rb +14 -69
  87. data/lib/authlete/utility.rb +70 -99
  88. data/lib/authlete/version.rb +3 -3
  89. data/test/authlete/model/request/test_authentication-callback-request.rb +100 -0
  90. data/test/authlete/model/request/test_authorization-fail-request.rb +67 -0
  91. data/test/authlete/model/request/test_authorization-issue-request.rb +94 -0
  92. data/test/authlete/model/request/test_authorization-request.rb +57 -0
  93. data/test/authlete/model/request/test_backchannel-authentication-complete-request.rb +102 -0
  94. data/test/authlete/model/request/test_backchannel-authentication-fail-request.rb +71 -0
  95. data/test/authlete/model/request/test_backchannel-authentication-issue-request.rb +57 -0
  96. data/test/authlete/model/request/test_backchannel-authentication-request.rb +75 -0
  97. data/test/authlete/model/request/test_client-authorization-delete-request.rb +57 -0
  98. data/test/authlete/model/request/test_client-authorization-get-list-request.rb +71 -0
  99. data/test/authlete/model/request/test_client-authorization-update-request.rb +63 -0
  100. data/test/authlete/model/request/test_client-registration-request.rb +68 -0
  101. data/test/authlete/model/request/test_device-authorization-request.rb +75 -0
  102. data/test/authlete/model/request/test_device-complete-request.rb +102 -0
  103. data/test/authlete/model/request/test_device-verification-request.rb +57 -0
  104. data/test/authlete/model/request/test_granted-scopes-request.rb +57 -0
  105. data/test/authlete/model/request/test_introspection-request.rb +79 -0
  106. data/test/authlete/model/request/test_pushed-auth-req-request.rb +75 -0
  107. data/test/authlete/model/request/test_revocation-request.rb +67 -0
  108. data/test/authlete/model/request/test_standard-introspection-request.rb +57 -0
  109. data/test/authlete/model/request/test_token-create-request.rb +110 -0
  110. data/test/authlete/model/request/test_token-fail-request.rb +63 -0
  111. data/test/authlete/model/request/test_token-issue-request.rb +70 -0
  112. data/test/authlete/model/request/test_token-request.rb +94 -0
  113. data/test/authlete/model/request/test_token-update-request.rb +82 -0
  114. data/test/authlete/model/request/test_user-info-issue-request.rb +67 -0
  115. data/test/authlete/model/request/test_user-info-request.rb +75 -0
  116. data/test/authlete/model/response/test_access-token.rb +101 -0
  117. data/test/authlete/model/response/test_authorization-fail-response.rb +68 -0
  118. data/test/authlete/model/response/test_authorization-issue-response.rb +92 -0
  119. data/test/authlete/model/response/test_authorization-response.rb +145 -0
  120. data/test/authlete/model/response/test_authorized-client-list-response.rb +83 -0
  121. data/test/authlete/model/response/test_backchannel-authentication-complete-response.rb +132 -0
  122. data/test/authlete/model/response/test_backchannel-authentication-fail-response.rb +68 -0
  123. data/test/authlete/model/response/test_backchannel-authentication-issue-response.rb +80 -0
  124. data/test/authlete/model/response/test_backchannel-authentication-response.rb +156 -0
  125. data/test/authlete/model/response/test_client-list-response.rb +79 -0
  126. data/test/authlete/model/response/test_client-secret-refresh-response.rb +68 -0
  127. data/test/authlete/model/response/test_client-secret-update-response.rb +68 -0
  128. data/test/authlete/model/response/test_device-authorization-response.rb +140 -0
  129. data/test/authlete/model/response/test_device-complete-response.rb +64 -0
  130. data/test/authlete/model/response/test_device-verification-response.rb +112 -0
  131. data/test/authlete/model/response/test_granted-scopes-get-response.rb +84 -0
  132. data/test/authlete/model/response/test_introspection-response.rb +127 -0
  133. data/test/authlete/model/response/test_pushed-auth-req-response.rb +76 -0
  134. data/test/authlete/model/response/test_revocation-response.rb +68 -0
  135. data/test/authlete/model/response/test_service-list-response.rb +72 -0
  136. data/test/authlete/model/response/test_standard-introspection-response.rb +68 -0
  137. data/test/authlete/model/response/test_token-create-response.rb +107 -0
  138. data/test/authlete/model/response/test_token-fail-response.rb +68 -0
  139. data/test/authlete/model/response/test_token-issue-response.rb +127 -0
  140. data/test/authlete/model/response/test_token-list-response.rb +84 -0
  141. data/test/authlete/model/response/test_token-response.rb +147 -0
  142. data/test/authlete/model/response/test_token-update-response.rb +87 -0
  143. data/test/authlete/model/response/test_user-info-issue-response.rb +68 -0
  144. data/test/authlete/model/response/test_user-info-response.rb +107 -0
  145. data/test/authlete/model/test_client-extension.rb +95 -0
  146. data/test/authlete/model/test_client.rb +461 -0
  147. data/test/authlete/model/test_named-uri.rb +85 -0
  148. data/test/authlete/model/test_pair.rb +85 -0
  149. data/test/authlete/model/test_property.rb +90 -0
  150. data/test/authlete/model/test_result.rb +68 -0
  151. data/test/authlete/model/test_scope.rb +106 -0
  152. data/test/authlete/model/test_service-owner.rb +80 -0
  153. data/test/authlete/model/test_service.rb +624 -0
  154. data/test/authlete/model/test_sns-credentials.rb +88 -0
  155. data/test/authlete/model/test_tagged-value.rb +83 -0
  156. data/test/authlete/test_exception.rb +70 -0
  157. metadata +173 -13
  158. data/lib/authlete/model/client-list.rb +0 -129
  159. data/lib/authlete/model/response/client-authorization-get-list-response.rb +0 -60
  160. data/lib/authlete/model/response/service-creatable-response.rb +0 -51
  161. data/lib/authlete/model/service-list.rb +0 -128
@@ -0,0 +1,57 @@
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 BackchannelAuthenticationIssueRequestTest < Minitest::Test
23
+ TICKET = '<ticket>'
24
+
25
+
26
+ def set_params(obj)
27
+ obj.ticket = TICKET
28
+ end
29
+
30
+
31
+ def match(obj)
32
+ assert_equal TICKET, obj.ticket
33
+ end
34
+
35
+
36
+ def generate_hash
37
+ { ticket: '<ticket>' }
38
+ end
39
+
40
+
41
+ def test_setters
42
+ actual = Authlete::Model::Request::BackchannelAuthenticationIssueRequest.new
43
+ set_params(actual)
44
+
45
+ match(actual)
46
+ end
47
+
48
+
49
+ def test_to_hash
50
+ obj = Authlete::Model::Request::BackchannelAuthenticationIssueRequest.new
51
+ set_params(obj)
52
+ actual = obj.to_hash
53
+ expected = generate_hash
54
+
55
+ assert_equal expected, actual
56
+ end
57
+ end
@@ -0,0 +1,75 @@
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 BackchannelAuthenticationRequestTest < Minitest::Test
23
+ PARAMETERS = '<parameters>'
24
+ CLIENT_ID = '<client-id>'
25
+ CLIENT_SECRET = '<client-secret>'
26
+ CLIENT_CERTIFICATE = '<client-certificate>'
27
+ CLIENT_CERTIFICATE_PATH = [ 'path0', 'path1' ]
28
+
29
+
30
+ def set_params(obj)
31
+ obj.parameters = PARAMETERS
32
+ obj.client_id = CLIENT_ID
33
+ obj.client_secret = CLIENT_SECRET
34
+ obj.client_certificate = CLIENT_CERTIFICATE
35
+ obj.client_certificate_path = CLIENT_CERTIFICATE_PATH
36
+ end
37
+
38
+
39
+ def match(obj)
40
+ assert_equal PARAMETERS, obj.parameters
41
+ assert_equal CLIENT_ID, obj.clientId
42
+ assert_equal CLIENT_SECRET, obj.clientSecret
43
+ assert_equal CLIENT_CERTIFICATE, obj.clientCertificate
44
+ assert_equal CLIENT_CERTIFICATE_PATH, obj.clientCertificatePath
45
+ end
46
+
47
+
48
+ def generate_hash
49
+ {
50
+ parameters: '<parameters>',
51
+ clientId: '<client-id>',
52
+ clientSecret: '<client-secret>',
53
+ clientCertificate: '<client-certificate>',
54
+ clientCertificatePath: [ 'path0', 'path1' ]
55
+ }
56
+ end
57
+
58
+
59
+ def test_setters
60
+ actual = Authlete::Model::Request::BackchannelAuthenticationRequest.new
61
+ set_params(actual)
62
+
63
+ match(actual)
64
+ end
65
+
66
+
67
+ def test_to_hash
68
+ obj = Authlete::Model::Request::BackchannelAuthenticationRequest.new
69
+ set_params(obj)
70
+ actual = obj.to_hash
71
+ expected = generate_hash
72
+
73
+ assert_equal expected, actual
74
+ end
75
+ end
@@ -0,0 +1,57 @@
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 ClientAuthorizationDeleteRequestTest < Minitest::Test
23
+ SUBJECT = '<subject>'
24
+
25
+
26
+ def set_params(obj)
27
+ obj.subject = SUBJECT
28
+ end
29
+
30
+
31
+ def match(obj)
32
+ assert_equal SUBJECT, obj.subject
33
+ end
34
+
35
+
36
+ def generate_hash
37
+ { subject: '<subject>' }
38
+ end
39
+
40
+
41
+ def test_setters
42
+ actual = Authlete::Model::Request::ClientAuthorizationDeleteRequest.new
43
+ set_params(actual)
44
+
45
+ match(actual)
46
+ end
47
+
48
+
49
+ def test_to_hash
50
+ obj = Authlete::Model::Request::ClientAuthorizationDeleteRequest.new
51
+ set_params(obj)
52
+ actual = obj.to_hash
53
+ expected = generate_hash
54
+
55
+ assert_equal expected, actual
56
+ end
57
+ end
@@ -0,0 +1,71 @@
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 ClientAuthorizationGetListRequestTest < Minitest::Test
23
+ SUBJECT = '<subject>'
24
+ DEVELOPER = '<developer>'
25
+ START_PARAM = 0
26
+ END_PARAM = 2
27
+
28
+
29
+ def set_params(obj)
30
+ obj.subject = SUBJECT
31
+ obj.developer = DEVELOPER
32
+ obj.start = START_PARAM
33
+ obj.end = END_PARAM
34
+ end
35
+
36
+
37
+ def match(obj)
38
+ assert_equal SUBJECT, obj.subject
39
+ assert_equal DEVELOPER, obj.developer
40
+ assert_equal START_PARAM, obj.start
41
+ assert_equal END_PARAM, obj.end
42
+ end
43
+
44
+
45
+ def generate_hash
46
+ {
47
+ subject: '<subject>',
48
+ developer: '<developer>',
49
+ start: 0,
50
+ end: 2
51
+ }
52
+ end
53
+
54
+
55
+ def test_setters
56
+ actual = Authlete::Model::Request::ClientAuthorizationGetListRequest.new
57
+ set_params(actual)
58
+
59
+ match(actual)
60
+ end
61
+
62
+
63
+ def test_to_hash
64
+ obj = Authlete::Model::Request::ClientAuthorizationGetListRequest.new
65
+ set_params(obj)
66
+ actual = obj.to_hash
67
+ expected = generate_hash
68
+
69
+ assert_equal expected, actual
70
+ end
71
+ end
@@ -0,0 +1,63 @@
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 ClientAuthorizationUpdateRequestTest < Minitest::Test
23
+ SUBJECT = '<subject>'
24
+ SCOPES = [ 'scope0', 'scope1' ]
25
+
26
+
27
+ def set_params(obj)
28
+ obj.subject = SUBJECT
29
+ obj.scopes = SCOPES
30
+ end
31
+
32
+
33
+ def match(obj)
34
+ assert_equal SUBJECT, obj.subject
35
+ assert_equal SCOPES, obj.scopes
36
+ end
37
+
38
+
39
+ def generate_hash
40
+ {
41
+ subject: '<subject>',
42
+ scopes: [ 'scope0', 'scope1' ]
43
+ }
44
+ end
45
+
46
+
47
+ def test_setters
48
+ actual = Authlete::Model::Request::ClientAuthorizationUpdateRequest.new
49
+ set_params(actual)
50
+
51
+ match(actual)
52
+ end
53
+
54
+
55
+ def test_to_hash
56
+ obj = Authlete::Model::Request::ClientAuthorizationUpdateRequest.new
57
+ set_params(obj)
58
+ actual = obj.to_hash
59
+ expected = generate_hash
60
+
61
+ assert_equal expected, actual
62
+ end
63
+ end
@@ -0,0 +1,68 @@
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 'json'
20
+ require 'minitest/autorun'
21
+
22
+
23
+ class ClientRegistrationRequestTest < Minitest::Test
24
+ JSON = '<json>'
25
+ TOKEN = '<token>'
26
+ CLIENT_ID = '<client-id>'
27
+
28
+
29
+ def set_params(obj)
30
+ obj.json = JSON
31
+ obj.token = TOKEN
32
+ obj.client_id = CLIENT_ID
33
+ end
34
+
35
+
36
+ def match(obj)
37
+ assert_equal JSON, obj.json
38
+ assert_equal TOKEN, obj.token
39
+ assert_equal CLIENT_ID, obj.clientId
40
+ end
41
+
42
+
43
+ def generate_hash
44
+ {
45
+ json: '<json>',
46
+ token: '<token>',
47
+ clientId: '<client-id>'
48
+ }
49
+ end
50
+
51
+
52
+ def test_setters
53
+ actual = Authlete::Model::Request::ClientRegistrationRequest.new
54
+ set_params(actual)
55
+
56
+ match(actual)
57
+ end
58
+
59
+
60
+ def test_to_hash
61
+ obj = Authlete::Model::Request::ClientRegistrationRequest.new
62
+ set_params(obj)
63
+ actual = obj.to_hash
64
+ expected = generate_hash
65
+
66
+ assert_equal expected, actual
67
+ end
68
+ end
@@ -0,0 +1,75 @@
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 DeviceAuthorizationRequestTest < Minitest::Test
23
+ PARAMETERS = '<parameters>'
24
+ CLIENT_ID = '<client-id>'
25
+ CLIENT_SECRET = '<client-secret>'
26
+ CLIENT_CERTIFICATE = '<client-certificate>'
27
+ CLIENT_CERTIFICATE_PATH = [ 'path0', 'path1' ]
28
+
29
+
30
+ def set_params(obj)
31
+ obj.parameters = PARAMETERS
32
+ obj.client_id = CLIENT_ID
33
+ obj.client_secret = CLIENT_SECRET
34
+ obj.client_certificate = CLIENT_CERTIFICATE
35
+ obj.client_certificate_path = CLIENT_CERTIFICATE_PATH
36
+ end
37
+
38
+
39
+ def match(obj)
40
+ assert_equal PARAMETERS, obj.parameters
41
+ assert_equal CLIENT_ID, obj.clientId
42
+ assert_equal CLIENT_SECRET, obj.clientSecret
43
+ assert_equal CLIENT_CERTIFICATE, obj.clientCertificate
44
+ assert_equal CLIENT_CERTIFICATE_PATH, obj.clientCertificatePath
45
+ end
46
+
47
+
48
+ def generate_hash
49
+ {
50
+ parameters: '<parameters>',
51
+ clientId: '<client-id>',
52
+ clientSecret: '<client-secret>',
53
+ clientCertificate: '<client-certificate>',
54
+ clientCertificatePath: [ 'path0', 'path1' ]
55
+ }
56
+ end
57
+
58
+
59
+ def test_setters
60
+ actual = Authlete::Model::Request::DeviceAuthorizationRequest.new
61
+ set_params(actual)
62
+
63
+ match(actual)
64
+ end
65
+
66
+
67
+ def test_to_hash
68
+ obj = Authlete::Model::Request::DeviceAuthorizationRequest.new
69
+ set_params(obj)
70
+ actual = obj.to_hash
71
+ expected = generate_hash
72
+
73
+ assert_equal expected, actual
74
+ end
75
+ end