authlete 1.26.1 → 1.27.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  # :nodoc:
2
2
  #
3
- # Copyright (C) 2014-2020 Authlete, Inc.
3
+ # Copyright (C) 2014-2022 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.
@@ -55,7 +55,7 @@ class ClientTest < Minitest::Test
55
55
  TOS_URI_VALUE = '<tos-uri0-value>'
56
56
  TOS_URIS = [ Authlete::Model::TaggedValue.new(tag: TOS_URI_TAG, value: TOS_URI_VALUE) ]
57
57
  JWKS_URI = '<jwks-uri>'
58
- JWKS = '<jwks>'
58
+ JWKS = '{"keys":[]}'
59
59
  DERIVED_SECTOR_IDENTIFIER = '<derived-sector-identifier>'
60
60
  SECTOR_IDENTIFIER_URI = '<sector-identifier-uri>'
61
61
  SUBJECT_TYPE = 'PUBLIC'
@@ -153,7 +153,7 @@ class ClientTest < Minitest::Test
153
153
  "tosUri": "<tos-uri>",
154
154
  "tosUris": [ { "tag": "<tos-uri0-tag>", "value": "<tos-uri0-value>" } ],
155
155
  "jwksUri": "<jwks-uri>",
156
- "jwks": "<jwks>",
156
+ "jwks": "{\\"keys\\":[]}",
157
157
  "derivedSectorIdentifier": "<derived-sector-identifier>",
158
158
  "sectorIdentifierUri": "<sector-identifier-uri>",
159
159
  "subjectType": "PUBLIC",
@@ -216,8 +216,8 @@ class ClientTest < Minitest::Test
216
216
  "pkceS256Required": false
217
217
  }
218
218
  JSON
219
- end
220
-
219
+ end
220
+
221
221
 
222
222
  def generate_hash
