Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#44841] added storage request specs for new endpoint

Eric Schubertf14b33faee70
diff --git a/config/initializers/zeitwerk.rb b/config/initializers/zeitwerk.rb
index a5ea5a876a3..46c21bbd14f 100644
--- a/config/initializers/zeitwerk.rb
+++ b/config/initializers/zeitwerk.rb
@@ -13,23 +13,23 @@ end
OpenProject::Inflector.rule do |basename, abspath|
case basename
when /\Aoauth_(.*)_api\z/
- 'OAuth' + default_inflect($1, abspath) + 'API'
+ "OAuth#{default_inflect($1, abspath)}API"
when /\Aapi_(.*)\z/
- 'API' + default_inflect($1, abspath)
+ "API#{default_inflect($1, abspath)}"
when /\A(.*)_api\z/
- default_inflect($1, abspath) + 'API'
+ "#{default_inflect($1, abspath)}API"
when 'api'
'API'
when /\Aar_(.*)\z/
- 'AR' + default_inflect($1, abspath)
+ "AR#{default_inflect($1, abspath)}"
when /\Aoauth_(.*)\z/
- 'OAuth' + default_inflect($1, abspath)
+ "OAuth#{default_inflect($1, abspath)}"
when /\A(.*)_oauth\z/
- default_inflect($1, abspath) + 'OAuth'
+ "#{default_inflect($1, abspath)}OAuth"
when 'oauth'
'OAuth'
when /\A(.*)_sso\z/
- default_inflect($1, abspath) + 'SSO'
+ "#{default_inflect($1, abspath)}SSO"
end
end
diff --git a/docs/api/apiv3/components/schemas/storage_write_model.yml b/docs/api/apiv3/components/schemas/storage_write_model.yml
index c542eeec583..e8a2c004994 100644
--- a/docs/api/apiv3/components/schemas/storage_write_model.yml
+++ b/docs/api/apiv3/components/schemas/storage_write_model.yml
@@ -7,6 +7,9 @@ properties:
description: Storage name, if not provided, falls back to a default.
_links:
type: object
+ required:
+ - origin
+ - type
properties:
origin:
allOf:
diff --git a/docs/api/apiv3/openapi-spec.yml b/docs/api/apiv3/openapi-spec.yml
index 857e43d548d..e711e147f16 100644
--- a/docs/api/apiv3/openapi-spec.yml
+++ b/docs/api/apiv3/openapi-spec.yml
@@ -251,8 +251,8 @@ paths:
"$ref": "./paths/notification_read.yml"
"/api/v3/notifications/{id}/unread_ian":
"$ref": "./paths/notification_unread.yml"
- "/api/v3/oauth_credentials/{id}":
- "$ref": "./paths/oauth_credentials.yml"
+ "/api/v3/oauth_client_credentials/{id}":
+ "$ref": "./paths/oauth_client_credentials.yml"
"/api/v3/posts/{id}":
"$ref": "./paths/post.yml"
"/api/v3/posts/{id}/attachments":
@@ -658,9 +658,9 @@ components:
"$ref": "./components/schemas/notification_settings_model.yml"
Offset_based_pagination:
"$ref": "./components/schemas/offset_based_pagination.yml"
- OauthClientCredentialsReadModel:
+ OAuthClientCredentialsReadModel:
"$ref": "./components/schemas/oauth_client_credentials_read_model.yml"
- OauthClientCredentialsWriteModel:
+ OAuthClientCredentialsWriteModel:
"$ref": "./components/schemas/oauth_client_credentials_write_model.yml"
Plain_Text:
"$ref": "./components/schemas/plain_text.yml"
diff --git a/docs/api/apiv3/paths/oauth_credentials.yml b/docs/api/apiv3/paths/oauth_client_credentials.yml
similarity index 78%
rename from docs/api/apiv3/paths/oauth_credentials.yml
rename to docs/api/apiv3/paths/oauth_client_credentials.yml
index 93aa5226308..0aa58b5717c 100644
--- a/docs/api/apiv3/paths/oauth_credentials.yml
+++ b/docs/api/apiv3/paths/oauth_client_credentials.yml
@@ -1,13 +1,13 @@
-# /api/v3/oauth_credentials/{id}
+# /api/v3/oauth_client_credentials/{id}
---
get:
summary: Get the oauth credentials object.
- operationId: get_storage_oauth_credentials
+ operationId: get_storage_oauth_client_credentials
tags:
- File links
description: |-
- Retrieves the OAuth 2 credentials for the given storage. The secret will not be part of the response, instead a
- `confidential` flag is indicating, whether there is a secret or not.
+ Retrieves the OAuth 2 client credentials for the given storage. The secret will not be part of the response,
+ instead a `confidential` flag is indicating, whether there is a secret or not.
parameters:
- name: id
description: Storage id
@@ -22,7 +22,7 @@ get:
content:
application/hal+json:
schema:
- $ref: '../components/schemas/oauth_credentials_read_model.yml'
+ $ref: '../components/schemas/oauth_client_credentials_read_model.yml'
'403':
content:
application/hal+json:
diff --git a/docs/api/apiv3/paths/storages.yml b/docs/api/apiv3/paths/storages.yml
index cc5660bed7c..08ffa7883b3 100644
--- a/docs/api/apiv3/paths/storages.yml
+++ b/docs/api/apiv3/paths/storages.yml
@@ -22,4 +22,4 @@ post:
content:
application/hal+json:
schema:
- $ref: '../components/schemas/oauth_credentials_write_model.yml'
+ $ref: '../components/schemas/oauth_client_credentials_write_model.yml'
diff --git a/modules/storages/app/contracts/storages/storages/base_contract.rb b/modules/storages/app/contracts/storages/storages/base_contract.rb
index 41d4825b317..b3e0abfb517 100644
--- a/modules/storages/app/contracts/storages/storages/base_contract.rb
+++ b/modules/storages/app/contracts/storages/storages/base_contract.rb
@@ -47,7 +47,7 @@ module Storages::Storages
validates :provider_type, inclusion: { in: ->(*) { Storages::Storage::PROVIDER_TYPES } }
attribute :host
- validates :host, url: true, length: { maximum: 255 }
+ validates :host, url: { message: I18n.t('activerecord.errors.messages.invalid_url') }, length: { maximum: 255 }
# Check that a host actually is a storage server.
# But only do so if the validations above for URL were successful.
validates :host, secure_context_uri: true, nextcloud_compatible_host: true, unless: -> { errors.include?(:host) }
diff --git a/modules/storages/app/controllers/storages/admin/storages_controller.rb b/modules/storages/app/controllers/storages/admin/storages_controller.rb
index 34c101c0220..c747a5d74f5 100644
--- a/modules/storages/app/controllers/storages/admin/storages_controller.rb
+++ b/modules/storages/app/controllers/storages/admin/storages_controller.rb
@@ -67,7 +67,7 @@ class Storages::Admin::StoragesController < ApplicationController
# That service inherits from ::BaseServices::SetAttributes
@object = ::Storages::Storages::SetAttributesService
.new(user: current_user,
- model: Storages::Storage.new,
+ model: Storages::Storage.new(provider_type: Storages::Storage::PROVIDER_TYPE_NEXTCLOUD),
contract_class: EmptyContract)
.call
.result
diff --git a/modules/storages/app/views/storages/admin/storages/_form.html.erb b/modules/storages/app/views/storages/admin/storages/_form.html.erb
index f365dfaded2..4f845f7c0c4 100644
--- a/modules/storages/app/views/storages/admin/storages/_form.html.erb
+++ b/modules/storages/app/views/storages/admin/storages/_form.html.erb
@@ -33,6 +33,7 @@ See COPYRIGHT and LICENSE files for more details.
<fieldset class="form--fieldset">
<legend class="form--fieldset-legend"><%= I18n.t(:label_general) %></legend>
<div class="form--field -required">
+ <%= f.hidden_field :provider_type %>
<%= f.select :provider_type,
::Storages::Storage::PROVIDER_TYPES.map { |provider_type| [I18n.t("storages.provider_types.#{provider_type}.name"), provider_type] },
{
diff --git a/modules/storages/lib/api/v3/oauth_client/oauth_client_credentials_api.rb b/modules/storages/lib/api/v3/oauth_client/oauth_client_credentials_api.rb
index 83695a9f000..b94ddcb4e15 100644
--- a/modules/storages/lib/api/v3/oauth_client/oauth_client_credentials_api.rb
+++ b/modules/storages/lib/api/v3/oauth_client/oauth_client_credentials_api.rb
@@ -28,7 +28,7 @@
module API::V3::OAuthClient
class OAuthClientCredentialsAPI < ::API::OpenProjectAPI
- resources :oauth_credentials do
+ resources :oauth_client_credentials do
post &::API::V3::Utilities::Endpoints::Create
.new(model: ::OAuthClient,
parse_representer: ::API::V3::OAuth::OAuthClientCredentialsRepresenter,
diff --git a/modules/storages/lib/open_project/storages/engine.rb b/modules/storages/lib/open_project/storages/engine.rb
index 6ce0f74292b..b2c1857205a 100644
--- a/modules/storages/lib/open_project/storages/engine.rb
+++ b/modules/storages/lib/open_project/storages/engine.rb
@@ -113,6 +113,10 @@ module OpenProject::Storages
# This helper methods adds a method on the `api_v3_paths` helper. It is created with one parameter (storage_id)
# and the return value is a string.
+ add_api_path :storages do
+ "#{root}/storages"
+ end
+
add_api_path :storage do |storage_id|
"#{root}/storages/#{storage_id}"
end
@@ -125,6 +129,10 @@ module OpenProject::Storages
"#{root}/storages/#{storage_id}/files/prepare_upload"
end
+ add_api_path :storage_oauth_client_credentials do |storage_id|
+ "#{root}/storages/#{storage_id}/oauth_client_credentials"
+ end
+
add_api_path :file_links do |work_package_id|
"#{work_package(work_package_id)}/file_links"
end
diff --git a/modules/storages/spec/contracts/storages/storages/shared_contract_examples.rb b/modules/storages/spec/contracts/storages/storages/shared_contract_examples.rb
index 41ad3853645..8f10857b0bb 100644
--- a/modules/storages/spec/contracts/storages/storages/shared_contract_examples.rb
+++ b/modules/storages/spec/contracts/storages/storages/shared_contract_examples.rb
@@ -95,13 +95,13 @@ shared_examples_for 'storage contract', :storage_server_helpers, webmock: true d
context 'as host is not a URL' do
let(:storage_host) { '---invalid-url---' }
- include_examples 'contract is invalid', host: :url
+ include_examples 'contract is invalid', host: I18n.t('activerecord.errors.messages.invalid_url')
end
context 'as host is an empty string' do
let(:storage_host) { '' }
- include_examples 'contract is invalid', host: :url
+ include_examples 'contract is invalid', host: I18n.t('activerecord.errors.messages.invalid_url')
end
context 'as host is longer than 255' do
diff --git a/modules/storages/spec/controller/storages_controller_spec.rb b/modules/storages/spec/controller/storages_controller_spec.rb
index 5d5ebea700d..f0feefbbbb4 100644
--- a/modules/storages/spec/controller/storages_controller_spec.rb
+++ b/modules/storages/spec/controller/storages_controller_spec.rb
@@ -30,15 +30,17 @@ require_relative '../spec_helper'
# These specs mainly check that error messages from a sub-service
# (about unsafe hosts with HTTP protocol) are passed to the main form.
-describe ::Storages::Admin::StoragesController, webmock: true, type: :controller do
+describe ::Storages::Admin::StoragesController, type: :controller, webmock: true do
render_views # rendering views is stubbed by default in controller specs
include StorageServerHelpers
- let(:admin) { create :admin }
+ let(:admin) { create(:admin) }
let(:schema) { "https" }
let(:host) { "#{schema}://example.org" }
let(:content_type_json) { { 'Content-Type' => 'application/json; charset=utf-8' } }
- let(:params) { { storages_storage: { name: "My Nextcloud", host: } } }
+ let(:params) do
+ { storages_storage: { name: "My Nextcloud", host:, provider_type: Storages::Storage::PROVIDER_TYPE_NEXTCLOUD } }
+ end
before do
login_as admin
diff --git a/modules/storages/spec/features/create_file_links_spec.rb b/modules/storages/spec/features/create_file_links_spec.rb
index 382ef9d23ca..8197e7b5a33 100644
--- a/modules/storages/spec/features/create_file_links_spec.rb
+++ b/modules/storages/spec/features/create_file_links_spec.rb
@@ -34,7 +34,8 @@ describe 'Creating file links in work package', js: true, webmock: true, with_fl
let(:current_user) { create(:user, member_in_project: project, member_with_permissions: permissions) }
let(:work_package) { create(:work_package, project:, description: 'Initial description') }
- let(:storage) { create(:storage) }
+ let(:oauth_application) { create(:oauth_application) }
+ let(:storage) { create(:storage, oauth_application:) }
let(:oauth_client) { create(:oauth_client, integration: storage) }
let(:oauth_client_token) { create(:oauth_client_token, oauth_client:, user: current_user) }
let(:project_storage) { create(:project_storage, project:, storage:) }
diff --git a/modules/storages/spec/features/show_file_links_spec.rb b/modules/storages/spec/features/show_file_links_spec.rb
index 5c3b210abdf..7763efed7ca 100644
--- a/modules/storages/spec/features/show_file_links_spec.rb
+++ b/modules/storages/spec/features/show_file_links_spec.rb
@@ -28,13 +28,14 @@
require_relative '../spec_helper'
-describe 'Showing of file links in work package', type: :feature, js: true do
+describe 'Showing of file links in work package', js: true do
let(:permissions) { %i(view_work_packages edit_work_packages view_file_links manage_file_links) }
let(:project) { create(:project) }
let(:current_user) { create(:user, member_in_project: project, member_with_permissions: permissions) }
let(:work_package) { create(:work_package, project:, description: 'Initial description') }
- let(:storage) { create(:storage) }
+ let(:oauth_application) { create(:oauth_application) }
+ let(:storage) { create(:storage, oauth_application:) }
let(:oauth_client) { create(:oauth_client, integration: storage) }
let(:oauth_client_token) { create(:oauth_client_token, oauth_client:, user: current_user) }
let(:project_storage) { create(:project_storage, project:, storage:) }
@@ -56,7 +57,7 @@ describe 'Showing of file links in work package', type: :feature, js: true do
.and_return(ServiceResult.success(result: oauth_client_token))
allow(connection_manager)
.to receive(:authorization_state)
- .and_return(:connected)
+ .and_return(:connected)
# Mock FileLinkSyncService as if Nextcloud would respond with origin_permission=nil
allow(::Storages::FileLinkSyncService)
@@ -103,7 +104,7 @@ describe 'Showing of file links in work package', type: :feature, js: true do
end
it 'must show storage information box with login button' do
- expect(page.find('[data-qa-selector="op-files-tab--storage-information"]')).to have_selector('button', count: 1)
+ expect(page.find('[data-qa-selector="op-files-tab--storage-information"]')).to have_button(count: 1)
end
end
diff --git a/modules/storages/spec/lib/api/v3/storages/storages_representer_rendering_spec.rb b/modules/storages/spec/lib/api/v3/storages/storages_representer_rendering_spec.rb
index 9bb272239cf..615865f7189 100644
--- a/modules/storages/spec/lib/api/v3/storages/storages_representer_rendering_spec.rb
+++ b/modules/storages/spec/lib/api/v3/storages/storages_representer_rendering_spec.rb
@@ -29,7 +29,8 @@
require 'spec_helper'
describe ::API::V3::Storages::StorageRepresenter, 'rendering' do
- let(:storage) { build_stubbed(:storage) }
+ let(:oauth_application) { build_stubbed(:oauth_application) }
+ let(:storage) { build_stubbed(:storage, oauth_application:) }
let(:user) { build_stubbed(:user) }
let(:representer) { described_class.new(storage, current_user: user) }
let(:connection_manager) { instance_double(::OAuthClients::ConnectionManager) }
@@ -68,6 +69,21 @@ describe ::API::V3::Storages::StorageRepresenter, 'rendering' do
let(:title) { 'Connected' }
end
end
+
+ describe 'oauthApplication' do
+ it_behaves_like 'has a titled link' do
+ let(:link) { 'oauthApplication' }
+ let(:href) { "/api/v3/oauth_applications/#{oauth_application.id}" }
+ let(:title) { oauth_application.name }
+ end
+ end
+
+ describe 'oauthClientCredentials' do
+ it_behaves_like 'has an untitled link' do
+ let(:link) { 'oauthClientCredentials' }
+ let(:href) { nil }
+ end
+ end
end
describe 'properties' do
diff --git a/modules/storages/spec/requests/api/v3/file_links/file_links_spec.rb b/modules/storages/spec/requests/api/v3/file_links/file_links_spec.rb
index 809407401b9..1236ddbbc77 100644
--- a/modules/storages/spec/requests/api/v3/file_links/file_links_spec.rb
+++ b/modules/storages/spec/requests/api/v3/file_links/file_links_spec.rb
@@ -29,7 +29,7 @@
require 'spec_helper'
require_module_spec_helper
-describe 'API v3 file links resource', type: :request do
+describe 'API v3 file links resource' do
include API::V3::Utilities::PathHelper
let(:permissions) { %i(view_work_packages view_file_links) }
@@ -42,7 +42,8 @@ describe 'API v3 file links resource', type: :request do
let(:work_package) { create(:work_package, author: current_user, project:) }
let(:another_work_package) { create(:work_package, author: current_user, project:) }
- let(:storage) { create(:storage, creator: current_user) }
+ let(:oauth_application) { create(:oauth_application) }
+ let(:storage) { create(:storage, creator: current_user, oauth_application:) }
let(:another_storage) { create(:storage, creator: current_user) }
let(:oauth_client) { create(:oauth_client, integration: storage) }
diff --git a/modules/storages/spec/requests/api/v3/storages/storages_spec.rb b/modules/storages/spec/requests/api/v3/storages/storages_spec.rb
index 4db1adf84b2..e020594e9a4 100644
--- a/modules/storages/spec/requests/api/v3/storages/storages_spec.rb
+++ b/modules/storages/spec/requests/api/v3/storages/storages_spec.rb
@@ -29,8 +29,9 @@
require 'spec_helper'
require_module_spec_helper
-describe 'API v3 storages resource', content_type: :json do
+describe 'API v3 storages resource', content_type: :json, webmock: true do
include API::V3::Utilities::PathHelper
+ include StorageServerHelpers
let(:permissions) { %i(view_work_packages view_file_links) }
let(:project) { create(:project) }
@@ -39,13 +40,9 @@ describe 'API v3 storages resource', content_type: :json do
create(:user, member_in_project: project, member_with_permissions: permissions)
end
- let(:storage) do
- create(:storage, creator: current_user)
- end
-
- let(:project_storage) do
- create(:project_storage, project:, storage:)
- end
+ let(:oauth_application) { create(:oauth_application) }
+ let(:storage) { create(:storage, creator: current_user, oauth_application:) }
+ let(:project_storage) { create(:project_storage, project:, storage:) }
let(:authorize_url) { 'https://example.com/authorize' }
let(:connection_manager) { instance_double(::OAuthClients::ConnectionManager) }
@@ -62,7 +59,7 @@ describe 'API v3 storages resource', content_type: :json do
login_as current_user
end
- shared_examples_for 'successful storage response' do
+ shared_examples_for 'successful storage response' do |as_admin: false|
include_examples 'successful response'
describe 'response body' do
@@ -70,6 +67,72 @@ describe 'API v3 storages resource', content_type: :json do
it { is_expected.to be_json_eql('Storage'.to_json).at_path('_type') }
it { is_expected.to be_json_eql(storage.id.to_json).at_path('id') }
+
+ if as_admin
+ it { is_expected.to have_json_path('_embedded/oauthApplication') }
+ else
+ it { is_expected.not_to have_json_path('_embedded/oauthApplication') }
+ end
+ end
+ end
+
+ describe 'POST /api/v3/storages' do
+ let(:path) { api_v3_paths.storages }
+ let(:host) { 'https://example.nextcloud.local' }
+ let(:name) { 'APIStorage' }
+ let(:type) { 'urn:openproject-org:api:v3:storages:Nextcloud' }
+ let(:params) do
+ {
+ name:,
+ _links: {
+ origin: { href: host },
+ type: { href: type }
+ }
+ }
+ end
+
+ before do
+ mock_server_capabilities_response(host)
+ mock_server_config_check_response(host)
+ end
+
+ subject(:last_response) do
+ post path, params.to_json
+ end
+
+ context 'as admin' do
+ let(:current_user) { create(:admin) }
+
+ describe 'creates a storage and returns it' do
+ subject { last_response.body }
+
+ it_behaves_like 'successful response', 201
+
+ it { is_expected.to be_json_eql('Storage'.to_json).at_path('_type') }
+ it { is_expected.to be_json_eql(name.to_json).at_path('name') }
+ it { is_expected.to be_json_eql(host.to_json).at_path('_links/origin/href') }
+ it { is_expected.to be_json_eql(type.to_json).at_path('_links/type/href') }
+ it { is_expected.to have_json_path('_embedded/oauthApplication/clientSecret') }
+ end
+
+ context 'if missing a mandatory value' do
+ let(:params) do
+ {
+ name: 'APIStorage',
+ _links: {
+ type: { href: 'urn:openproject-org:api:v3:storages:Nextcloud' }
+ }
+ }
+ end
+
+ it_behaves_like 'constraint violation' do
+ let(:message) { "Host is not a valid URL" }
+ end
+ end
+ end
+
+ context 'as non-admin' do
+ it_behaves_like 'unauthorized access'
end
end
@@ -103,7 +166,11 @@ describe 'API v3 storages resource', content_type: :json do
context 'as admin' do
let(:current_user) { create(:admin) }
- it_behaves_like 'successful storage response'
+ it_behaves_like 'successful storage response', as_admin: true
+
+ subject { last_response.body }
+
+ it { is_expected.not_to have_json_path('_embedded/oauthApplication/clientSecret') }
end
context 'when OAuth authorization server is involved' do
@@ -153,6 +220,42 @@ describe 'API v3 storages resource', content_type: :json do
end
end
+ describe 'PATCH /api/v3/storages/:storage_id' do
+ let(:path) { api_v3_paths.storage(storage.id) }
+ let(:name) { 'A new storage name' }
+ let(:params) { { name: } }
+
+ subject(:last_response) do
+ patch path, params.to_json
+ end
+
+ context 'as non-admin' do
+ context 'if user belongs to a project using the given storage' do
+ it_behaves_like 'unauthorized access'
+ end
+
+ context 'if user does not belong to a project using the given storage' do
+ let(:current_user) do
+ create(:user, member_with_permissions: permissions)
+ end
+
+ it_behaves_like 'not found'
+ end
+ end
+
+ context 'as admin' do
+ let(:current_user) { create(:admin) }
+
+ describe 'patches the storage and returns it' do
+ subject { last_response.body }
+
+ it_behaves_like 'successful response'
+
+ it { is_expected.to be_json_eql(name.to_json).at_path('name') }
+ end
+ end
+ end
+
describe 'DELETE /api/v3/storages/:storage_id' do
let(:path) { api_v3_paths.storage(storage.id) }
@@ -376,4 +479,61 @@ describe 'API v3 storages resource', content_type: :json do
end
end
end
+
+ describe 'POST /api/v3/storages/:storage_id/oauth_client_credentials' do
+ let(:path) { api_v3_paths.storage_oauth_client_credentials(storage.id) }
+ let(:client_id) { 'myl1ttlecl13ntidii' }
+ let(:client_secret) { 'th3v3rys3cr3tcl13nts3cr3t' }
+ let(:params) do
+ {
+ clientId: client_id,
+ clientSecret: client_secret
+ }
+ end
+
+ subject(:last_response) do
+ post path, params.to_json
+ end
+
+ context 'as non-admin' do
+ context 'if user belongs to a project using the given storage' do
+ it_behaves_like 'unauthorized access'
+ end
+
+ context 'if user does not belong to a project using the given storage' do
+ let(:current_user) do
+ create(:user, member_with_permissions: permissions)
+ end
+
+ it_behaves_like 'not found'
+ end
+ end
+
+ context 'as admin' do
+ let(:current_user) { create(:admin) }
+
+ describe 'creates new oauth client secrets' do
+ subject { last_response.body }
+
+ it_behaves_like 'successful response', 201
+
+ it { is_expected.to be_json_eql('OAuthClientCredentials'.to_json).at_path('_type') }
+ it { is_expected.to be_json_eql(client_id.to_json).at_path('clientId') }
+ it { is_expected.to be_json_eql(true.to_json).at_path('confidential') }
+ it { is_expected.not_to have_json_path('clientSecret') }
+ end
+
+ context 'if request body is invalid' do
+ let(:params) do
+ {
+ clientId: 'only_an_id'
+ }
+ end
+
+ it_behaves_like 'constraint violation' do
+ let(:message) { 'Client secret can\'t be blank.' }
+ end
+ end
+ end
+ end
end
diff --git a/modules/storages/spec/services/storages/storages/set_attributes_service_spec.rb b/modules/storages/spec/services/storages/storages/set_attributes_service_spec.rb
index fb9297b384c..a520651e61c 100644
--- a/modules/storages/spec/services/storages/storages/set_attributes_service_spec.rb
+++ b/modules/storages/spec/services/storages/storages/set_attributes_service_spec.rb
@@ -61,7 +61,7 @@ describe ::Storages::Storages::SetAttributesService, type: :model do
::Storages::Storages::CreateContract
end
- let(:params) { {} }
+ let(:params) { { provider_type: Storages::Storage::PROVIDER_TYPE_NEXTCLOUD } }
before do
allow(model_instance)
@@ -131,10 +131,7 @@ describe ::Storages::Storages::SetAttributesService, type: :model do
it 'assigns the params' do
expect(model_instance.name).to eq 'Foobar'
- end
-
- it 'cannot assign provider_type to anything else than "nextcloud"' do
- expect(model_instance.provider_type).to eq Storages::Storage::PROVIDER_TYPE_NEXTCLOUD
+ expect(model_instance.provider_type).to eq 'foo provider'
end
end
diff --git a/script/api/validate_spec b/script/api/validate_spec
index d1d3a0a040a..bf6f89d4af1 100755
--- a/script/api/validate_spec
+++ b/script/api/validate_spec
@@ -18,7 +18,7 @@ begin
file.puts full_spec
end
- `npx @redocly/openapi-cli lint #{openapi_yaml_spec_path} --max-problems 200`
+ `npx @redocly/openapi-cli lint #{openapi_yaml_spec_path}`
status = $?.exitstatus
ensure