Skip to content

Commit

Permalink
Development: Fix LTI deep linking (#10346)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias-lippert authored Feb 17, 2025
1 parent 039e6c8 commit b80e594
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/main/webapp/app/lti/lti13-deep-linking.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { ArtemisTranslatePipe } from 'app/shared/pipes/artemis-translate.pipe';
import { SortByDirective } from 'app/shared/sort/sort-by.directive';
import { SortDirective } from 'app/shared/sort/sort.directive';
import { ArtemisDatePipe } from 'app/shared/pipes/artemis-date.pipe';
import { HasAnyAuthorityDirective } from 'app/shared/auth/has-any-authority.directive';

@Component({
selector: 'jhi-deep-linking',
Expand All @@ -32,6 +33,7 @@ import { ArtemisDatePipe } from 'app/shared/pipes/artemis-date.pipe';
SortDirective,
ArtemisDatePipe,
// NOTE: this is actually used in the html template, otherwise *jhiHasAnyAuthority would not work
HasAnyAuthorityDirective,
],
})
export class Lti13DeepLinkingComponent implements OnInit {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ComponentFixture, TestBed, fakeAsync, tick, waitForAsync } from '@angular/core/testing';
import { ComponentFixture, fakeAsync, TestBed, tick, waitForAsync } from '@angular/core/testing';
import { Lti13DeepLinkingComponent } from 'app/lti/lti13-deep-linking.component';
import { ActivatedRoute, Router } from '@angular/router';
import { HttpClient, HttpParams, HttpResponse } from '@angular/common/http';
Expand Down Expand Up @@ -27,7 +27,7 @@ describe('Lti13DeepLinkingComponent', () => {
const routerMock = { navigate: jest.fn() };
const httpMock = { post: jest.fn() };
const courseManagementServiceMock = { findWithExercises: jest.fn() };
const accountServiceMock = { identity: jest.fn(), getAuthenticationState: jest.fn() };
const accountServiceMock = { identity: jest.fn(), getAuthenticationState: jest.fn(), hasAnyAuthority: jest.fn().mockResolvedValue(true) };
const sortServiceMock = { sortByProperty: jest.fn() };
const alertServiceMock = { error: jest.fn(), addAlert: jest.fn() };

Expand Down Expand Up @@ -194,4 +194,9 @@ describe('Lti13DeepLinkingComponent', () => {
params: new HttpParams().set('exerciseIds', Array.from(component.selectedExercises!).join(',')).set('ltiIdToken', '').set('clientRegistrationId', ''),
});
});

it('should invoke account service using jhiHasAnyAuthority directive', () => {
fixture.detectChanges();
expect(accountServiceMock.hasAnyAuthority).toHaveBeenCalledWith(['ROLE_ADMIN', 'ROLE_INSTRUCTOR']);
});
});

0 comments on commit b80e594

Please sign in to comment.