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.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/Makefile +40 -0
- data/README.md +20 -20
- data/Rakefile +5 -0
- data/authlete.gemspec +2 -2
- data/lib/authlete.rb +28 -9
- data/lib/authlete/api.rb +153 -322
- data/lib/authlete/authentication-server.rb +230 -230
- 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 +203 -338
- 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 +68 -158
- data/lib/authlete/model/service-owner.rb +32 -116
- data/lib/authlete/model/service.rb +672 -837
- data/lib/authlete/model/sns-credentials.rb +51 -124
- data/lib/authlete/model/tagged-value.rb +14 -69
- data/lib/authlete/utility.rb +70 -99
- 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 +624 -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 +173 -13
- 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
data/lib/authlete/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# :nodoc:
|
2
2
|
#
|
3
|
-
# Copyright (C) 2014-
|
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
|
20
|
-
end
|
19
|
+
VERSION = "1.2.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
|
@@ -0,0 +1,94 @@
|
|
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 AuthorizationIssueRequestTest < Minitest::Test
|
23
|
+
TICKET = '<ticket>'
|
24
|
+
SUBJECT = '<subject>'
|
25
|
+
AUTH_TIME = 100
|
26
|
+
ACR = '<acr>'
|
27
|
+
CLAIMS = [ 'claim0', 'claim1' ]
|
28
|
+
PROPERTY_KEY = '<property0-key>'
|
29
|
+
PROPERTY_VALUE = '<property0-value>'
|
30
|
+
PROPERTIES = [ Authlete::Model::Property.new(key: PROPERTY_KEY, value: PROPERTY_VALUE) ]
|
31
|
+
SCOPES = [ 'scope0', 'scope1' ]
|
32
|
+
SUB = '<sub>'
|
33
|
+
IDT_HEADER_PARAMS = '<idt-header-params>'
|
34
|
+
|
35
|
+
|
36
|
+
def set_params(obj)
|
37
|
+
obj.ticket = TICKET
|
38
|
+
obj.subject = SUBJECT
|
39
|
+
obj.auth_time = AUTH_TIME
|
40
|
+
obj.acr = ACR
|
41
|
+
obj.claims = CLAIMS
|
42
|
+
obj.properties = PROPERTIES
|
43
|
+
obj.scopes = SCOPES
|
44
|
+
obj.sub = SUB
|
45
|
+
obj.idtHeaderParams = IDT_HEADER_PARAMS
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
def match(obj)
|
50
|
+
assert_equal TICKET, obj.ticket
|
51
|
+
assert_equal SUBJECT, obj.subject
|
52
|
+
assert_equal AUTH_TIME, obj.authTime
|
53
|
+
assert_equal ACR, obj.acr
|
54
|
+
assert_equal CLAIMS, obj.claims
|
55
|
+
assert_equal PROPERTY_KEY, obj.properties[0].key
|
56
|
+
assert_equal PROPERTY_VALUE, obj.properties[0].value
|
57
|
+
assert_equal SCOPES, obj.scopes
|
58
|
+
assert_equal SUB, obj.sub
|
59
|
+
assert_equal IDT_HEADER_PARAMS, obj.idtHeaderParams
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
def generate_hash
|
64
|
+
{
|
65
|
+
ticket: '<ticket>',
|
66
|
+
subject: '<subject>',
|
67
|
+
authTime: 100,
|
68
|
+
acr: '<acr>',
|
69
|
+
claims: [ 'claim0', 'claim1' ],
|
70
|
+
properties: [ { key: '<property0-key>', value: '<property0-value>', hidden: false } ],
|
71
|
+
scopes: [ 'scope0', 'scope1' ],
|
72
|
+
sub: '<sub>',
|
73
|
+
idtHeaderParams: '<idt-header-params>'
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
def test_setters
|
79
|
+
actual = Authlete::Model::Request::AuthorizationIssueRequest.new
|
80
|
+
set_params(actual)
|
81
|
+
|
82
|
+
match(actual)
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
def test_to_hash
|
87
|
+
obj = Authlete::Model::Request::AuthorizationIssueRequest.new
|
88
|
+
set_params(obj)
|
89
|
+
actual = obj.to_hash
|
90
|
+
expected = generate_hash
|
91
|
+
|
92
|
+
assert_equal expected, actual
|
93
|
+
end
|
94
|
+
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 AuthorizationRequestTest < Minitest::Test
|
23
|
+
PARAMETERS = '<parameters>'
|
24
|
+
|
25
|
+
|
26
|
+
def set_params(obj)
|
27
|
+
obj.parameters = PARAMETERS
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
def match(obj)
|
32
|
+
assert_equal PARAMETERS, obj.parameters
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
def generate_hash
|
37
|
+
{ parameters: '<parameters>' }
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
def test_setters
|
42
|
+
actual = Authlete::Model::Request::AuthorizationRequest.new
|
43
|
+
set_params(actual)
|
44
|
+
|
45
|
+
match(actual)
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
def test_to_hash
|
50
|
+
obj = Authlete::Model::Request::AuthorizationRequest.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,102 @@
|
|
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 BackchannelAuthenticationCompleteRequestTest < Minitest::Test
|
23
|
+
TICKET = '<ticket>'
|
24
|
+
RESULT = 'AUTHORIZED'
|
25
|
+
SUBJECT = '<subject>'
|
26
|
+
SUB = '<sub>'
|
27
|
+
AUTH_TIME = 100
|
28
|
+
ACR = '<acr>'
|
29
|
+
CLAIMS = [ 'claim0', 'claim1' ]
|
30
|
+
PROPERTY_KEY = '<prop-key0>'
|
31
|
+
PROPERTY_VALUE = '<prop-value0>'
|
32
|
+
PROPERTIES = [ Authlete::Model::Property.new(key: PROPERTY_KEY, value: PROPERTY_VALUE) ]
|
33
|
+
SCOPES = [ 'scope0', 'scope1' ]
|
34
|
+
ERROR_DESCRIPTION = '<error-description>'
|
35
|
+
ERROR_URI = '<error-uri>'
|
36
|
+
|
37
|
+
|
38
|
+
def set_params(obj)
|
39
|
+
obj.ticket = TICKET
|
40
|
+
obj.result = RESULT
|
41
|
+
obj.subject = SUBJECT
|
42
|
+
obj.sub = SUB
|
43
|
+
obj.auth_time = AUTH_TIME
|
44
|
+
obj.acr = ACR
|
45
|
+
obj.claims = CLAIMS
|
46
|
+
obj.properties = PROPERTIES
|
47
|
+
obj.scopes = SCOPES
|
48
|
+
obj.error_description = ERROR_DESCRIPTION
|
49
|
+
obj.error_uri = ERROR_URI
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
def match(obj)
|
54
|
+
assert_equal TICKET, obj.ticket
|
55
|
+
assert_equal RESULT, obj.result
|
56
|
+
assert_equal SUBJECT, obj.subject
|
57
|
+
assert_equal SUB, obj.sub
|
58
|
+
assert_equal AUTH_TIME, obj.authTime
|
59
|
+
assert_equal ACR, obj.acr
|
60
|
+
assert_equal CLAIMS, obj.claims
|
61
|
+
assert_equal PROPERTY_KEY, obj.properties[0].key
|
62
|
+
assert_equal PROPERTY_VALUE, obj.properties[0].value
|
63
|
+
assert_equal SCOPES, obj.scopes
|
64
|
+
assert_equal ERROR_DESCRIPTION, obj.errorDescription
|
65
|
+
assert_equal ERROR_URI, obj.errorUri
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
def generate_hash
|
70
|
+
{
|
71
|
+
ticket: '<ticket>',
|
72
|
+
result: 'AUTHORIZED',
|
73
|
+
subject: '<subject>',
|
74
|
+
sub: '<sub>',
|
75
|
+
authTime: 100,
|
76
|
+
acr: '<acr>',
|
77
|
+
claims: [ 'claim0', 'claim1' ],
|
78
|
+
properties: [ { key: '<prop-key0>', value: '<prop-value0>', hidden: false } ],
|
79
|
+
scopes: [ 'scope0', 'scope1' ],
|
80
|
+
errorDescription: '<error-description>',
|
81
|
+
errorUri: '<error-uri>'
|
82
|
+
}
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
def test_setters
|
87
|
+
actual = Authlete::Model::Request::BackchannelAuthenticationCompleteRequest.new
|
88
|
+
set_params(actual)
|
89
|
+
|
90
|
+
match(actual)
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
def test_to_hash
|
95
|
+
obj = Authlete::Model::Request::BackchannelAuthenticationCompleteRequest.new
|
96
|
+
set_params(obj)
|
97
|
+
actual = obj.to_hash
|
98
|
+
expected = generate_hash
|
99
|
+
|
100
|
+
assert_equal expected, actual
|
101
|
+
end
|
102
|
+
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 BackchannelAuthenticationFailRequestTest < Minitest::Test
|
23
|
+
TICKET = '<ticket>'
|
24
|
+
REASON = 'ACCESS_DENIED'
|
25
|
+
ERROR_DESCRIPTION = '<error-description>'
|
26
|
+
ERROR_URI = '<error-uri>'
|
27
|
+
|
28
|
+
|
29
|
+
def set_params(obj)
|
30
|
+
obj.ticket = TICKET
|
31
|
+
obj.reason = REASON
|
32
|
+
obj.error_description = ERROR_DESCRIPTION
|
33
|
+
obj.error_uri = ERROR_URI
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
def match(obj)
|
38
|
+
assert_equal TICKET, obj.ticket
|
39
|
+
assert_equal REASON, obj.reason
|
40
|
+
assert_equal ERROR_DESCRIPTION, obj.errorDescription
|
41
|
+
assert_equal ERROR_URI, obj.errorUri
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
def generate_hash
|
46
|
+
{
|
47
|
+
ticket: '<ticket>',
|
48
|
+
reason: 'ACCESS_DENIED',
|
49
|
+
errorDescription: '<error-description>',
|
50
|
+
errorUri: '<error-uri>'
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
def test_setters
|
56
|
+
actual = Authlete::Model::Request::BackchannelAuthenticationFailRequest.new
|
57
|
+
set_params(actual)
|
58
|
+
|
59
|
+
match(actual)
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
def test_to_hash
|
64
|
+
obj = Authlete::Model::Request::BackchannelAuthenticationFailRequest.new
|
65
|
+
set_params(obj)
|
66
|
+
actual = obj.to_hash
|
67
|
+
expected = generate_hash
|
68
|
+
|
69
|
+
assert_equal expected, actual
|
70
|
+
end
|
71
|
+
end
|