223
223
  {
@@ -245,7 +245,7 @@ class ClientTest < Minitest::Test
245
245
  tosUri: '<tos-uri>',
246
246
  tosUris: [ { tag: '<tos-uri0-tag>', value: '<tos-uri0-value>' } ],
247
247
  jwksUri: '<jwks-uri>',
248
- jwks: '<jwks>',
248
+ jwks: '{"keys":[]}',
249
249
  derivedSectorIdentifier: '<derived-sector-identifier>',
250
250
  sectorIdentifierUri: '<sector-identifier-uri>',
251
251
  subjectType: 'PUBLIC',
@@ -509,4 +509,81 @@ class ClientTest < Minitest::Test
509
509
 
510
510
  assert_equal expected, actual
511
511
  end
512
+
513
+
514
+ def test_standard_metadata_full
515
+ client = Authlete::Model::Client.new
516
+ set_params(client)
517
+
518
+ expected_response_types = ['none', 'code', 'token', 'id_token']
519
+ expected_grant_types = ['authorization_code', 'refresh_token']
520
+ expected_jwks = { "keys" => [] }
521
+
522
+ metadata = client.standard_metadata(false, false, false)
523
+
524
+ assert_equal "#{CLIENT_ID}", metadata[:client_id]
525
+ assert_equal REDIRECT_URIS, metadata[:redirect_uris]
526
+ assert_equal expected_response_types, metadata[:response_types]
527
+ assert_equal expected_grant_types, metadata[:grant_types]
528
+ assert_equal 'web', metadata[:application_type]
529
+ assert_equal CONTACTS, metadata[:contacts]
530
+ assert_equal CLIENT_NAME, metadata[:client_name]
531
+ assert_equal LOGO_URI, metadata[:logo_uri]
532
+ assert_equal CLIENT_URI, metadata[:client_uri]
533
+ assert_equal POLICY_URI, metadata[:policy_uri]
534
+ assert_equal TOS_URI, metadata[:tos_uri]
535
+ assert_equal JWKS_URI, metadata[:jwks_uri]
536
+ assert_equal expected_jwks, metadata[:jwks]
537
+ assert_equal SECTOR_IDENTIFIER_URI, metadata[:sector_identifier_uri]
538
+ assert_equal 'public', metadata[:subject_type]
539
+ assert_equal 'HS256', metadata[:id_token_signed_response_alg]
540
+ assert_equal 'PBES2-HS256+A128KW', metadata[:id_token_encrypted_response_alg]
541
+ assert_equal 'A128CBC-HS256', metadata[:id_token_encrypted_response_enc]
542
+ assert_equal 'HS256', metadata[:userinfo_signed_response_alg]
543
+ assert_equal 'PBES2-HS256+A128KW', metadata[:userinfo_encrypted_response_alg]
544
+ assert_equal 'A128CBC-HS256', metadata[:userinfo_encrypted_response_enc]
545
+ assert_equal 'HS256', metadata[:request_object_signing_alg]
546
+ assert_equal 'PBES2-HS256+A128KW', metadata[:request_object_encryption_alg]
547
+ assert_equal 'A128CBC-HS256', metadata[:request_object_encryption_enc]
548
+ assert_equal 'client_secret_basic', metadata[:token_endpoint_auth_method]
549
+ assert_equal 'HS256', metadata[:token_endpoint_auth_signing_alg]
550
+ assert_equal DEFAULT_MAX_AGE, metadata[:default_max_age]
551
+ assert_equal DEFAULT_ACRS, metadata[:default_acr_values]
552
+ assert_equal AUTH_TIME_REQUIRED, metadata[:require_auth_time]
553
+ assert_equal LOGIN_URI, metadata[:initiate_login_uri]
554
+ assert_equal REQUEST_URIS, metadata[:request_uris]
555
+ assert_equal TLS_CLIENT_AUTH_SUBJECT_DN, metadata[:tls_client_auth_subject_dn]
556
+ assert_equal TLS_CLIENT_AUTH_SAN_DNS, metadata[:tls_client_auth_san_dns]
557
+ assert_equal TLS_CLIENT_AUTH_SAN_URI, metadata[:tls_client_auth_san_uri]
558
+ assert_equal TLS_CLIENT_AUTH_SAN_IP, metadata[:tls_client_auth_san_ip]
559
+ assert_equal TLS_CLIENT_AUTH_SAN_EMAIL, metadata[:tls_client_auth_san_email]
560
+ assert_equal TLS_CLIENT_CERTIFICATE_BOUND_ACCESS_TOKENS, metadata[:tls_client_certificate_bound_access_tokens]
561
+ assert_equal SOFTWARE_ID, metadata[:software_id]
562
+ assert_equal SOFTWARE_VERSION, metadata[:software_version]
563
+ assert_equal 'HS256', metadata[:authorization_signed_response_alg]
564
+ assert_equal 'PBES2-HS256+A128KW', metadata[:authorization_encrypted_response_alg]
565
+ assert_equal 'A128CBC-HS256', metadata[:authorization_encrypted_response_enc]
566
+ assert_equal 'poll', metadata[:backchannel_token_delivery_mode]
567
+ assert_equal BC_NOTIFICATION_ENDPOINT, metadata[:backchannel_client_notification_endpoint]
568
+ assert_equal 'HS256', metadata[:backchannel_authentication_request_signing_alg]
569
+ assert_equal BC_USER_CODE_REQUIRED, metadata[:backchannel_user_code_parameter]
570
+ assert_equal AUTHORIZATION_DETAILS_TYPES, metadata[:authorization_details_types]
571
+ assert_equal DIGEST_ALGORITHM, metadata[:digest_algorithm]
572
+ end
573
+
574
+
575
+ def test_standard_metadata_minimum
576
+ client = Authlete::Model::Client.new
577
+ set_params(client)
578
+
579
+ client.default_max_age = 0
580
+ client.auth_time_required = false
581
+ client.login_uri = nil
582
+
583
+ metadata = client.standard_metadata
584
+
585
+ assert_nil metadata[:default_max_age]
586
+ assert_nil metadata[:require_auth_time]
587
+ assert_nil metadata[:initiate_login_uri]
588
+ end
512
589
  end
@@ -1,6 +1,6 @@
1
1
  # :nodoc:
2
2
  #
3
- # Copyright (C) 2014-2020 Authlete, Inc.
3
+ # Copyright (C) 2014-2022 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.
@@ -194,6 +194,7 @@ class ServiceTest < Minitest::Test
194
194
  FEDERATION_SIGNATURE_KEY_ID = '<federation-signature-key-id>'
195
195
  FEDERATION_CONFIGURATION_DURATION = 100
196
196
  DCR_DUPLICATE_SOFTWARE_ID_BLOCKED = false
197
+ OPENID_DROPPED_ON_REFRESH_WITHOUT_OFFLINE_ACCESS = false
197
198
 
198
199
  def generate_json
199
200
  return <<~JSON
@@ -347,7 +348,8 @@ class ServiceTest < Minitest::Test
347
348
  "jwtGrantUnsignedJwtRejected": false,
348
349
  "federationSignatureKeyId": "<federation-signature-key-id>",
349
350
  "federationConfigurationDuration": 100,
350
- "dcrDuplicateSoftwareIdBlocked": false
351
+ "dcrDuplicateSoftwareIdBlocked": false,
352
+ "openidDroppedOnRefreshWithoutOfflineAccess": false
351
353
  }
