authlete 1.0.24 → 1.1.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.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/Makefile +40 -0
- data/Rakefile +5 -0
- data/authlete.gemspec +2 -2
- data/lib/authlete.rb +28 -9
- data/lib/authlete/api.rb +146 -321
- data/lib/authlete/authentication-server.rb +2 -2
- data/lib/authlete/exception.rb +14 -15
- data/lib/authlete/model/base.rb +30 -0
- data/lib/authlete/model/client-extension.rb +17 -119
- data/lib/authlete/model/client.rb +196 -345
- data/lib/authlete/model/hashable.rb +13 -33
- data/lib/authlete/model/named-uri.rb +13 -74
- data/lib/authlete/model/pair.rb +13 -74
- data/lib/authlete/model/param-initializer.rb +45 -0
- data/lib/authlete/model/property.rb +15 -85
- data/lib/authlete/model/request/authentication-callback-request.rb +63 -55
- data/lib/authlete/model/request/authorization-fail-request.rb +14 -75
- data/lib/authlete/model/request/authorization-issue-request.rb +38 -119
- data/lib/authlete/model/request/authorization-request.rb +8 -73
- data/lib/authlete/model/request/backchannel-authentication-complete-request.rb +97 -0
- data/lib/authlete/model/request/backchannel-authentication-fail-request.rb +55 -0
- data/lib/authlete/model/request/backchannel-authentication-issue-request.rb +37 -0
- data/lib/authlete/model/request/backchannel-authentication-request.rb +63 -0
- data/lib/authlete/model/request/base.rb +26 -0
- data/lib/authlete/model/request/client-authorization-delete-request.rb +7 -93
- data/lib/authlete/model/request/client-authorization-get-list-request.rb +17 -89
- data/lib/authlete/model/request/client-authorization-update-request.rb +11 -86
- data/lib/authlete/model/request/client-registration-request.rb +49 -0
- data/lib/authlete/model/request/client-secret-update-request.rb +7 -89
- data/lib/authlete/model/request/developer-authentication-callback-request.rb +40 -43
- data/lib/authlete/model/request/device-authorization-request.rb +63 -0
- data/lib/authlete/model/request/device-complete-request.rb +99 -0
- data/lib/authlete/model/request/device-verification-request.rb +40 -0
- data/lib/authlete/model/request/granted-scopes-request.rb +8 -74
- data/lib/authlete/model/request/introspection-request.rb +24 -83
- data/lib/authlete/model/request/pushed-auth-req-request.rb +64 -0
- data/lib/authlete/model/request/revocation-request.rb +14 -88
- data/lib/authlete/model/request/standard-introspection-request.rb +8 -73
- data/lib/authlete/model/request/token-create-request.rb +52 -183
- data/lib/authlete/model/request/token-fail-request.rb +12 -74
- data/lib/authlete/model/request/token-issue-request.rb +22 -80
- data/lib/authlete/model/request/token-request.rb +44 -81
- data/lib/authlete/model/request/token-update-request.rb +35 -121
- data/lib/authlete/model/request/user-info-issue-request.rb +14 -80
- data/lib/authlete/model/request/user-info-request.rb +25 -70
- data/lib/authlete/model/response/access-token.rb +96 -0
- data/lib/authlete/model/response/authentication-callback-response.rb +24 -19
- data/lib/authlete/model/response/authorization-fail-response.rb +13 -15
- data/lib/authlete/model/response/authorization-issue-response.rb +29 -32
- data/lib/authlete/model/response/authorization-response.rb +97 -123
- data/lib/authlete/model/response/authorized-client-list-response.rb +37 -0
- data/lib/authlete/model/response/backchannel-authentication-complete-response.rb +143 -0
- data/lib/authlete/model/response/backchannel-authentication-fail-response.rb +47 -0
- data/lib/authlete/model/response/backchannel-authentication-issue-response.rb +63 -0
- data/lib/authlete/model/response/backchannel-authentication-response.rb +160 -0
- data/lib/authlete/model/response/client-list-response.rb +58 -0
- data/lib/authlete/model/response/client-registration-response.rb +50 -0
- data/lib/authlete/model/response/client-secret-refresh-response.rb +12 -12
- data/lib/authlete/model/response/client-secret-update-response.rb +12 -12
- data/lib/authlete/model/response/developer-authentication-callback-response.rb +24 -19
- data/lib/authlete/model/response/device-authorization-response.rb +134 -0
- data/lib/authlete/model/response/device-complete-response.rb +39 -0
- data/lib/authlete/model/response/device-verification-response.rb +96 -0
- data/lib/authlete/model/response/granted-scopes-get-response.rb +27 -19
- data/lib/authlete/model/response/introspection-response.rb +64 -58
- data/lib/authlete/model/response/pushed-auth-req-response.rb +59 -0
- data/lib/authlete/model/response/revocation-response.rb +12 -15
- data/lib/authlete/model/response/service-list-response.rb +54 -0
- data/lib/authlete/model/response/standard-introspection-response.rb +13 -15
- data/lib/authlete/model/response/token-create-response.rb +50 -55
- data/lib/authlete/model/response/token-fail-response.rb +14 -17
- data/lib/authlete/model/response/token-issue-response.rb +49 -62
- data/lib/authlete/model/response/token-list-response.rb +64 -0
- data/lib/authlete/model/response/token-response.rb +59 -79
- data/lib/authlete/model/response/token-update-response.rb +28 -23
- data/lib/authlete/model/response/user-info-issue-response.rb +16 -16
- data/lib/authlete/model/response/user-info-response.rb +48 -42
- data/lib/authlete/model/result.rb +14 -13
- data/lib/authlete/model/scope.rb +29 -119
- data/lib/authlete/model/service-owner.rb +32 -116
- data/lib/authlete/model/service.rb +464 -685
- data/lib/authlete/model/sns-credentials.rb +18 -91
- data/lib/authlete/model/tagged-value.rb +14 -69
- data/lib/authlete/utility.rb +3 -32
- data/lib/authlete/version.rb +3 -3
- data/test/authlete/model/request/test_authentication-callback-request.rb +100 -0
- data/test/authlete/model/request/test_authorization-fail-request.rb +67 -0
- data/test/authlete/model/request/test_authorization-issue-request.rb +94 -0
- data/test/authlete/model/request/test_authorization-request.rb +57 -0
- data/test/authlete/model/request/test_backchannel-authentication-complete-request.rb +102 -0
- data/test/authlete/model/request/test_backchannel-authentication-fail-request.rb +71 -0
- data/test/authlete/model/request/test_backchannel-authentication-issue-request.rb +57 -0
- data/test/authlete/model/request/test_backchannel-authentication-request.rb +75 -0
- data/test/authlete/model/request/test_client-authorization-delete-request.rb +57 -0
- data/test/authlete/model/request/test_client-authorization-get-list-request.rb +71 -0
- data/test/authlete/model/request/test_client-authorization-update-request.rb +63 -0
- data/test/authlete/model/request/test_client-registration-request.rb +68 -0
- data/test/authlete/model/request/test_device-authorization-request.rb +75 -0
- data/test/authlete/model/request/test_device-complete-request.rb +102 -0
- data/test/authlete/model/request/test_device-verification-request.rb +57 -0
- data/test/authlete/model/request/test_granted-scopes-request.rb +57 -0
- data/test/authlete/model/request/test_introspection-request.rb +79 -0
- data/test/authlete/model/request/test_pushed-auth-req-request.rb +75 -0
- data/test/authlete/model/request/test_revocation-request.rb +67 -0
- data/test/authlete/model/request/test_standard-introspection-request.rb +57 -0
- data/test/authlete/model/request/test_token-create-request.rb +110 -0
- data/test/authlete/model/request/test_token-fail-request.rb +63 -0
- data/test/authlete/model/request/test_token-issue-request.rb +70 -0
- data/test/authlete/model/request/test_token-request.rb +94 -0
- data/test/authlete/model/request/test_token-update-request.rb +82 -0
- data/test/authlete/model/request/test_user-info-issue-request.rb +67 -0
- data/test/authlete/model/request/test_user-info-request.rb +75 -0
- data/test/authlete/model/response/test_access-token.rb +101 -0
- data/test/authlete/model/response/test_authorization-fail-response.rb +68 -0
- data/test/authlete/model/response/test_authorization-issue-response.rb +92 -0
- data/test/authlete/model/response/test_authorization-response.rb +145 -0
- data/test/authlete/model/response/test_authorized-client-list-response.rb +83 -0
- data/test/authlete/model/response/test_backchannel-authentication-complete-response.rb +132 -0
- data/test/authlete/model/response/test_backchannel-authentication-fail-response.rb +68 -0
- data/test/authlete/model/response/test_backchannel-authentication-issue-response.rb +80 -0
- data/test/authlete/model/response/test_backchannel-authentication-response.rb +156 -0
- data/test/authlete/model/response/test_client-list-response.rb +79 -0
- data/test/authlete/model/response/test_client-secret-refresh-response.rb +68 -0
- data/test/authlete/model/response/test_client-secret-update-response.rb +68 -0
- data/test/authlete/model/response/test_device-authorization-response.rb +140 -0
- data/test/authlete/model/response/test_device-complete-response.rb +64 -0
- data/test/authlete/model/response/test_device-verification-response.rb +112 -0
- data/test/authlete/model/response/test_granted-scopes-get-response.rb +84 -0
- data/test/authlete/model/response/test_introspection-response.rb +127 -0
- data/test/authlete/model/response/test_pushed-auth-req-response.rb +76 -0
- data/test/authlete/model/response/test_revocation-response.rb +68 -0
- data/test/authlete/model/response/test_service-list-response.rb +72 -0
- data/test/authlete/model/response/test_standard-introspection-response.rb +68 -0
- data/test/authlete/model/response/test_token-create-response.rb +107 -0
- data/test/authlete/model/response/test_token-fail-response.rb +68 -0
- data/test/authlete/model/response/test_token-issue-response.rb +127 -0
- data/test/authlete/model/response/test_token-list-response.rb +84 -0
- data/test/authlete/model/response/test_token-response.rb +147 -0
- data/test/authlete/model/response/test_token-update-response.rb +87 -0
- data/test/authlete/model/response/test_user-info-issue-response.rb +68 -0
- data/test/authlete/model/response/test_user-info-response.rb +107 -0
- data/test/authlete/model/test_client-extension.rb +95 -0
- data/test/authlete/model/test_client.rb +461 -0
- data/test/authlete/model/test_named-uri.rb +85 -0
- data/test/authlete/model/test_pair.rb +85 -0
- data/test/authlete/model/test_property.rb +90 -0
- data/test/authlete/model/test_result.rb +68 -0
- data/test/authlete/model/test_scope.rb +106 -0
- data/test/authlete/model/test_service-owner.rb +80 -0
- data/test/authlete/model/test_service.rb +614 -0
- data/test/authlete/model/test_sns-credentials.rb +88 -0
- data/test/authlete/model/test_tagged-value.rb +83 -0
- data/test/authlete/test_exception.rb +70 -0
- metadata +169 -9
- data/lib/authlete/model/client-list.rb +0 -129
- data/lib/authlete/model/response/client-authorization-get-list-response.rb +0 -60
- data/lib/authlete/model/response/service-creatable-response.rb +0 -51
- data/lib/authlete/model/service-list.rb +0 -128
@@ -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 ClientSecretRefreshResponseTest < Minitest::Test
|
24
|
+
RESULT_CODE = '<result-code>'
|
25
|
+
RESULT_MESSAGE = '<result-message>'
|
26
|
+
NEW_CLEINT_SECRET = '<new-client-secret>'
|
27
|
+
OLD_CLIENT_SECRET = '<old-client-secret>'
|
28
|
+
|
29
|
+
|
30
|
+
def generate_json
|
31
|
+
return <<~JSON
|
32
|
+
{
|
33
|
+
"resultCode": "<result-code>",
|
34
|
+
"resultMessage": "<result-message>",
|
35
|
+
"newClientSecret": "<new-client-secret>",
|
36
|
+
"oldClientSecret": "<old-client-secret>"
|
37
|
+
}
|
38
|
+
JSON
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
def match(obj)
|
43
|
+
assert_equal RESULT_CODE, obj.resultCode
|
44
|
+
assert_equal RESULT_MESSAGE, obj.resultMessage
|
45
|
+
assert_equal NEW_CLEINT_SECRET, obj.newClientSecret
|
46
|
+
assert_equal OLD_CLIENT_SECRET, obj.oldClientSecret
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
def test_from_json
|
51
|
+
jsn = generate_json
|
52
|
+
hsh = JSON.parse(jsn)
|
53
|
+
actual = Authlete::Model::Response::ClientSecretRefreshResponse.new(hsh)
|
54
|
+
|
55
|
+
match(actual)
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
def test_setters
|
60
|
+
actual = Authlete::Model::Response::ClientSecretRefreshResponse.new
|
61
|
+
actual.result_code = RESULT_CODE
|
62
|
+
actual.result_message = RESULT_MESSAGE
|
63
|
+
actual.new_client_secret = NEW_CLEINT_SECRET
|
64
|
+
actual.old_client_secret = OLD_CLIENT_SECRET
|
65
|
+
|
66
|
+
match(actual)
|
67
|
+
end
|
68
|
+
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 ClientSecretUpdateResponseTest < Minitest::Test
|
24
|
+
RESULT_CODE = '<result-code>'
|
25
|
+
RESULT_MESSAGE = '<result-message>'
|
26
|
+
NEW_CLEINT_SECRET = '<new-client-secret>'
|
27
|
+
OLD_CLIENT_SECRET = '<old-client-secret>'
|
28
|
+
|
29
|
+
|
30
|
+
def generate_json
|
31
|
+
return <<~JSON
|
32
|
+
{
|
33
|
+
"resultCode": "<result-code>",
|
34
|
+
"resultMessage": "<result-message>",
|
35
|
+
"newClientSecret": "<new-client-secret>",
|
36
|
+
"oldClientSecret": "<old-client-secret>"
|
37
|
+
}
|
38
|
+
JSON
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
def match(obj)
|
43
|
+
assert_equal RESULT_CODE, obj.resultCode
|
44
|
+
assert_equal RESULT_MESSAGE, obj.resultMessage
|
45
|
+
assert_equal NEW_CLEINT_SECRET, obj.newClientSecret
|
46
|
+
assert_equal OLD_CLIENT_SECRET, obj.oldClientSecret
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
def test_from_json
|
51
|
+
jsn = generate_json
|
52
|
+
hsh = JSON.parse(jsn)
|
53
|
+
actual = Authlete::Model::Response::ClientSecretUpdateResponse.new(hsh)
|
54
|
+
|
55
|
+
match(actual)
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
def test_setters
|
60
|
+
actual = Authlete::Model::Response::ClientSecretUpdateResponse.new
|
61
|
+
actual.result_code = RESULT_CODE
|
62
|
+
actual.result_message = RESULT_MESSAGE
|
63
|
+
actual.new_client_secret = NEW_CLEINT_SECRET
|
64
|
+
actual.old_client_secret = OLD_CLIENT_SECRET
|
65
|
+
|
66
|
+
match(actual)
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,140 @@
|
|
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 DeviceAuthorizationResponseTest < Minitest::Test
|
24
|
+
RESULT_CODE = '<result-code>'
|
25
|
+
RESULT_MESSAGE = '<result-message>'
|
26
|
+
ACTION = 'OK'
|
27
|
+
RESPONSE_CONTENT = '<response-content>'
|
28
|
+
CLIENT_ID = 12345
|
29
|
+
CLIENT_ID_ALIAS = '<client-id-alias>'
|
30
|
+
CLIENT_ID_ALIAS_USED = false
|
31
|
+
CLIENT_NAME = '<client-name>'
|
32
|
+
CLIENT_AUTH_METHOD = 'BASIC'
|
33
|
+
SCOPE_NAME = "scope0"
|
34
|
+
SCOPE_DESCRIPTION = "<scope0-description>"
|
35
|
+
SCOPES = [ Authlete::Model::Scope.new(name: SCOPE_NAME, description: SCOPE_DESCRIPTION) ]
|
36
|
+
CLIENT_NAMES = [ 'client0', 'client1' ]
|
37
|
+
ACRS = [ 'acr0', 'acr1' ]
|
38
|
+
DEVICE_CODE = '<device-code>'
|
39
|
+
USER_CODE = '<user-code>'
|
40
|
+
VERIFICATION_URI = '<verification-uri>'
|
41
|
+
VERIFICATION_URI_COMPLETE = '<verification-uri-complete>'
|
42
|
+
EXPIRES_IN = 1000
|
43
|
+
INTERVAL = 100
|
44
|
+
RESOURCES = [ 'resource0', 'resource1' ]
|
45
|
+
WARNINGS = [ 'warning0', 'warning1' ]
|
46
|
+
|
47
|
+
|
48
|
+
def generate_json
|
49
|
+
return <<~JSON
|
50
|
+
{
|
51
|
+
"resultCode": "<result-code>",
|
52
|
+
"resultMessage": "<result-message>",
|
53
|
+
"action": "OK",
|
54
|
+
"responseContent": "<response-content>",
|
55
|
+
"clientId": 12345,
|
56
|
+
"clientIdAlias": "<client-id-alias>",
|
57
|
+
"clientIdAliasUsed": false,
|
58
|
+
"clientName": "<client-name>",
|
59
|
+
"clientAuthMethod": "BASIC",
|
60
|
+
"scopes": [
|
61
|
+
{
|
62
|
+
"name": "scope0",
|
63
|
+
"description": "<scope0-description>"
|
64
|
+
}
|
65
|
+
],
|
66
|
+
"clientNames": [ "client0", "client1" ],
|
67
|
+
"acrs": [ "acr0", "acr1" ],
|
68
|
+
"deviceCode": "<device-code>",
|
69
|
+
"userCode": "<user-code>",
|
70
|
+
"verificationUri": "<verification-uri>",
|
71
|
+
"verificationUriComplete": "<verification-uri-complete>",
|
72
|
+
"expiresIn": 1000,
|
73
|
+
"interval": 100,
|
74
|
+
"resources": [ "resource0", "resource1" ],
|
75
|
+
"warnings": [ "warning0", "warning1" ]
|
76
|
+
}
|
77
|
+
JSON
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
def match(obj)
|
82
|
+
assert_equal RESULT_CODE, obj.resultCode
|
83
|
+
assert_equal RESULT_MESSAGE, obj.resultMessage
|
84
|
+
assert_equal ACTION, obj.action
|
85
|
+
assert_equal RESPONSE_CONTENT, obj.responseContent
|
86
|
+
assert_equal CLIENT_ID, obj.clientId
|
87
|
+
assert_equal CLIENT_ID_ALIAS, obj.clientIdAlias
|
88
|
+
assert_equal CLIENT_ID_ALIAS_USED, obj.clientIdAliasUsed
|
89
|
+
assert_equal CLIENT_NAME, obj.clientName
|
90
|
+
assert_equal CLIENT_AUTH_METHOD, obj.clientAuthMethod
|
91
|
+
assert_equal SCOPE_NAME, obj.scopes[0].name
|
92
|
+
assert_equal SCOPE_DESCRIPTION, obj.scopes[0].description
|
93
|
+
assert_equal CLIENT_NAMES, obj.clientNames
|
94
|
+
assert_equal ACRS, obj.acrs
|
95
|
+
assert_equal DEVICE_CODE, obj.deviceCode
|
96
|
+
assert_equal USER_CODE, obj.userCode
|
97
|
+
assert_equal VERIFICATION_URI, obj.verificationUri
|
98
|
+
assert_equal VERIFICATION_URI_COMPLETE, obj.verificationUriComplete
|
99
|
+
assert_equal EXPIRES_IN, obj.expiresIn
|
100
|
+
assert_equal INTERVAL, obj.interval
|
101
|
+
assert_equal RESOURCES, obj.resources
|
102
|
+
assert_equal WARNINGS, obj.warnings
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
def test_from_json
|
107
|
+
jsn = generate_json
|
108
|
+
hsh = JSON.parse(jsn)
|
109
|
+
actual = Authlete::Model::Response::DeviceAuthorizationResponse.new(hsh)
|
110
|
+
|
111
|
+
match(actual)
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
def test_setters
|
116
|
+
actual = Authlete::Model::Response::DeviceAuthorizationResponse.new
|
117
|
+
actual.result_code = RESULT_CODE
|
118
|
+
actual.result_message = RESULT_MESSAGE
|
119
|
+
actual.action = ACTION
|
120
|
+
actual.response_content = RESPONSE_CONTENT
|
121
|
+
actual.client_id = CLIENT_ID
|
122
|
+
actual.client_id_alias = CLIENT_ID_ALIAS
|
123
|
+
actual.client_id_alias_used = CLIENT_ID_ALIAS_USED
|
124
|
+
actual.client_name = CLIENT_NAME
|
125
|
+
actual.client_auth_method = CLIENT_AUTH_METHOD
|
126
|
+
actual.scopes = SCOPES
|
127
|
+
actual.client_names = CLIENT_NAMES
|
128
|
+
actual.acrs = ACRS
|
129
|
+
actual.device_code = DEVICE_CODE
|
130
|
+
actual.user_code = USER_CODE
|
131
|
+
actual.verification_uri = VERIFICATION_URI
|
132
|
+
actual.verification_uri_complete = VERIFICATION_URI_COMPLETE
|
133
|
+
actual.expires_in = EXPIRES_IN
|
134
|
+
actual.interval = INTERVAL
|
135
|
+
actual.resources = RESOURCES
|
136
|
+
actual.warnings = WARNINGS
|
137
|
+
|
138
|
+
match(actual)
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,64 @@
|
|
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 DeviceCompleteResponseTest < Minitest::Test
|
24
|
+
RESULT_CODE = '<result-code>'
|
25
|
+
RESULT_MESSAGE = '<result-message>'
|
26
|
+
ACTION = 'SUCCESS'
|
27
|
+
|
28
|
+
|
29
|
+
def generate_json
|
30
|
+
return <<~JSON
|
31
|
+
{
|
32
|
+
"resultCode": "<result-code>",
|
33
|
+
"resultMessage": "<result-message>",
|
34
|
+
"action": "SUCCESS"
|
35
|
+
}
|
36
|
+
JSON
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
def match(obj)
|
41
|
+
assert_equal RESULT_CODE, obj.resultCode
|
42
|
+
assert_equal RESULT_MESSAGE, obj.resultMessage
|
43
|
+
assert_equal ACTION, obj.action
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def test_from_json
|
48
|
+
jsn = generate_json
|
49
|
+
hsh = JSON.parse(jsn)
|
50
|
+
actual = Authlete::Model::Response::DeviceVerificationResponse.new(hsh)
|
51
|
+
|
52
|
+
match(actual)
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def test_setters
|
57
|
+
actual = Authlete::Model::Response::DeviceVerificationResponse.new
|
58
|
+
actual.result_code = RESULT_CODE
|
59
|
+
actual.result_message = RESULT_MESSAGE
|
60
|
+
actual.action = ACTION
|
61
|
+
|
62
|
+
match(actual)
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,112 @@
|
|
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 DeviceVerificationResponseTest < Minitest::Test
|
24
|
+
RESULT_CODE = '<result-code>'
|
25
|
+
RESULT_MESSAGE = '<result-message>'
|
26
|
+
ACTION = 'VALID'
|
27
|
+
RESPONSE_CONTENT = '<response-content>'
|
28
|
+
CLIENT_ID = 12345
|
29
|
+
CLIENT_ID_ALIAS = '<client-id-alias>'
|
30
|
+
CLIENT_ID_ALIAS_USED = false
|
31
|
+
CLIENT_NAME = '<client-name>'
|
32
|
+
SCOPE_NAME = "scope0"
|
33
|
+
SCOPE_DESCRIPTION = "<scope0-description>"
|
34
|
+
SCOPES = [ Authlete::Model::Scope.new(name: SCOPE_NAME, description: SCOPE_DESCRIPTION) ]
|
35
|
+
CLIENT_NAMES = [ 'client0', 'client1' ]
|
36
|
+
ACRS = [ 'acr0', 'acr1' ]
|
37
|
+
EXPIRES_AT = 1000
|
38
|
+
RESOURCES = [ 'resource0', 'resource1' ]
|
39
|
+
|
40
|
+
|
41
|
+
def generate_json
|
42
|
+
return <<~JSON
|
43
|
+
{
|
44
|
+
"resultCode": "<result-code>",
|
45
|
+
"resultMessage": "<result-message>",
|
46
|
+
"action": "VALID",
|
47
|
+
"responseContent": "<response-content>",
|
48
|
+
"clientId": 12345,
|
49
|
+
"clientIdAlias": "<client-id-alias>",
|
50
|
+
"clientIdAliasUsed": false,
|
51
|
+
"clientName": "<client-name>",
|
52
|
+
"scopes": [
|
53
|
+
{
|
54
|
+
"name": "scope0",
|
55
|
+
"description": "<scope0-description>"
|
56
|
+
}
|
57
|
+
],
|
58
|
+
"clientNames": [ "client0", "client1" ],
|
59
|
+
"acrs": [ "acr0", "acr1" ],
|
60
|
+
"expiresAt": 1000,
|
61
|
+
"resources": [ "resource0", "resource1" ]
|
62
|
+
}
|
63
|
+
JSON
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
def match(obj)
|
68
|
+
assert_equal RESULT_CODE, obj.resultCode
|
69
|
+
assert_equal RESULT_MESSAGE, obj.resultMessage
|
70
|
+
assert_equal ACTION, obj.action
|
71
|
+
assert_equal RESPONSE_CONTENT, obj.responseContent
|
72
|
+
assert_equal CLIENT_ID, obj.clientId
|
73
|
+
assert_equal CLIENT_ID_ALIAS, obj.clientIdAlias
|
74
|
+
assert_equal CLIENT_ID_ALIAS_USED, obj.clientIdAliasUsed
|
75
|
+
assert_equal CLIENT_NAME, obj.clientName
|
76
|
+
assert_equal SCOPE_NAME, obj.scopes[0].name
|
77
|
+
assert_equal SCOPE_DESCRIPTION, obj.scopes[0].description
|
78
|
+
assert_equal CLIENT_NAMES, obj.clientNames
|
79
|
+
assert_equal ACRS, obj.acrs
|
80
|
+
assert_equal EXPIRES_AT, obj.expiresAt
|
81
|
+
assert_equal RESOURCES, obj.resources
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
def test_from_json
|
86
|
+
jsn = generate_json
|
87
|
+
hsh = JSON.parse(jsn)
|
88
|
+
actual = Authlete::Model::Response::DeviceVerificationResponse.new(hsh)
|
89
|
+
|
90
|
+
match(actual)
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
def test_setters
|
95
|
+
actual = Authlete::Model::Response::DeviceVerificationResponse.new
|
96
|
+
actual.result_code = RESULT_CODE
|
97
|
+
actual.result_message = RESULT_MESSAGE
|
98
|
+
actual.action = ACTION
|
99
|
+
actual.response_content = RESPONSE_CONTENT
|
100
|
+
actual.client_id = CLIENT_ID
|
101
|
+
actual.client_id_alias = CLIENT_ID_ALIAS
|
102
|
+
actual.client_id_alias_used = CLIENT_ID_ALIAS_USED
|
103
|
+
actual.client_name = CLIENT_NAME
|
104
|
+
actual.scopes = SCOPES
|
105
|
+
actual.client_names = CLIENT_NAMES
|
106
|
+
actual.acrs = ACRS
|
107
|
+
actual.expires_at = EXPIRES_AT
|
108
|
+
actual.resources = RESOURCES
|
109
|
+
|
110
|
+
match(actual)
|
111
|
+
end
|
112
|
+
end
|