-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1317 from datacite/role-member-fix
Allows providers with ROLE_MEMBER "Member Only" role to retrieve non-findable DOIs at /dois endpoint
- Loading branch information
Showing
4 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
include Passwordable | ||
|
||
describe ClientsController, type: :request, elasticsearch: true do | ||
let(:ids) { clients.map(&:uid).join(",") } | ||
let(:bearer) { User.generate_token } | ||
let(:provider) { create(:provider, password_input: "12345") } | ||
let(:provider_member_only) { create(:provider, role_name: "ROLE_MEMBER", symbol: "YYYY", password: encrypt_password_sha256(ENV["MDS_PASSWORD"])) } | ||
let!(:client) { create(:client, provider: provider) } | ||
let(:params) do | ||
{ | ||
|
@@ -228,6 +230,26 @@ | |
} | ||
end | ||
|
||
let(:provider_member_only_basic_auth_headers) { { "HTTP_ACCEPT" => "application/vnd.api+json", "HTTP_AUTHORIZATION" => ActionController::HttpAuthentication::Basic.encode_credentials(provider_member_only.symbol, ENV["MDS_PASSWORD"]) } } | ||
let(:params_member_only) do | ||
{ | ||
"data" => { | ||
"type" => "clients", | ||
"attributes" => { | ||
"symbol" => provider_member_only.symbol + ".IMPERIAL", | ||
"name" => "Imperial College", | ||
"contactEmail" => "[email protected]", | ||
"clientType" => "repository", | ||
}, | ||
"relationships": { | ||
"provider": { | ||
"data": { "type": "providers", "id": provider_member_only.uid }, | ||
}, | ||
}, | ||
}, | ||
} | ||
end | ||
|
||
it "returns status code 422" do | ||
post "/clients", params, headers | ||
|
||
|
@@ -247,6 +269,12 @@ | |
], | ||
) | ||
end | ||
|
||
it "returns status code 422" do | ||
post "/clients", params_member_only, provider_member_only_basic_auth_headers | ||
|
||
expect(last_response.status).to eq(403) | ||
end | ||
end | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters