Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/applications.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ OPTIONS
modes) of the application to be
created.
--description=<value> Application description
--redirect-url=<value> OpenID Connect redirect url
--user-key=<value> User Key (API Key) of the application
to be created.
```
Expand Down Expand Up @@ -130,6 +131,7 @@ OPTIONS
--name=<value> Application name
--plan=<value> Application's plan. Required when
creating
--redirect-url=<value> OpenID Connect redirect url
--resume Resume a suspended application
--service=<value> Application's service. Required when
creating
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def self.command
option nil, :account, 'Application\'s account. Required when creating', argument: :required
option nil, :service, 'Application\'s service. Required when creating', argument: :required
option nil, :plan, 'Application\'s plan. Required when creating', argument: :required
option nil, :'redirect-url', 'OpenID Connect redirect url', argument: :required
flag nil, :resume, 'Resume a suspended application'
flag nil, :suspend, 'Suspends an application (changes the state to suspended)'
param :remote
Expand Down Expand Up @@ -87,6 +88,7 @@ def create_app_attrs
'user_key' => application_ref,
'application_id' => application_ref,
'application_key' => option_app_key,
'redirect_url' => option_redirect_url,
}.compact
end

Expand All @@ -97,6 +99,7 @@ def app_attrs
'name' => option_name,
'description' => description,
'user_key' => option_user_key,
'redirect_url' => option_redirect_url,
}.compact
end

Expand Down Expand Up @@ -180,6 +183,10 @@ def option_suspend
def application_ref
arguments[:application]
end

def option_redirect_url
options[:'redirect-url']
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def self.command
option nil, 'application-id', 'App ID or Client ID (for OAuth and OpenID Connect authentication modes) of the application to be created. ', argument: :required
option nil, 'application-key', 'App Key(s) or Client Secret (for OAuth and OpenID Connect authentication modes) of the application to be created.' , argument: :required
option nil, :description, 'Application description', argument: :required
option nil, :'redirect-url', 'OpenID Connect redirect url', argument: :required
param :remote
param :account
param :service
Expand Down Expand Up @@ -45,7 +46,8 @@ def app_attrs
'description' => description,
'user_key' => options[:'user-key'],
'application_id' => options[:'application-id'],
'application_key' => options[:'application-key']
'application_key' => options[:'application-key'],
'redirect_url' => options[:'redirect-url'],
}.compact
end

Expand Down
22 changes: 21 additions & 1 deletion spec/unit/commands/application_command/apply_command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@
expect { subject.run }.to output(/Applied application id: 1/).to_stdout
end
end

context 'redirect_url opt given' do
let(:options) { { 'redirect-url': 'https://example.com/callback' } }

it 'application updated with redirect url' do
expect(application).to receive(:update).with(hash_including('redirect_url' => 'https://example.com/callback'))
expect { subject.run }.to output(/Applied application id: 1/).to_stdout
end
end
end

context 'application not found' do
Expand Down Expand Up @@ -283,7 +292,8 @@
plan: 'myplan',
name: 'myname',
description: 'mydescr',
'application-key': 'appKey'
'application-key': 'appKey',
'redirect-url': 'https://example.com/callback'
}
end

Expand Down Expand Up @@ -337,6 +347,16 @@
.and_return(application)
expect { subject.run }.to output(/Applied application id: 1/).to_stdout
end

it 'redirect-url is included' do
expect(application_class).to receive(:create)
.with(
remote: remote, account_id: account_id, plan_id: 'planId',
app_attrs: hash_including('redirect_url' => 'https://example.com/callback')
)
.and_return(application)
expect { subject.run }.to output(/Applied application id: 1/).to_stdout
end
end
end
end
Expand Down
17 changes: 17 additions & 0 deletions spec/unit/commands/application_command/create_command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,23 @@
expect { subject.run }.to output(/Created application id: 200/).to_stdout
end
end

context 'redirect-url opt given' do
let(:options) { { 'redirect-url': 'https://example.com/callback' } }
let(:expected_app_attrs) do
{
'redirect_url' => 'https://example.com/callback', 'name' => 'myapp',
'description' => 'myapp'
}
end

it 'redirect_url param sent' do
expect(application_class).to receive(:create).with(hash_including(app_attrs: expected_app_attrs))
.and_return(app0)

expect { subject.run }.to output(/Created application id: 200/).to_stdout
end
end
end
end
end