forked from DSpace/DSpace
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Customer UK update 15.11.-6.12. (#465)
* ufal/downloading-restricted-bitstreams-not-working-properly (#457) * The admin could download restricted bitstreams. * The user cannot download bitstream if he/she is not signed in. * Cannot obtain context with user. * The user is already fetched from the context. * Added docs. * Do not use endpoint for downloading the single file because it already exists - remove it. * Fixed AuthorizationRestControllerIT tests. * ufal/be-cannot-download-and-preview-files-after-migration (#454) * Find bitstream format using mimetype not ID. * Updated tests according to fix. * ufal/update-canonical-prefix-to-hdl (#460) * Updated `handle.canonical.prefix` to hdl handle. * Integration test cannot have changed handle.canonical.prefix. * ufal/be-user-registration-missing (#463) * The user registration is added when the eperson is created by the ui. * try using newer checkout, same as upstream, since error is with git --------- Co-authored-by: MajoBerger <[email protected]> * ufal/be-license-download-statistics (#462) * Add logging of downloading restricted bitstreams. * Log downloading of every bitstream not only restricted ones. * Added docs * Refactored logging. * ufal/be-shibboleth-headers-encoding (#464) * givenname and last name values are converted to UTF-8 encoding * Delete eperson in tests --------- Co-authored-by: MajoBerger <[email protected]>
- Loading branch information
1 parent
6034d69
commit 6619764
Showing
10 changed files
with
201 additions
and
18 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
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
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 |
---|---|---|
|
@@ -65,6 +65,7 @@ | |
import org.dspace.app.rest.model.patch.ReplaceOperation; | ||
import org.dspace.app.rest.test.AbstractControllerIntegrationTest; | ||
import org.dspace.app.rest.test.MetadataPatchSuite; | ||
import org.dspace.builder.ClarinUserRegistrationBuilder; | ||
import org.dspace.builder.CollectionBuilder; | ||
import org.dspace.builder.CommunityBuilder; | ||
import org.dspace.builder.EPersonBuilder; | ||
|
@@ -120,6 +121,8 @@ public void createTest() throws Exception { | |
|
||
AtomicReference<UUID> idRef = new AtomicReference<UUID>(); | ||
AtomicReference<UUID> idRefNoEmbeds = new AtomicReference<UUID>(); | ||
AtomicReference<Integer> idRefUserDataReg = new AtomicReference<Integer>(); | ||
AtomicReference<Integer> idRefUserDataFullReg = new AtomicReference<Integer>(); | ||
|
||
String authToken = getAuthToken(admin.getEmail(), password); | ||
|
||
|
@@ -155,11 +158,51 @@ public void createTest() throws Exception { | |
.andExpect(content().contentType(contentType)) | ||
.andExpect(jsonPath("$", HalMatcher.matchNoEmbeds())) | ||
.andDo(result -> idRefNoEmbeds | ||
.set(UUID.fromString(read(result.getResponse().getContentAsString(), "$.id"))));; | ||
.set(UUID.fromString(read(result.getResponse().getContentAsString(), "$.id")))); | ||
|
||
// Check that the user registration for test data user has been created | ||
getClient(authToken).perform(get("/api/core/clarinuserregistration/search/byEPerson") | ||
.param("userUUID", String.valueOf(idRef.get())) | ||
.contentType(contentType)) | ||
.andExpect(status().isOk()) | ||
.andExpect(jsonPath("$.page.totalElements", is(1))) | ||
.andExpect(jsonPath( | ||
"$._embedded.clarinuserregistrations[0].id", is(not(empty())))) | ||
.andExpect(jsonPath( | ||
"$._embedded.clarinuserregistrations[0].email", is("[email protected]"))) | ||
.andExpect(jsonPath( | ||
"$._embedded.clarinuserregistrations[0].confirmation", is(true))) | ||
.andExpect(jsonPath( | ||
"$._embedded.clarinuserregistrations[0].ePersonID", is(idRef.get().toString()))) | ||
.andDo(result -> idRefUserDataReg | ||
.set(read(result.getResponse().getContentAsString(), | ||
"$._embedded.clarinuserregistrations[0].id"))); | ||
|
||
// Check that the user registration for test data full user has been created | ||
getClient(authToken).perform(get("/api/core/clarinuserregistration/search/byEPerson") | ||
.param("userUUID", String.valueOf(idRefNoEmbeds.get())) | ||
.contentType(contentType)) | ||
.andExpect(status().isOk()) | ||
.andExpect(jsonPath("$.page.totalElements", is(1))) | ||
.andExpect(jsonPath( | ||
"$._embedded.clarinuserregistrations[0].id", is(not(empty())))) | ||
.andExpect(jsonPath( | ||
"$._embedded.clarinuserregistrations[0].email", | ||
is("[email protected]"))) | ||
.andExpect(jsonPath( | ||
"$._embedded.clarinuserregistrations[0].confirmation", is(true))) | ||
.andExpect(jsonPath( | ||
"$._embedded.clarinuserregistrations[0].ePersonID", | ||
is(idRefNoEmbeds.get().toString()))) | ||
.andDo(result -> idRefUserDataFullReg | ||
.set(read(result.getResponse().getContentAsString(), | ||
"$._embedded.clarinuserregistrations[0].id"))); | ||
|
||
} finally { | ||
EPersonBuilder.deleteEPerson(idRef.get()); | ||
EPersonBuilder.deleteEPerson(idRefNoEmbeds.get()); | ||
ClarinUserRegistrationBuilder.deleteClarinUserRegistration(idRefUserDataReg.get()); | ||
ClarinUserRegistrationBuilder.deleteClarinUserRegistration(idRefUserDataFullReg.get()); | ||
} | ||
} | ||
|
||
|
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 |
---|---|---|
|
@@ -446,15 +446,18 @@ public void testRedirectToGivenUntrustedUrl() throws Exception { | |
} | ||
|
||
@Test | ||
public void testUTF8ShibHeaders() throws Exception { | ||
public void testISOShibHeaders() throws Exception { | ||
String testMail = "[email protected]"; | ||
String testIdp = IDP_TEST_EPERSON + "test"; | ||
String testNetId = NET_ID_TEST_EPERSON + "000"; | ||
// NOTE: The initial call to /shibboleth comes *from* an external Shibboleth site. So, it is always | ||
// unauthenticated, but it must include some expected SHIB attributes. | ||
// SHIB-MAIL attribute is the default email header sent from Shibboleth after a successful login. | ||
// In this test we are simply mocking that behavior by setting it to an existing EPerson. | ||
String token = getClient().perform(get("/api/authn/shibboleth") | ||
.header("SHIB-MAIL", clarinEperson.getEmail()) | ||
.header("Shib-Identity-Provider", IDP_TEST_EPERSON) | ||
.header("SHIB-NETID", NET_ID_TEST_EPERSON) | ||
.header("SHIB-MAIL", testMail) | ||
.header("Shib-Identity-Provider", testIdp) | ||
.header("SHIB-NETID", testNetId) | ||
.header("SHIB-GIVENNAME", "knihovna KůÅ\u0088 test ŽluÅ¥ouÄ\u008Dký")) | ||
.andExpect(status().is3xxRedirection()) | ||
.andExpect(redirectedUrl("http://localhost:4000")) | ||
|
@@ -466,6 +469,56 @@ public void testUTF8ShibHeaders() throws Exception { | |
.andExpect(jsonPath("$.authenticated", is(true))) | ||
.andExpect(jsonPath("$.authenticationMethod", is("shibboleth"))); | ||
|
||
// Check if was created a user with such email and netid. | ||
EPerson ePerson = ePersonService.findByNetid(context, Util.formatNetId(testNetId, testIdp)); | ||
assertTrue(Objects.nonNull(ePerson)); | ||
assertEquals(ePerson.getEmail(), testMail); | ||
assertEquals(ePerson.getFirstName(), "knihovna Kůň test Žluťoučký"); | ||
|
||
EPersonBuilder.deleteEPerson(ePerson.getID()); | ||
|
||
getClient(token).perform( | ||
get("/api/authz/authorizations/search/object") | ||
.param("embed", "feature") | ||
.param("feature", feature) | ||
.param("uri", utils.linkToSingleResource(ePersonRest, "self").getHref())) | ||
.andExpect(status().isOk()) | ||
.andExpect(jsonPath("$.page.totalElements", is(0))) | ||
.andExpect(jsonPath("$._embedded").doesNotExist()); | ||
} | ||
|
||
@Test | ||
public void testUTF8ShibHeaders() throws Exception { | ||
String testMail = "[email protected]"; | ||
String testIdp = IDP_TEST_EPERSON + "test"; | ||
String testNetId = NET_ID_TEST_EPERSON + "000"; | ||
// NOTE: The initial call to /shibboleth comes *from* an external Shibboleth site. So, it is always | ||
// unauthenticated, but it must include some expected SHIB attributes. | ||
// SHIB-MAIL attribute is the default email header sent from Shibboleth after a successful login. | ||
// In this test we are simply mocking that behavior by setting it to an existing EPerson. | ||
String token = getClient().perform(get("/api/authn/shibboleth") | ||
.header("SHIB-MAIL", testMail) | ||
.header("Shib-Identity-Provider", testIdp) | ||
.header("SHIB-NETID", testNetId) | ||
.header("SHIB-GIVENNAME", "knihovna Kůň test Žluťoučký")) | ||
.andExpect(status().is3xxRedirection()) | ||
.andExpect(redirectedUrl("http://localhost:4000")) | ||
.andReturn().getResponse().getHeader("Authorization"); | ||
|
||
|
||
getClient(token).perform(get("/api/authn/status")) | ||
.andExpect(status().isOk()) | ||
.andExpect(jsonPath("$.authenticated", is(true))) | ||
.andExpect(jsonPath("$.authenticationMethod", is("shibboleth"))); | ||
|
||
// Check if was created a user with such email and netid. | ||
EPerson ePerson = ePersonService.findByNetid(context, Util.formatNetId(testNetId, testIdp)); | ||
assertTrue(Objects.nonNull(ePerson)); | ||
assertEquals(ePerson.getEmail(), testMail); | ||
assertEquals(ePerson.getFirstName(), "knihovna Kůň test Žluťoučký"); | ||
|
||
EPersonBuilder.deleteEPerson(ePerson.getID()); | ||
|
||
getClient(token).perform( | ||
get("/api/authz/authorizations/search/object") | ||
.param("embed", "feature") | ||
|
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