Skip to content

Commit

Permalink
Merge pull request opf#14165 from opf/bug/oauth-does-not-show-plainte…
Browse files Browse the repository at this point in the history
…xt-secret

Fixed storage oauth credential replace to show plaintext secret
  • Loading branch information
apfohl authored Nov 20, 2023
2 parents f1450c8 + 68c45ae commit 0cda27c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
OpenProject::Common::ClipboardCopyComponent.new(
name: :openproject_oauth_application_secret,
visually_hide_label: false,
value_to_copy: oauth_application.secret,
value_to_copy: oauth_application.plaintext_secret,
label: I18n.t('storages.label_openproject_oauth_application_secret'),
required: true
)
Expand Down
12 changes: 10 additions & 2 deletions modules/storages/spec/features/admin_storages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@

describe 'New file storage', with_flag: { storage_primer_design: true } do
context 'with Nextcloud Storage' do
let(:secret) { 'awesome_secret' }

before do
allow(Doorkeeper::OAuth::Helpers::UniqueToken).to receive(:generate).and_return(secret)
end

it 'renders a Nextcloud specific multi-step form', :webmock do
visit admin_settings_storages_path

Expand Down Expand Up @@ -153,7 +159,7 @@
expect(page).to have_css('#openproject_oauth_application_uid',
value: storage.reload.oauth_application.uid)
expect(page).to have_css('#openproject_oauth_application_secret',
value: storage.reload.oauth_application.secret)
value: secret)

click_link 'Done, continue'
end
Expand Down Expand Up @@ -304,8 +310,10 @@
let(:storage) { create(:nextcloud_storage, :as_automatically_managed) }
let(:oauth_application) { create(:oauth_application, integration: storage) }
let(:oauth_client) { create(:oauth_client, integration: storage) }
let(:secret) { 'awesome_secret' }

before do
allow(Doorkeeper::OAuth::Helpers::UniqueToken).to receive(:generate).and_return(secret)
oauth_application
oauth_client
end
Expand Down Expand Up @@ -385,7 +393,7 @@
expect(page).to have_css('#openproject_oauth_application_uid',
value: storage.reload.oauth_application.uid)
expect(page).to have_css('#openproject_oauth_application_secret',
value: storage.reload.oauth_application.secret)
value: secret)

click_link 'Done, continue'
end
Expand Down

0 comments on commit 0cda27c

Please sign in to comment.