Skip to content

Commit 01c22cd

Browse files
authored
MInor bugfixes on Sharepoint Storage (#20030)
* Translations and missing keys * Remove AMPF references to avoid confusion
1 parent 4b13d45 commit 01c22cd

File tree

5 files changed

+20
-57
lines changed

5 files changed

+20
-57
lines changed

config/static_links.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ storage_docs:
149149
href: https://portal.azure.com/
150150
one_drive_setup:
151151
href: https://www.openproject.org/docs/system-admin-guide/integrations/one-drive/
152-
share_point_drive_id_guide:
152+
sharepoint_drive_id_guide:
153153
href: https://www.openproject.org/docs/system-admin-guide/integrations/one-drive/drive-guide/
154-
share_point_oauth_application:
154+
sharepoint_oauth_application:
155155
href: https://portal.azure.com/
156-
share_point_setup:
156+
sharepoint_setup:
157157
href: https://www.openproject.org/docs/system-admin-guide/integrations/one-drive/
158158
troubleshooting:
159159
href: https://www.openproject.org/docs/user-guide/file-management/nextcloud-integration/#possible-errors-and-troubleshooting

modules/storages/app/common/storages/adapters/providers/sharepoint/storage_wizard.rb

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ module Sharepoint
3535
class StorageWizard < Wizard
3636
step :general_information, completed_if: ->(storage) { storage.name.present? }
3737

38-
step :access_management,
39-
section: :access_management_section,
40-
completed_if: ->(storage) { !storage.automatic_management_unspecified? },
41-
preparation: :prepare_storage_for_access_management_form
42-
4338
step :oauth_client,
4439
section: :oauth_configuration,
4540
completed_if: ->(storage) { storage.oauth_client.present? },
@@ -53,22 +48,10 @@ class StorageWizard < Wizard
5348

5449
private
5550

56-
def prepare_storage_for_access_management_form(storage)
57-
::Storages::Storages::SetProviderFieldsAttributesService
58-
.new(user:, model: storage, contract_class: EmptyContract)
59-
.call
60-
end
61-
6251
def prepare_oauth_application(storage)
6352
persist_service_result = ::Storages::OAuthApplications::CreateService.new(storage:, user:).call
6453
storage.oauth_application = persist_service_result.result if persist_service_result.success?
6554
end
66-
67-
def prepare_storage_for_automatic_management_form(storage)
68-
::Storages::Storages::SetProviderFieldsAttributesService
69-
.new(user:, model: storage, contract_class: EmptyContract)
70-
.call
71-
end
7255
end
7356
end
7457
end

modules/storages/app/helpers/storages/open_storage_links.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def static_link(storage)
3939
case storage
4040
when NextcloudStorage
4141
api_static_link
42-
when OneDriveStorage
42+
when OneDriveStorage, SharepointStorage
4343
raise Errors::ConfigurationError, "No OAuth credential information configured." if storage.oauth_client.nil?
4444

4545
oauth_clients_ensure_connection_url(
@@ -56,7 +56,7 @@ def can_generate_static_link?(storage)
5656
case storage
5757
when NextcloudStorage
5858
true
59-
when OneDriveStorage
59+
when OneDriveStorage, SharepointStorage
6060
storage.oauth_client&.persisted?
6161
else
6262
false

modules/storages/config/locales/en.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ en:
237237
openproject_oauth: OpenProject OAuth
238238
project_folders: Project folders
239239
redirect_uri: Redirect URI
240+
sharepoint_oauth: Azure OAuth
240241
storage_audience_blank: No audience has been configured.
241242
storage_audience_description: Exchanging tokens for audience "%{audience}".
242243
storage_audience_idp: Using access token obtained by identity provider during login, regardless of audience.
@@ -279,6 +280,7 @@ en:
279280
drive_id_exists: Drive exists
280281
drive_id_format: Drive ID format
281282
header: Configuration
283+
host: Host URL
282284
host_url_accessible: Host URL accessible
283285
storage_configured: Configuration complete
284286
tenant_id: Tenant ID

modules/storages/spec/common/storages/adapters/providers/sharepoint/storage_wizard_spec.rb

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646

4747
it "has all steps pending in correct order" do
4848
expect(wizard.pending_steps).to eq(%i[general_information
49-
access_management
5049
oauth_client
5150
redirect_uri])
5251
end
@@ -70,49 +69,28 @@
7069
wizard.prepare_next_step
7170
end
7271

73-
it "automatically finished the access_management step" do
74-
expect(wizard.completed_steps).to eq(%i[general_information access_management])
72+
it "finishes the oauth_client step" do
73+
expect(wizard.completed_steps).to eq(%i[general_information oauth_client])
7574
end
7675

77-
it "disabled automatic storage management, and didn't persist it" do
78-
expect(model).not_to be_automatic_management_enabled
79-
before, after = model.changes["provider_fields"]
80-
expect(before.keys).not_to include("automatically_managed")
81-
expect(after.keys).to include("automatically_managed")
76+
it "now has an unsaved oauth_client" do
77+
expect(model.oauth_client).to be_present
78+
expect(model.oauth_client).not_to be_persisted
8279
end
8380

84-
it "has no oauth_client yet" do
85-
expect(model.oauth_client).to be_nil
86-
end
87-
88-
context "and the next step was prepared" do
81+
context "when the client was saved" do
8982
before do
90-
wizard.prepare_next_step
91-
end
92-
93-
it "finishes the oauth_client step" do
94-
expect(wizard.completed_steps).to eq(%i[general_information access_management oauth_client])
83+
model.oauth_client.assign_attributes(client_id: "Foo", client_secret: "Bar")
84+
model.oauth_client.save!
9585
end
9686

97-
it "now has an unsaved oauth_client" do
98-
expect(model.oauth_client).to be_present
99-
expect(model.oauth_client).not_to be_persisted
87+
it "did not finish the final step immediately" do
88+
expect(wizard.pending_steps).to eq(%i[redirect_uri])
10089
end
10190

102-
context "when the client was saved" do
103-
before do
104-
model.oauth_client.assign_attributes(client_id: "Foo", client_secret: "Bar")
105-
model.oauth_client.save!
106-
end
107-
108-
it "did not finish the final step immediately" do
109-
expect(wizard.pending_steps).to eq(%i[redirect_uri])
110-
end
111-
112-
it "after some time, the final step is completed" do
113-
Timecop.travel(15.seconds.from_now) do
114-
expect(wizard.completed_steps).to eq(%i[general_information access_management oauth_client redirect_uri])
115-
end
91+
it "after some time, the final step is completed" do
92+
Timecop.travel(15.seconds.from_now) do
93+
expect(wizard.completed_steps).to eq(%i[general_information oauth_client redirect_uri])
11694
end
11795
end
11896
end

0 commit comments

Comments
 (0)