Skip to content

Commit 9f68c0e

Browse files
committed
Update yard doc. (+1 squashed commit)
Squashed commits: [2b827f5] Options pass through to oauth2 client.
1 parent aea28ec commit 9f68c0e

File tree

2 files changed

+38
-45
lines changed

2 files changed

+38
-45
lines changed

lib/jira/oauth2_client.rb

+26-12
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module JIRA
55
#
66
# == OAuth 2.0 Overview
77
#
8-
# OAuth 2.0 sepearates the roles of Resource Server and Authentication Server.
8+
# OAuth 2.0 separates the roles of Resource Server and Authentication Server.
99
#
1010
# The Resource Server will be Jira.
1111
# The Authentication Server can be Jira or some other OAuth 2.0 Authentication server.
@@ -94,12 +94,16 @@ module JIRA
9494
# @return [String] The CLIENT ID registered with the Authentication Server
9595
# @!attribute [r] client_secret
9696
# @return [String] The CLIENT SECRET registered with the Authentication Server
97-
# @!attribute [r] cstf_state
97+
# @!attribute [r] csrf_state
9898
# @return [String] An unpredictable value which a CSRF forger would not be able to provide
9999
# @!attribute [r] oauth2_client
100100
# @return [OAuth2::Client] The oauth2 gem client object used.
101-
# @!attribute [r] options
101+
# @!attribute [r] oauth2_client_options
102102
# @return [Hash] The oauth2 gem options for the client object.
103+
# @!attribute [r] prior_grant_type
104+
# @return [String] The grant type used to create the current Access Token.
105+
# @!attribute [r] access_token
106+
# @return [OAuth2::AccessToken] An object for the Access Token.
103107
#
104108
class Oauth2Client < RequestClient
105109

@@ -117,26 +121,36 @@ class Oauth2Client < RequestClient
117121
}.freeze
118122

119123
attr_reader :prior_grant_type, :access_token
120-
# attr_reader :options
121124
attr_reader :oauth2_client_options, :client_id, :client_secret, :csrf_state
125+
# attr_reader :options
122126

123-
# @param [Hash] options
124-
# @option options [String] :client_id The registered client id
125-
# @option options [String] :client_secret The registered client secret
126-
# @option options [String] :site The hostname of the Authentication Server
127-
# @option options [String] :authorize_url The Authorization Request URI (default '/rest/oauth2/latest/authorize')
128-
# @option options [String] :token_url The Jira Resource Server Access Request URI (default '/rest/oauth2/latest/token')
129-
# @option options [String] :auth_scheme Way of passing parameters for authentication (default 'request_body')
127+
# @param [Hash] options Options as passed from JIRA::Client constructor.
128+
# @option options [String] :site The hostname of the Jira in the role as Resource Server
129+
# @option options [String] :auth_site The hostname of the Authentication Server
130+
# @option options [String] :client_id The OAuth 2.0 client id as registered with the Authentication Server
131+
# @option options [String] :client_secret The OAuth 2.0 client secret as registered with the Authentication Server
132+
# @option options [String] :auth_scheme Way of passing parameters for authentication (defaults to 'request_body')
133+
# @option options [String] :authorize_url The Authorization Request URI (defaults to '/rest/oauth2/latest/authorize')
134+
# @option options [String] :token_url The Jira Resource Server Access Request URI (defaults to '/rest/oauth2/latest/token')
130135
# @option options [String] :redirect_uri Callback for result of Authentication Request
136+
# @option options [Integer] :max_redirects Number of redirects allowed
137+
# @option options [Hash] :default_headers Additional headers for requests
138+
# @option options [Boolean] :use_ssl true if using HTTPS, false for HTTP
139+
# @option options [Integer] :ssl_verify_mode OpenSSL::SSL::VERIFY_PEER or OpenSSL::SSL::VERIFY_NONE
140+
# @option options [String] :cert_path Full path to certificate verifying server identity.
141+
# @option options [String] :ssl_client_cert Path to client public key certificate.
142+
# @option options [String] :ssl_client_key Path to client private key.
143+
# @option options [Symbol] :ssl_version Version of TLS or SSL, (e.g. :TLSv1_2)
131144
# @option options [String] :proxy_uri Proxy URI
132145
# @option options [String] :proxy_user Proxy user
133146
# @option options [String] :proxy_password Proxy Password
134-
def initialize(options = {})
147+
def initialize(options)
135148
# @options = init_oauth2_options(options)
136149
init_oauth2_options(options)
137150
if options.has_key?(:access_token_options)
138151
@access_token = access_token_from_options(options[:access_token_options])
139152
end
153+
nil
140154
end
141155

