Skip to content

Commit 0f6fdce

Browse files
Merge branch 'main' into w2p-93889_Invalidate-EPerson-when-their-group-change
2 parents 95e8346 + 6d361be commit 0f6fdce

89 files changed

Lines changed: 20076 additions & 9027 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
1-
# Auto detect text files and perform LF normalization
1+
# By default, auto detect text files and perform LF normalization
2+
# This ensures code is always checked in with LF line endings
23
* text=auto
4+
5+
# JS and TS files must always use LF for Angular tools to work
6+
# Some Angular tools expect LF line endings, even on Windows.
7+
# This ensures Windows always checks out these files with LF line endings
8+
# We've copied many of these rules from https://github.com/angular/angular-cli/
9+
*.js eol=lf
10+
*.ts eol=lf
11+
*.json eol=lf
12+
*.json5 eol=lf
13+
*.css eol=lf
14+
*.scss eol=lf
15+
*.html eol=lf
16+
*.svg eol=lf

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ If needing to update default configurations values for production, update local
179179

180180
- Update `environment.production.ts` file in `src/environment/` for a `production` environment;
181181

182-
The environment object is provided for use as import in code and is extended with he runtime configuration on bootstrap of the application.
182+
The environment object is provided for use as import in code and is extended with the runtime configuration on bootstrap of the application.
183183

184184
> Take caution moving runtime configs into the buildtime configuration. They will be overwritten by what is defined in the runtime config on bootstrap.
185185

config/config.example.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ languages:
150150
- code: fi
151151
label: Suomi
152152
active: true
153+
- code: sv
154+
label: Svenska
155+
active: true
153156
- code: tr
154157
label: Türkçe
155158
active: true

scripts/serve.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ const appConfig: AppConfig = buildAppConfig();
77

88
/**
99
* Calls `ng serve` with the following arguments configured for the UI in the app config: host, port, nameSpace, ssl
10+
* Any CLI arguments given to this script are patched through to `ng serve` as well.
1011
*/
1112
child.spawn(
12-
`ng serve --host ${appConfig.ui.host} --port ${appConfig.ui.port} --serve-path ${appConfig.ui.nameSpace} --ssl ${appConfig.ui.ssl}`,
13+
`ng serve --host ${appConfig.ui.host} --port ${appConfig.ui.port} --serve-path ${appConfig.ui.nameSpace} --ssl ${appConfig.ui.ssl} ${process.argv.slice(2).join(' ')}`,
1314
{ stdio: 'inherit', shell: true }
1415
);

scripts/sync-i18n-files.ts

100755100644
File mode changed.

src/app/admin/admin-sidebar/admin-sidebar.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<nav @slideHorizontal class="navbar navbar-dark p-0"
1+
<nav class="navbar navbar-dark p-0"
22
[ngClass]="{'active': sidebarOpen, 'inactive': sidebarClosed}"
33
[@slideSidebar]="{
44
value: (!(sidebarExpanded | async) ? 'collapsed' : 'expanded'),