352
354
  JSON
353
355
 
@@ -505,7 +507,8 @@ class ServiceTest < Minitest::Test
505
507
  jwtGrantUnsignedJwtRejected: false,
506
508
  federationSignatureKeyId: '<federation-signature-key-id>',
507
509
  federationConfigurationDuration: 100,
508
- dcrDuplicateSoftwareIdBlocked: false
510
+ dcrDuplicateSoftwareIdBlocked: false,
511
+ openidDroppedOnRefreshWithoutOfflineAccess: false
509
512
  }
510
513
  end
511
514
 
@@ -659,6 +662,7 @@ class ServiceTest < Minitest::Test
659
662
  obj.federation_signature_key_id = FEDERATION_SIGNATURE_KEY_ID
660
663
  obj.federation_configuration_duration = FEDERATION_CONFIGURATION_DURATION
661
664
  obj.dcr_duplicate_software_id_blocked = DCR_DUPLICATE_SOFTWARE_ID_BLOCKED
665
+ obj.openidDroppedOnRefreshWithoutOfflineAccess = OPENID_DROPPED_ON_REFRESH_WITHOUT_OFFLINE_ACCESS
662
666
  end
663
667
 
664
668
  def match(obj)
@@ -827,6 +831,7 @@ class ServiceTest < Minitest::Test
827
831
  assert_equal FEDERATION_SIGNATURE_KEY_ID, obj.federationSignatureKeyId
828
832
  assert_equal FEDERATION_CONFIGURATION_DURATION, obj.federationConfigurationDuration
829
833
  assert_equal DCR_DUPLICATE_SOFTWARE_ID_BLOCKED, obj.dcrDuplicateSoftwareIdBlocked
834
+ assert_equal OPENID_DROPPED_ON_REFRESH_WITHOUT_OFFLINE_ACCESS, obj.openidDroppedOnRefreshWithoutOfflineAccess
830
835
  end
831
836
 
832
837
 
