|
287 | 287 | it "can change the value" do |
288 | 288 | Doorkeeper.configure do |
289 | 289 | orm DOORKEEPER_ORM |
290 | | - client_credentials :from_digest, :from_params |
| 290 | + client_credentials :from_basic |
291 | 291 | end |
292 | 292 |
|
293 | 293 | expect(config.client_credentials_methods) |
294 | | - .to eq(%i[from_digest from_params]) |
| 294 | + .to eq(%i[from_basic]) |
| 295 | + end |
| 296 | + end |
| 297 | + |
| 298 | + # Returns token endpoint auth methods based on client_credentials per |
| 299 | + # https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml#token-endpoint-auth-method |
| 300 | + describe 'token_endpoint_auth_methods' do |
| 301 | + it 'returns methods according to defaults' do |
| 302 | + expect(config.client_credentials_methods).to eq(%i[from_basic from_params]) |
| 303 | + expect(config.token_endpoint_auth_methods).to contain_exactly('none', 'client_secret_post', 'client_secret_basic') |
| 304 | + end |
| 305 | + |
| 306 | + it "returns none even if no methods are configured" do |
| 307 | + Doorkeeper.configure do |
| 308 | + orm DOORKEEPER_ORM |
| 309 | + client_credentials |
| 310 | + end |
| 311 | + |
| 312 | + expect(config.client_credentials_methods) |
| 313 | + .to eq([]) |
| 314 | + |
| 315 | + expect(config.token_endpoint_auth_methods).to contain_exactly('none') |
| 316 | + end |
| 317 | + |
| 318 | + it 'returns client_secret_post if configured' do |
| 319 | + Doorkeeper.configure do |
| 320 | + orm DOORKEEPER_ORM |
| 321 | + client_credentials :from_params |
| 322 | + end |
| 323 | + |
| 324 | + expect(config.client_credentials_methods) |
| 325 | + .to eq(%i[from_params]) |
| 326 | + |
| 327 | + expect(config.token_endpoint_auth_methods).to contain_exactly('none', 'client_secret_post') |
| 328 | + end |
| 329 | + |
| 330 | + it 'returns client_secret_basic if configured' do |
| 331 | + Doorkeeper.configure do |
| 332 | + orm DOORKEEPER_ORM |
| 333 | + client_credentials :from_basic |
| 334 | + end |
| 335 | + |
| 336 | + expect(config.client_credentials_methods) |
| 337 | + .to eq(%i[from_basic]) |
| 338 | + |
| 339 | + expect(config.token_endpoint_auth_methods).to contain_exactly('none', 'client_secret_basic') |
295 | 340 | end |
296 | 341 | end |
297 | 342 |
|
|
0 commit comments