src/app/admin/admin-sidebar/admin-sidebar.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Component, HostListener, Injector, OnInit } from '@angular/core';
22
import { BehaviorSubject, combineLatest, Observable } from 'rxjs';
33
import { debounceTime, distinctUntilChanged, first, map, withLatestFrom } from 'rxjs/operators';
44
import { AuthService } from '../../core/auth/auth.service';
5-
import { slideHorizontal, slideSidebar } from '../../shared/animations/slide';
5+
import { slideSidebar } from '../../shared/animations/slide';
66
import { MenuComponent } from '../../shared/menu/menu.component';
77
import { MenuService } from '../../shared/menu/menu.service';
88
import { CSSVariableService } from '../../shared/sass-helper/sass-helper.service';
@@ -18,7 +18,7 @@ import { ThemeService } from '../../shared/theme-support/theme.service';
1818
selector: 'ds-admin-sidebar',
1919
templateUrl: './admin-sidebar.component.html',
2020
styleUrls: ['./admin-sidebar.component.scss'],
21-
animations: [slideHorizontal, slideSidebar]
21+
animations: [slideSidebar]
2222
})
2323
export class AdminSidebarComponent extends MenuComponent implements OnInit {
2424
/**

src/app/app.module.ts

100755100644
File mode changed.

src/app/browse-by/browse-by-metadata-page/browse-by-metadata-page.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import { BrowseByDataType, rendersBrowseBy } from '../browse-by-switcher/browse-
1818
import { PaginationService } from '../../core/pagination/pagination.service';
1919
import { map } from 'rxjs/operators';
2020

21+
export const BBM_PAGINATION_ID = 'bbm';
22+
2123
@Component({
2224
selector: 'ds-browse-by-metadata-page',
2325
styleUrls: ['./browse-by-metadata-page.component.scss'],
@@ -50,7 +52,7 @@ export class BrowseByMetadataPageComponent implements OnInit {
5052
* The pagination config used to display the values
5153
*/
5254
paginationConfig: PaginationComponentOptions = Object.assign(new PaginationComponentOptions(), {
53-
id: 'bbm',
55+
id: BBM_PAGINATION_ID,
5456
currentPage: 1,
5557
pageSize: 20
5658
});

src/app/core/auth/auth-request.service.spec.ts

Lines changed: 129 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,56 +7,155 @@ import { TestScheduler } from 'rxjs/testing';
77
import { createSuccessfulRemoteDataObject } from '../../shared/remote-data.utils';
88
import { ShortLivedToken } from './models/short-lived-token.model';
99
import { RemoteData } from '../data/remote-data';
10+
import { HttpOptions } from '../dspace-rest/dspace-rest.service';
11+
import objectContaining = jasmine.objectContaining;
12+
import { AuthStatus } from './models/auth-status.model';
13+
import { RestRequestMethod } from '../data/rest-request-method';
1014

1115
describe(`AuthRequestService`, () => {
1216
let halService: HALEndpointService;
1317
let endpointURL: string;
18+
let requestID: string;
1419
let shortLivedToken: ShortLivedToken;
1520
let shortLivedTokenRD: RemoteData<ShortLivedToken>;
1621
let requestService: RequestService;
1722
let rdbService: RemoteDataBuildService;
18-
let service: AuthRequestService;
23+
let service;
1924
let testScheduler;
2025

21-
class TestAuthRequestService extends AuthRequestService {
22-
constructor(
23-
hes: HALEndpointService,
24-
rs: RequestService,
25-
rdbs: RemoteDataBuildService
26-
) {
27-
super(hes, rs, rdbs);
28-
}
29-
30-
protected createShortLivedTokenRequest(href: string): PostRequest {
31-
return new PostRequest(this.requestService.generateRequestId(), href);
32-
}
26+
const status = new AuthStatus();
27+
28+
class TestAuthRequestService extends AuthRequestService {
29+
constructor(
30+
hes: HALEndpointService,
31+
rs: RequestService,
32+
rdbs: RemoteDataBuildService
33+
) {
34+
super(hes, rs, rdbs);
3335
}
3436

35-
const init = (cold: typeof TestScheduler.prototype.createColdObservable) => {
36-
endpointURL = 'https://rest.api/auth';
37-
shortLivedToken = Object.assign(new ShortLivedToken(), {
38-
value: 'some-token'
39-
});
40-
shortLivedTokenRD = createSuccessfulRemoteDataObject(shortLivedToken);
37+
protected createShortLivedTokenRequest(href: string): PostRequest {
38+
return new PostRequest(this.requestService.generateRequestId(), href);
39+
}
40+
}
41+
42+
const init = (cold: typeof TestScheduler.prototype.createColdObservable) => {
43+
endpointURL = 'https://rest.api/auth';
44+
requestID = 'requestID';
45+
shortLivedToken = Object.assign(new ShortLivedToken(), {
46+
value: 'some-token'
47+
});
48+
shortLivedTokenRD = createSuccessfulRemoteDataObject(shortLivedToken);
49+
50+
halService = jasmine.createSpyObj('halService', {
51+
'getEndpoint': cold('a', { a: endpointURL })
52+
});
53+
requestService = jasmine.createSpyObj('requestService', {
54+
'generateRequestId': requestID,
55+
'send': null,
56+
});
57+
rdbService = jasmine.createSpyObj('rdbService', {
58+
'buildFromRequestUUID': cold('a', { a: shortLivedTokenRD })
59+
});
60+
61+
service = new TestAuthRequestService(halService, requestService, rdbService);
62+
63+
spyOn(service as any, 'fetchRequest').and.returnValue(cold('a', { a: createSuccessfulRemoteDataObject(status) }));
64+
};
65+
66+
beforeEach(() => {
67+
testScheduler = new TestScheduler((actual, expected) => {
68+
expect(actual).toEqual(expected);
69+
});
70+
});
71+
72+
describe('REST request methods', () => {
73+
let options: HttpOptions;
4174

42-
halService = jasmine.createSpyObj('halService', {
43-
'getEndpoint': cold('a', { a: endpointURL })
75+
beforeEach(() => {
76+
options = Object.create({});
77+
});
78+
79+
describe('GET', () => {
80+
it('should send a GET request to the right endpoint and return the auth status', () => {
81+
testScheduler.run(({ cold, expectObservable, flush }) => {
82+
init(cold);
83+
84+
expectObservable(service.getRequest('method', options)).toBe('a', {
85+
a: objectContaining({ payload: status }),
86+
});
87+
flush();
88+
89+
expect(requestService.send).toHaveBeenCalledWith(objectContaining({
90+
uuid: requestID,
91+
href: endpointURL + '/method',
92+
method: RestRequestMethod.GET,
93+
body: undefined,
94+
options,
95+
}));
96+
expect((service as any).fetchRequest).toHaveBeenCalledWith(requestID);
97+
});
4498
});
45-
requestService = jasmine.createSpyObj('requestService', {
46-
'send': null
99+
100+
it('should send the request even if caller doesn\'t subscribe to the response', () => {
101+
testScheduler.run(({ cold, flush }) => {
102+
init(cold);
103+
104+
service.getRequest('method', options);
105+
flush();
106+
107+
expect(requestService.send).toHaveBeenCalledWith(objectContaining({
108+
uuid: requestID,
109+
href: endpointURL + '/method',
110+
method: RestRequestMethod.GET,
111+
body: undefined,
112+
options,
113+
}));
114+
expect((service as any).fetchRequest).toHaveBeenCalledWith(requestID);
115+
});
47116
});
48-
rdbService = jasmine.createSpyObj('rdbService', {
49-
'buildFromRequestUUID': cold('a', { a: shortLivedTokenRD })
117+
});
118+
119+
describe('POST', () => {
120+
it('should send a POST request to the right endpoint and return the auth status', () => {
121+
testScheduler.run(({ cold, expectObservable, flush }) => {
122+
init(cold);
123+
124+
expectObservable(service.postToEndpoint('method', { content: 'something' }, options)).toBe('a', {
125+
a: objectContaining({ payload: status }),
126+
});
127+
flush();
128+
129+
expect(requestService.send).toHaveBeenCalledWith(objectContaining({
130+
uuid: requestID,
131+
href: endpointURL + '/method',
132+
method: RestRequestMethod.POST,
133+
body: { content: 'something' },
134+
options,
135+
}));
136+
expect((service as any).fetchRequest).toHaveBeenCalledWith(requestID);
137+
});
50138
});
51139

52-
service = new TestAuthRequestService(halService, requestService, rdbService);
53-
};
140+
it('should send the request even if caller doesn\'t subscribe to the response', () => {
141+
testScheduler.run(({ cold, flush }) => {
142+
init(cold);
54143

55-
beforeEach(() => {
56-
testScheduler = new TestScheduler((actual, expected) => {
57-
expect(actual).toEqual(expected);
144+
service.postToEndpoint('method', { content: 'something' }, options);
145+
flush();
146+
147+
expect(requestService.send).toHaveBeenCalledWith(objectContaining({
148+
uuid: requestID,
149+
href: endpointURL + '/method',
150+
method: RestRequestMethod.POST,
151+
body: { content: 'something' },
152+
options,
153+
}));
154+
expect((service as any).fetchRequest).toHaveBeenCalledWith(requestID);
155+
});
58156
});
59157
});
158+
});
60159

61160
describe(`getShortlivedToken`, () => {
62161
it(`should call createShortLivedTokenRequest with the url for the endpoint`, () => {

0 commit comments

Comments
 (0)