@@ -0,0 +1,44 @@
1
+ # :nodoc:
2
+ #
3
+ # Copyright (C) 2022 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 ApplicationTypeTest < Minitest::Test
23
+ def do_test(input, expected)
24
+ output = Authlete::Types::ApplicationType::constant_get(input)
25
+
26
+ if expected.nil?
27
+ assert_nil output
28
+ else
29
+ assert_equal expected, output
30
+ end
31
+ end
32
+
33
+ def test_unknown
34
+ do_test('UNKNOWN', nil)
35
+ end
36
+
37
+ def test_web
38
+ do_test('WEB', 'web')
39
+ end
40
+
41
+ def test_native
42
+ do_test('NATIVE', 'native')
43
+ end
44
+ end
@@ -0,0 +1,64 @@
1
+ # :nodoc:
2
+ #
3
+ # Copyright (C) 2022 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 ClientAuthMethodTest < Minitest::Test
23
+ def do_test(input, expected)
24
+ output = Authlete::Types::ClientAuthMethod::constant_get(input)
25
+
26
+ if expected.nil?
27
+ assert_nil output
28
+ else
29
+ assert_equal expected, output
30
+ end
31
+ end
32
+
33
+ def test_unknown
34
+ do_test('UNKNOWN', nil)
35
+ end
36
+
37
+ def test_none
38
+ do_test('NONE', 'none')
39
+ end
40
+
41
+ def test_client_secret_basic
42
+ do_test('CLIENT_SECRET_BASIC', 'client_secret_basic')
43
+ end
44
+
45
+ def test_client_secret_post
46
+ do_test('CLIENT_SECRET_POST', 'client_secret_post')
47
+ end
48
+
49
+ def test_client_secret_jwt
50
+ do_test('CLIENT_SECRET_JWT', 'client_secret_jwt')
51
+ end
52
+
53
+ def test_private_key_jwt
54
+ do_test('PRIVATE_KEY_JWT', 'private_key_jwt')
55
+ end
56
+
57
+ def test_tls_client_auth
58
+ do_test('TLS_CLIENT_AUTH', 'tls_client_auth')
59
+ end
60
+
61
+ def test_self_signed_tls_client_auth
62
+ do_test('SELF_SIGNED_TLS_CLIENT_AUTH', 'self_signed_tls_client_auth')
63
+ end
64
+ end
@@ -0,0 +1,48 @@
1
+ # :nodoc:
2
+ #
3
+ # Copyright (C) 2022 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 DeliveryModeTest < Minitest::Test
23
+ def do_test(input, expected)
24
+ output = Authlete::Types::DeliveryMode::constant_get(input)
25
+
26
+ if expected.nil?
27
+ assert_nil output
28
+ else
29
+ assert_equal expected, output
30
+ end
31
+ end
32
+
33
+ def test_unknown
34
+ do_test('UNKNOWN', nil)
35
+ end
36
+
37
+ def test_poll
38
+ do_test('POLL', 'poll')
39
+ end
40
+
41
+ def test_ping
42
+ do_test('PING', 'ping')
43
+ end
44
+
45
+ def test_push
46
+ do_test('PUSH', 'push')
47
+ end
48
+ end
@@ -0,0 +1,72 @@
1
+ # :nodoc:
2
+ #
3
+ # Copyright (C) 2022 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 GrantTypeTest < Minitest::Test
23
+ def do_test(input, expected)
24
+ output = Authlete::Types::GrantType::constant_get(input)
25
+
26
+ if expected.nil?
27
+ assert_nil output
28
+ else
29
+ assert_equal expected, output
30
+ end
31
+ end
32
+
33
+ def test_unknown
34
+ do_test('UNKNOWN', nil)
35
+ end
36
+
37
+ def test_authorization_code
38
+ do_test('AUTHORIZATION_CODE', 'authorization_code')
39
+ end
40
+
41
+ def test_implicit
42
+ do_test('IMPLICIT', 'implicit')
43
+ end
44
+
45
+ def test_password
46
+ do_test('PASSWORD', 'password')
47
+ end
48
+
49
+ def test_client_credentials
50
+ do_test('CLIENT_CREDENTIALS', 'client_credentials')
51
+ end
52
+
53
+ def test_refresh_token
54
+ do_test('REFRESH_TOKEN', 'refresh_token')
55
+ end
56
+
57
+ def test_ciba
58
+ do_test('CIBA', 'urn:openid:params:grant-type:ciba')
59
+ end
60
+
61
+ def test_device_code
62
+ do_test('DEVICE_CODE', 'urn:ietf:params:oauth:grant-type:device_code')
63
+ end
64
+
65
+ def test_token_exchange
66
+ do_test('TOKEN_EXCHANGE', 'urn:ietf:params:oauth:grant-type:token-exchange')
67
+ end
68
+
69
+ def test_jwt_bearer
70
+ do_test('JWT_BEARER', 'urn:ietf:params:oauth:grant-type:jwt-bearer')
71
+ end
72
+ end
@@ -0,0 +1,104 @@
1
+ # :nodoc:
2
+ #
3
+ # Copyright (C) 2022 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 JWEAlgTest < Minitest::Test
23
+ def do_test(input, expected)
24
+ output = Authlete::Types::JWEAlg::constant_get(input)
25
+
26
+ if expected.nil?
27
+ assert_nil output
28
+ else
29
+ assert_equal expected, output
30
+ end
31
+ end
32
+
33
+ def test_unknown
34
+ do_test('UNKNOWN', nil)
35
+ end
36
+
37
+ def test_rsa1_5
38
+ do_test('RSA1_5', 'RSA1_5')
39
+ end
40
+
41
+ def test_oaep
42
+ do_test('RSA_OAEP', 'RSA-OAEP')
43
+ end
44
+
45
+ def test_oaep_256
46
+ do_test('RSA_OAEP_256', 'RSA-OAEP-256')
47
+ end
48
+
49
+ def test_a128kw
50
+ do_test('A128KW', 'A128KW')
51
+ end
52
+
53
+ def test_a192kw
54
+ do_test('A192KW', 'A192KW')
55
+ end
56
+
57
+ def test_a256kw
58
+ do_test('A256KW', 'A256KW')
59
+ end
60
+
61
+ def test_dir
62
+ do_test('DIR', 'dir')
63
+ end
64
+
65
+ def test_ecdh_es
66
+ do_test('ECDH_ES', 'ECDH-ES')
67
+ end
68
+
69
+ def test_ecdh_es_a128kw
70
+ do_test('ECDH_ES_A128KW', 'ECDH-ES+A128KW')
71
+ end
72
+
73
+ def test_ecdh_es_a192kw
74
+ do_test('ECDH_ES_A192KW', 'ECDH-ES+A192KW')
75
+ end
76
+
77
+ def test_ecdh_es_a256kw
78
+ do_test('ECDH_ES_A256KW', 'ECDH-ES+A256KW')
79
+ end
80
+
81
+ def test_a128gcmkw
82
+ do_test('A128GCMKW', 'A128GCMKW')
83
+ end
84
+
85
+ def test_a192gcmkw
86
+ do_test('A192GCMKW', 'A192GCMKW')
87
+ end
88
+
89
+ def test_a256gcmkw
90
+ do_test('A256GCMKW', 'A256GCMKW')
91
+ end
92
+
93
+ def test_pbes2_hs256_a128kw
94
+ do_test('PBES2_HS256_A128KW', 'PBES2-HS256+A128KW')
95
+ end
96
+
97
+ def test_pbes2_hs384_a192kw
98
+ do_test('PBES2_HS384_A192KW', 'PBES2-HS384+A192KW')
99
+ end
100
+
101
+ def test_pbes2_hs512_a256kw
102
+ do_test('PBES2_HS512_A256KW', 'PBES2-HS512+A256KW')
103
+ end
104
+ end
@@ -0,0 +1,60 @@
1
+ # :nodoc:
2
+ #
3
+ # Copyright (C) 2022 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 JWEEncTest < Minitest::Test
23
+ def do_test(input, expected)
24
+ output = Authlete::Types::JWEEnc::constant_get(input)
25
+
26
+ if expected.nil?
27
+ assert_nil output
28
+ else
29
+ assert_equal expected, output
30
+ end
31
+ end
32
+
33
+ def test_unknown
34
+ do_test('UNKNOWN', nil)
35
+ end
36
+
37
+ def test_a128cbc_hs256
38
+ do_test('A128CBC_HS256', 'A128CBC-HS256')
39
+ end
40
+
41
+ def test_a192cbc_hs384
42
+ do_test('A192CBC_HS384', 'A192CBC-HS384')
43
+ end
44
+
45
+ def test_a256cbc_hs512
46
+ do_test('A256CBC_HS512', 'A256CBC-HS512')
47
+ end
48
+
49
+ def test_a128gcm
50
+ do_test('A128GCM', 'A128GCM')
51
+ end
52
+
53
+ def test_a192gcm
54
+ do_test('A192GCM', 'A192GCM')
55
+ end
56
+
57
+ def test_a256gcm
58
+ do_test('A256GCM', 'A256GCM')
59
+ end
60
+ end
@@ -0,0 +1,96 @@
1
+ # :nodoc:
2
+ #
3
+ # Copyright (C) 2022 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 JWSAlgTest < Minitest::Test
23
+ def do_test(input, expected)
24
+ output = Authlete::Types::JWSAlg::constant_get(input)
25
+
26
+ if expected.nil?
27
+ assert_nil output
28
+ else
29
+ assert_equal expected, output
30
+ end
31
+ end
32
+
33
+ def test_unknown
34
+ do_test('UNKNOWN', nil)
35
+ end
36
+
37
+ def test_none
38
+ do_test('NONE', 'none')
39
+ end
40
+
41
+ def test_hs256
42
+ do_test('HS256', 'HS256')
43
+ end
44
+
45
+ def test_hs384
46
+ do_test('HS384', 'HS384')
47
+ end
48
+
49
+ def test_hs512
50
+ do_test('HS512', 'HS512')
51
+ end
52
+
53
+ def test_rs256
54
+ do_test('RS256', 'RS256')
55
+ end
56
+
57
+ def test_rs384
58
+ do_test('RS384', 'RS384')
59
+ end
60
+
61
+ def test_rs512
62
+ do_test('RS512', 'RS512')
63
+ end
64
+
65
+ def test_es256
66
+ do_test('ES256', 'ES256')
67
+ end
68
+
69
+ def test_es384
70
+ do_test('ES384', 'ES384')
71
+ end
72
+
73
+ def test_es512
74
+ do_test('ES512', 'ES512')
75
+ end
76
+
77
+ def test_ps256
78
+ do_test('PS256', 'PS256')
79
+ end
80
+
81
+ def test_ps384
82
+ do_test('PS384', 'PS384')
83
+ end
84
+
85
+ def test_ps512
86
+ do_test('PS512', 'PS512')
87
+ end
88
+
89
+ def test_es256k
90
+ do_test('ES256K', 'ES256K')
91
+ end
92
+
93
+ def test_eddsa
94
+ do_test('EdDSA', 'EdDSA')
95
+ end
96
+ end