inferno_core 0.4.38 → 0.4.39

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2af0569e09addd1d815e42110f9813a875037b66a67871af0441a149b38c818
4
- data.tar.gz: 4b526226bac3009548c7e70b75b59dc77e9c800700eed13e13846d30cbc79161
3
+ metadata.gz: 1c569fc01e07576cb3aa512c37a69d730bc7b9848bd24ed95935b23a0d52759c
4
+ data.tar.gz: 41165f4f56dcf7c7e552ec0c391b868e5020feed0957f12d508489835a91d140
5
5
  SHA512:
6
- metadata.gz: c0ab492c234d9a19ee06cca497a1e9714238bd1b7b0a2765b3647a49e0f3125a7a3b3f73e025e9741ec71b67c695d78258480d22aaf8974f8002b0354a0c0bdc
7
- data.tar.gz: 241271ec1ef24731b06446dd442485fb8053f43504e3948a29077e26358b6b515102f41671336577c54b6705cb3858b7c59e0ac53819eadde5243ea98c16f8b2
6
+ metadata.gz: 03cb4fec0a859ba0967d891b62d4741b6a241839bce017ac0a9f212c06cabbec45e3d8c9464d8a75421c697c6e547af19e5bdbe8055ab7ea630344a781dfdf5e
7
+ data.tar.gz: ad2fc2e5f42777535e912e4bc8217f48d9d90babb074b071b7437fb3b987f4f8470f505f9e1bd29b1b893f7b6ccc36800145ad62fe82664188e0eab965b71cf5
@@ -27,20 +27,24 @@ module Inferno
27
27
  desc: 'Automatically restart Inferno when a file is changed.'
28
28
  def start
29
29
  Migration.new.run(Logger::INFO)
30
- command = 'foreman start --env=/dev/null'
31
- if `gem list -i foreman`.chomp == 'false'
32
- puts "You must install foreman with 'gem install foreman' prior to running Inferno."
33
- end
34
30
 
35
- if options[:watch]
36
- if `gem list -i rerun`.chomp == 'false'
37
- puts "You must install 'rerun' with 'gem install rerun' to restart on file changes."
31
+ without_bundler do
32
+ command = 'foreman start --env=/dev/null'
33
+
34
+ if `gem list -i foreman`.chomp == 'false'
35
+ puts "You must install foreman with 'gem install foreman' prior to running Inferno."
38
36
  end
39
37
 
40
- command = "rerun \"#{command}\" --background"
41
- end
38
+ if options[:watch]
39
+ if `gem list -i rerun`.chomp == 'false'
40
+ puts "You must install 'rerun' with 'gem install rerun' to restart on file changes."
41
+ end
42
+
43
+ command = "rerun \"#{command}\" --background"
44
+ end
42
45
 
43
- exec command
46
+ exec command
47
+ end
44
48
  end
45
49
 
46
50
  desc 'suites', 'List available test suites'
@@ -60,6 +64,19 @@ module Inferno
60
64
  def version
61
65
  puts "Inferno Core v#{Inferno::VERSION}"
62
66
  end
67
+
68
+ private
69
+
70
+ # https://github.com/rubocop/rubocop/issues/12571 - still affects Ruby 3.1 upto Rubocop 1.63
71
+ # rubocop:disable Naming/BlockForwarding
72
+ def without_bundler(&block)
73
+ if defined?(Bundler) && ENV['BUNDLE_GEMFILE']
74
+ Bundler.with_unbundled_env(&block)
75
+ else
76
+ yield
77
+ end
78
+ end
79
+ # rubocop:enable Naming/BlockForwarding
63
80
  end
64
81
  end
65
82
  end
@@ -21,7 +21,7 @@ module <%= module_name %>
21
21
  oauth_credentials :credentials
22
22
  end
23
23
 
24
- # All FHIR validation requsets will use this FHIR validator
24
+ # All FHIR validation requests will use this FHIR validator
25
25
  fhir_resource_validator do
26
26
  # igs 'identifier#version' # Use this method for published IGs/versions
27
27
  # igs 'igs/filename.tgz' # Use this otherwise
