Class: DaVinciCRDTestKit::CRDClientRegistrationVerification
- Inherits:
-
Inferno::Test
- Object
- Inferno::Test
- DaVinciCRDTestKit::CRDClientRegistrationVerification
- Includes:
- URLs
- Defined in:
- lib/davinci_crd_test_kit/client_tests/client_registration_verification_test.rb
Instance Method Summary collapse
-
#jwk_set(jku, warning_messages = []) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity.
Methods included from URLs
#appointment_book_url, #base_url, #encounter_discharge_url, #encounter_start_url, #order_dispatch_url, #order_select_url, #order_sign_url, #resume_fail_url, #resume_pass_url, #suite_id
Instance Method Details
#jwk_set(jku, warning_messages = []) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/davinci_crd_test_kit/client_tests/client_registration_verification_test.rb', line 43 def jwk_set(jku, = []) # rubocop:disable Metrics/CyclomaticComplexity jwk_set = JWT::JWK::Set.new if jku.blank? << 'No key set input.' return jwk_set end jwk_body = # try as raw jwk set begin JSON.parse(jku) rescue JSON::ParserError nil end if jwk_body.blank? retrieved = Faraday.get(jku) # try as url pointing to a jwk set jwk_body = begin JSON.parse(retrieved.body) rescue JSON::ParserError << "Failed to fetch valid json from jwks uri #{jku}." nil end else << 'Providing the JWK Set directly is strongly discouraged.' end return jwk_set if jwk_body.blank? jwk_body['keys']&.each_with_index do |key_hash, index| parsed_key = begin JWT::JWK.new(key_hash) rescue JWT::JWKError => e id = key_hash['kid'] | index << "Key #{id} invalid: #{e}" nil end jwk_set << parsed_key unless parsed_key.blank? end jwk_set end |