Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,15 @@ describe('ClarinBitstreamDownloadPageComponent', () => {
expect(component.redirectToContent).not.toHaveBeenCalled();
});

it('should download with the dtoken and the access token once the CLARIN check passes', () => {
it('should redirect an anonymous user through HardRedirectService with the dtoken and the access token once the CLARIN check passes', () => {
rdbService.buildFromRequestUUID.and.returnValue(of(createSuccessfulRemoteDataObject({})));
activatedRoute.snapshot.queryParams = { dtoken: dtoken, accessToken: accessToken };

component.ngOnInit();

expect(component.redirectToContent).toHaveBeenCalledWith(
expect(hardRedirectService.redirect).toHaveBeenCalledWith(
contentHref + '?dtoken=' + dtoken + '&accessToken=' + accessToken);
expect(component.redirectToContent).not.toHaveBeenCalled();
});

it('should download through the file link with the access token for a logged-in user', () => {
Expand Down Expand Up @@ -266,7 +267,8 @@ describe('ClarinBitstreamDownloadPageComponent', () => {
component.ngOnInit();

expect(clarinCheckUrl()).toEqual('rest-api/authrn/bitstreamUuid?dtoken=' + dtoken);
expect(component.redirectToContent).toHaveBeenCalledWith(contentHref + '?dtoken=' + dtoken);
expect(hardRedirectService.redirect).toHaveBeenCalledWith(contentHref + '?dtoken=' + dtoken);
expect(component.redirectToContent).not.toHaveBeenCalled();
});

it('should send an anonymous user without an access token to the login page', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ export class ClarinBitstreamDownloadPageComponent implements OnInit {
this.redirectToContent(fileLink);
} else if ((isAuthorized || isAuthorizedByClarin) && !isLoggedIn) {
this.downloadStatus.next(RequestEntryState.Success);
this.redirectToContent(bitstreamURL);
// Server-side too, so crawlers get a 302. Logged-in users keep the client-side
// redirect: a server 302 right after login left the browser on the login page.
this.hardRedirectService.redirect(bitstreamURL);
} else if (!(isAuthorized || isAuthorizedByClarin) && isLoggedIn &&
this.downloadStatus.value === (RequestEntryState.Error as string)) {
// this.downloadStatus is `ERROR` - no CLARIN exception is thrown up
Expand Down
Loading