@@ -0,0 +1,174 @@
1
+ require_relative '../entities/attributes'
2
+
3
+ module Inferno
4
+ module DSL
5
+ # AuthInfo provide a user with a single input which contains the information
6
+ # needed for a fhir client to perform authorization and refresh an access
7
+ # token when necessary.
8
+ #
9
+ # AuthInfo supports the following `auth_type`:
10
+ # - `public` - client id only
11
+ # - `symmetric` - Symmetric confidential (i.e., with a static client id and
12
+ # secret)
13
+ # - `asymmetric` - Symmetric confidential (i.e., a client id with a signed
14
+ # JWT rather than a client secret)
15
+ # - `backend_services`
16
+ #
17
+ # When configuring an AuthInfo input, the invdidual fields are exposed as
18
+ # `components` in the input's options, and can be configured there similar
19
+ # to normal inputs.
20
+ #
21
+ # The AuthInfo input type supports two different modes in the UI. Different
22
+ # fields will be presented to the user dependengi on which mode is selected.
23
+ # - `auth` - This presents the inputs needed to perform authorization, and
24
+ # is appropriate to use as an input to test groups which perform
25
+ # authorization
26
+ # - `access` - This presents the inputs needed to access resources assuming
27
+ # that authorization has already happened, and is appropriate to use as an
28
+ # input to test groups which access resources using previously granted
29
+ # authorization
30
+ #
31
+ # @example
32
+ # class AuthInfoExampleSuite < Inferno::TestSuite
33
+ # input :url,
34
+ # title: 'Base FHIR url'
35
+ #
36
+ # group do
37
+ # title 'Perform public authorization'
38
+ # input :fhir_auth,
39
+ # type: :auth_info,
40
+ # options: {
41
+ # mode: 'auth',
42
+ # components: [
43
+ # {
44
+ # name: :auth_type,
45
+ # default: 'public',
46
+ # locked: true
47
+ # }
48
+ # ]
49
+ # }
50
+ #
51
+ # # Some tests here to perform authorization
52
+ # end
53
+ #
54
+ # group do
55
+ # title 'FHIR API Tests'
56
+ # input :fhir_auth,
57
+ # type: :auth_info,
58
+ # options: {
59
+ # mode: 'access'
60
+ # }
61
+ #
62
+ # fhir_client do
63
+ # url :url
64
+ # auth_info :fhir_auth # NOT YET IMPLEMENTED
65
+ # end
66
+ #
67
+ # # Some tests here to access FHIR API
68
+ # end
69
+ # end
70
+ class AuthInfo
71
+ ATTRIBUTES = [
72
+ :auth_type,
73
+ :use_discovery,
74
+ :token_url,
75
+ :auth_url,
76
+ :requested_scopes,
77
+ :client_id,
78
+ :client_secret,
79
+ :redirect_url, # TODO: does this belong here?
80
+ :pkce_support,
81
+ :pkce_code_challenge_method,
82
+ :auth_request_method,
83
+ :encryption_algorithm,
84
+ :kid,
85
+ :jwks,
86
+ :access_token,
87
+ :refresh_token,
88
+ :issue_time,
89
+ :expires_in,
90
+ :name
91
+ ].freeze
92
+
93
+ include Entities::Attributes
94
+
95
+ attr_accessor :client
96
+
97
+ # @!attribute [rw] auth_type The type of authorization to be performed.
98
+ # One of `public`, `symmetric`, `asymmetric`, or `backend_services`
99
+ # @!attribute [rw] token_url The url of the auth server's token endpoint
100
+ # @!attribute [rw] auth_url The url of the authorization endpoint
101
+ # @!attribute [rw] requested_scopes The scopes which will be requested
102
+ # during authorization
103
+ # @!attribute [rw] client_id
104
+ # @!attribute [rw] client_secret
105
+ # @!attribute [rw] redirect_url
106
+ # @!attribute [rw] pkce_support Whether PKCE will be used during
107
+ # authorization. Either `enabled` or `disabled`.
108
+ # @!attribute [rw] pkce_code_challenge_method Either `S256` (default) or
109
+ # `plain`
110
+ # @!attribute [rw] auth_request_method The http method which will be used
111
+ # to perform the request to the authorization endpoint. Either `get`
112
+ # (default) or `post`
113
+ # @!attribute [rw] encryption_algorithm The encryption algorithm which
114
+ # will be used to sign the JWT client credentials. Either `es384`
115
+ # (default) or `rs384`
116
+ # @!attribute [rw] kid The key id for the keys to be used to sign the JWT
117
+ # client credentials. When blank, the first key for the selected
118
+ # encryption algorithm will be used
119
+ # @!attribute [rw] jwks A JWKS (including private keys) which will be used
120
+ # instead of Inferno's default JWKS if provided
121
+ # @!attribute [rw] access_token
122
+ # @!attribute [rw] refresh_token
123
+ # @!attribute [rw] issue_time An iso8601 formatted string representing the
124
+ # time the access token was issued
125
+ # @!attribute [rw] expires_in The lifetime of the access token in seconds
126
+ # @!attribute [rw] name
127
+
128
+ # @private
129
+ def initialize(raw_attributes_hash)
130
+ attributes_hash = raw_attributes_hash.symbolize_keys
131
+
132
+ invalid_keys = attributes_hash.keys - ATTRIBUTES
133
+
134
+ raise Exceptions::UnknownAttributeException.new(invalid_keys, self.class) if invalid_keys.present?
135
+
136
+ attributes_hash.each do |name, value|
137
+ value = DateTime.parse(value) if name == :issue_time && value.is_a?(String)
138
+
139
+ instance_variable_set(:"@#{name}", value)
140
+ end
141
+
142
+ self.issue_time = DateTime.now if access_token.present? && issue_time.blank?
143
+ end
144
+
145
+ # @private
146
+ def to_hash
147
+ self.class::ATTRIBUTES.each_with_object({}) do |attribute, hash|
148
+ value = send(attribute)
149
+ next if value.nil?
150
+
151
+ value = issue_time.iso8601 if attribute == :issue_time
152
+
153
+ hash[attribute] = value
154
+ end
155
+ end
156
+
157
+ # @private
158
+ def to_s
159
+ JSON.generate(to_hash)
160
+ end
161
+
162
+ # @private
163
+ def add_to_client(client)
164
+ # TODO
165
+ # client.auth = self
166
+ # self.client = client
167
+
168
+ # return unless access_token.present?
169
+
170
+ # client.set_bearer_token(access_token)
171
+ end
172
+ end
173
+ end
174
+ end
@@ -289,7 +289,6 @@ module Inferno
289
289
  uri.query = env['rack.request.query_string'] if env['rack.request.query_string'].present?
290
290
  url = uri&.to_s
291
291
  verb = env['REQUEST_METHOD']
292
- logger.info('get body')
293
292
  request_body = env['rack.input']
294
293
  request_body.rewind if env['rack.input'].respond_to? :rewind
295
294
  request_body = request_body.instance_of?(Puma::NullIO) ? nil : request_body.string