142156
# @private

spec/jira/oauth2_client_spec.rb

+12-33
Original file line numberDiff line numberDiff line change
@@ -93,38 +93,6 @@ def query_params_to_h(uri)
9393
expect(request_client.oauth2_client.site).to eq(site)
9494
expect(request_client.oauth2_client.id).to eq(client_id)
9595
expect(request_client.oauth2_client.secret).to eq(client_secret)
96-
# authorize_url: 'oauth/authorize',
97-
# redirect_uri: ?
98-
# authorize_url: ?
99-
# token_url: 'oauth/token',
100-
# token_method: :post,
101-
# auth_scheme: :basic_auth,
102-
# connection_opts: {}, # <-- Faraday
103-
# connection_build: block,
104-
# max_redirects: 5,
105-
# raise_errors: true,
106-
# logger: ::Logger.new($stdout),
107-
# access_token_class: AccessToken,
108-
# Faraday:
109-
# # @option options [Hash] :params Hash of unencoded URI query params.
110-
# # @option options [Hash] :headers Hash of unencoded HTTP headers.
111-
# # @option options [Hash] :request Hash of request options.
112-
# # @option options [Hash] :ssl Hash of SSL options.
113-
# # @option options [Hash] :proxy Hash of Proxy options.
114-
# expect(request_client.oauth2_client_options[:auth_scheme]).to eq(JIRA::Oauth2Client::DEFAULT_AUTHORIZE_OPTIONS[:auth_scheme])
115-
# expect(request_client.oauth2_client_options[:authorize_url]).to eq(JIRA::Oauth2Client::DEFAULT_AUTHORIZE_OPTIONS[:authorize_url])
116-
# expect(request_client.options[:token_url]).to eq(JIRA::Oauth2Client::DEFAULT_OPTIONS[:token_url])
117-
# use_ssl: config.tls,
118-
# ssl_verify_mode: ('verify-none' == config.verify_mode ? OpenSSL::SSL::VERIFY_NONE : OpenSSL::SSL::VERIFY_PEER),
119-
# cert_path: config.ca_cert_file,
120-
# read_timeout: config.read_timeout,
121-
#
122-
#:verify => OpenSSL::SSL::VERIFY_NONE
123-
# version: :TLSv1_2
124-
# :client_cert => ...,
125-
# :client_key => ...,
126-
# :ca_file => ...,
127-
# :ca_path => ...,
12896
end
12997
end
13098

@@ -192,7 +160,18 @@ def query_params_to_h(uri)
192160
end
193161

194162
context 'passing options to oauth2 client' do
195-
it 'passes oauth2 client options to creating oauth2 client'
163+
let(:oauth2_client) { instance_double(OAuth2::Client) }
164+
subject(:request_client) do
165+
JIRA::Oauth2Client.new(full_options)
166+
end
167+
168+
it 'passes oauth2 client options to creating oauth2 client' do
169+
expect(OAuth2::Client).to receive(:new).with(client_id, client_secret, request_client.oauth2_client_options).and_return(oauth2_client)
170+
171+
oauth2_client_result = request_client.oauth2_client
172+
173+
expect(oauth2_client_result).to eq(oauth2_client)
174+
end
196175
end
197176
end
198177
end

0 commit comments

Comments
 (0)