Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

N21 2149 merlin bibliothek element #5323

Merged
merged 28 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e349b48
poc
MarvinOehlerkingCap May 23, 2024
e779ef8
use cache
MarvinOehlerkingCap May 24, 2024
6020aa2
add deep link prop
MarvinOehlerkingCap May 24, 2024
929b0f2
re-deploy
MarvinOehlerkingCap Sep 16, 2024
a1e21d8
Merge branch 'refs/heads/N21-1829-deep-linking-poc' into N21-2149-mer…
mrikallab Oct 23, 2024
f154211
N21-2149 seed data
mrikallab Oct 25, 2024
f4df271
N21-2149 impl
mrikallab Oct 25, 2024
69416c3
Merge branch 'refs/heads/main' into N21-2149-merlin-bibliothek-element
mrikallab Oct 28, 2024
864747d
Merge branch 'refs/heads/main' into N21-2149-merlin-bibliothek-element
mrikallab Oct 28, 2024
38c43bc
Merge branch 'main' into N21-2149-merlin-bibliothek-element
MarvinOehlerkingCap Oct 30, 2024
4784089
remove poc code that is not needed yet
MarvinOehlerkingCap Oct 30, 2024
ce6a505
update seed data
MarvinOehlerkingCap Oct 30, 2024
ac988e9
add secret to db init
MarvinOehlerkingCap Oct 30, 2024
fa8573d
N21-2149 tests
mrikallab Nov 6, 2024
91c67b2
Merge remote-tracking branch 'origin/N21-2149-merlin-bibliothek-eleme…
mrikallab Nov 6, 2024
42f67b0
remove secrets again
MarvinOehlerkingCap Nov 6, 2024
d9a20fc
fix id in seed data
MarvinOehlerkingCap Nov 6, 2024
3dd1934
fix abstract strategy test
MarvinOehlerkingCap Nov 6, 2024
7a44226
Merge branch 'main' into N21-2149-merlin-bibliothek-element
MarvinOehlerkingCap Nov 6, 2024
f0d733b
fix tests
MarvinOehlerkingCap Nov 6, 2024
6100ca8
fix tests
MarvinOehlerkingCap Nov 6, 2024
ea1da38
improve test coverage
MarvinOehlerkingCap Nov 6, 2024
b0953ed
reduce "code duplication"
MarvinOehlerkingCap Nov 6, 2024
c0a987d
add iconName to seed data
MBergCap Nov 11, 2024
4b03b3f
Merge branch 'main' into N21-2149-merlin-bibliothek-element
MBergCap Nov 11, 2024
7c905e4
fix lti11-strategy test structure
MarvinOehlerkingCap Nov 12, 2024
0bf0c5d
Merge branch 'main' into N21-2149-merlin-bibliothek-element
MBergCap Nov 12, 2024
4eb67ba
Merge branch 'main' into N21-2149-merlin-bibliothek-element
MBergCap Nov 13, 2024
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 @@ -545,6 +545,17 @@ data:
"upsert": true
}
);'
mongosh $DATABASE__URL --quiet --eval 'db.getCollection("external-tools").updateOne(
{
"name": "Merlin Bibliothek",
},
{ $set: {
"config_secret": "'$CTL_SEED_SECRET_MERLIN'",
} },
{
"upsert": true
}
);'
echo "Inserted ctl seed data secrets to external-tools."

# ========== End of the CTL seed data configuration section.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export enum LtiMessageType {
BASIC_LTI_LAUNCH_REQUEST = 'basic-lti-launch-request',
CONTENT_ITEM_SELECTION_REQUEST = 'ContentItemSelectionRequest',
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Embedded, Entity, ManyToOne, Property } from '@mikro-orm/core';
import { ObjectId } from '@mikro-orm/mongodb';
import { BaseEntityWithTimestamps } from '@shared/domain/entity/base.entity';
import { EntityId } from '@shared/domain/types';
import { ObjectId } from '@mikro-orm/mongodb';
import { CustomParameterEntryEntity } from '../../common/entity';
import { SchoolExternalToolEntity } from '../../school-external-tool/entity';
import { ContextExternalToolType } from './context-external-tool-type.enum';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const externalToolDatasheetTemplateDataFactory = ExternalToolDatasheetTem
creatorName: `John Doe ${sequence}`,
instance: 'dBildungscloud',
toolName: `external-tool-${sequence}`,
toolUrl: 'https://www.basic-baseUrl.com/',
toolUrl: 'https://www.basic-baseurl.com/',
toolType: 'Basic',
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DeepPartial } from 'fishery';
import { ObjectId } from '@mikro-orm/mongodb';
import { DoBaseFactory } from '@shared/testing/factory/domainobject/do-base.factory';
import { DeepPartial } from 'fishery';
import { CustomParameter } from '../../common/domain';
import {
CustomParameterLocation,
Expand All @@ -24,7 +24,7 @@ import { fileRecordRefFactory } from './file-record-ref.factory';
export const basicToolConfigFactory = DoBaseFactory.define<BasicToolConfig, BasicToolConfig>(BasicToolConfig, () => {
return {
type: ToolConfigType.BASIC,
baseUrl: 'https://www.basic-baseUrl.com/',
baseUrl: 'https://www.basic-baseurl.com/',
};
});

Expand Down Expand Up @@ -86,24 +86,35 @@ export const customParameterFactory = CustomParameterFactory.define(CustomParame
});

class ExternalToolFactory extends DoBaseFactory<ExternalTool, ExternalToolProps> {
withBasicConfig(customParam?: DeepPartial<BasicToolConfig>): this {
const params: DeepPartial<ExternalTool> = {
config: basicToolConfigFactory.build(customParam),
};

return this.params(params);
}

withOauth2Config(customParam?: DeepPartial<Oauth2ToolConfig>): this {
const params: DeepPartial<ExternalTool> = {
config: oauth2ToolConfigFactory.build(customParam),
};

return this.params(params);
}

withLti11Config(customParam?: DeepPartial<Lti11ToolConfig>): this {
const params: DeepPartial<ExternalTool> = {
config: lti11ToolConfigFactory.build(customParam),
};

return this.params(params);
}

withCustomParameters(number: number, customParam?: DeepPartial<CustomParameter>): this {
const params: DeepPartial<ExternalTool> = {
parameters: customParameterFactory.buildList(number, customParam),
};

return this.params(params);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ describe(ExternalToolUc.name, () => {

const lti11ToolConfig: Lti11ToolConfigUpdate = {
type: ToolConfigType.LTI11,
baseUrl: 'https://www.basic-baseUrl.com/',
baseUrl: 'https://www.basic-baseurl.com/',
key: 'key',
privacy_permission: LtiPrivacyPermission.PSEUDONYMOUS,
lti_message_type: LtiMessageType.BASIC_LTI_LAUNCH_REQUEST,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ describe('ToolLaunchController (API)', () => {
method: LaunchRequestMethod.GET,
url: 'https://mockurl.de/',
openNewTab: true,
isDeepLink: false,
});
});
});
Expand Down Expand Up @@ -413,6 +414,7 @@ describe('ToolLaunchController (API)', () => {
method: LaunchRequestMethod.GET,
url: 'https://mockurl.de/',
openNewTab: true,
isDeepLink: false,
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,16 @@ export class ToolLaunchRequestResponse {
})
openNewTab?: boolean;

@ApiProperty({
description: 'Specifies whether the request is an LTI Deep linking content item selection request',
})
isDeepLink: boolean;

constructor(props: ToolLaunchRequestResponse) {
this.url = props.url;
this.method = props.method;
this.payload = props.payload;
this.openNewTab = props.openNewTab;
this.isDeepLink = props.isDeepLink;
}
}
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
import { contextExternalToolFactory } from '../../context-external-tool/testing';
import { toolConfigurationStatusFactory } from '../../external-tool/testing';
import { ToolStatusNotLaunchableLoggableException } from './tool-status-not-launchable.loggable-exception';

describe('ToolStatusNotLaunchableLoggableException', () => {
describe(ToolStatusNotLaunchableLoggableException.name, () => {
describe('getLogMessage', () => {
const setup = () => {
const toolId = 'toolId';
const userId = 'userId';
const contextExternalTool = contextExternalToolFactory.build();
const toolConfigStatus = toolConfigurationStatusFactory.build();

const exception = new ToolStatusNotLaunchableLoggableException(
userId,
toolId,
toolConfigStatus.isOutdatedOnScopeSchool,
toolConfigStatus.isOutdatedOnScopeContext,
toolConfigStatus.isIncompleteOnScopeContext,
toolConfigStatus.isIncompleteOperationalOnScopeContext,
toolConfigStatus.isDeactivated,
toolConfigStatus.isNotLicensed
);
const exception = new ToolStatusNotLaunchableLoggableException(userId, contextExternalTool, toolConfigStatus);

return {
exception,
toolConfigStatus,
contextExternalTool,
};
};

it('should log the correct message', () => {
const { exception } = setup();
const { exception, toolConfigStatus, contextExternalTool } = setup();

const result = exception.getLogMessage();

Expand All @@ -35,13 +29,9 @@ describe('ToolStatusNotLaunchableLoggableException', () => {
stack: expect.any(String),
data: {
userId: 'userId',
toolId: 'toolId',
isOutdatedOnScopeSchool: false,
isOutdatedOnScopeContext: false,
isIncompleteOnScopeContext: false,
isIncompleteOperationalOnScopeContext: false,
isDeactivated: false,
isNotLicensed: false,
contextExternalToolId: contextExternalTool.id,
schoolExternalToolId: contextExternalTool.schoolToolRef.schoolToolId,
status: toolConfigStatus,
},
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { UnprocessableEntityException } from '@nestjs/common';
import { EntityId } from '@shared/domain/types';
import { ErrorLogMessage, Loggable, LogMessage, ValidationErrorLogMessage } from '@src/core/logger';
import { ContextExternalToolConfigurationStatus } from '../../common/domain';
import { ContextExternalToolLaunchable } from '../../context-external-tool/domain';

export class ToolStatusNotLaunchableLoggableException extends UnprocessableEntityException implements Loggable {
constructor(
private readonly userId: EntityId,
private readonly toolId: EntityId,
private readonly isOutdatedOnScopeSchool: boolean,
private readonly isOutdatedOnScopeContext: boolean,
private readonly isIncompleteOnScopeContext: boolean,
private readonly isIncompleteOperationalOnScopeContext: boolean,
private readonly isDeactivated: boolean,
private readonly isNotLicensed: boolean
private readonly contextExternalTool: ContextExternalToolLaunchable,
private readonly configStatus: ContextExternalToolConfigurationStatus
) {
super();
}
Expand All @@ -23,13 +20,9 @@ export class ToolStatusNotLaunchableLoggableException extends UnprocessableEntit
stack: this.stack,
data: {
userId: this.userId,
toolId: this.toolId,
isOutdatedOnScopeSchool: this.isOutdatedOnScopeSchool,
isOutdatedOnScopeContext: this.isOutdatedOnScopeContext,
isIncompleteOnScopeContext: this.isIncompleteOnScopeContext,
isIncompleteOperationalOnScopeContext: this.isIncompleteOperationalOnScopeContext,
isDeactivated: this.isDeactivated,
isNotLicensed: this.isNotLicensed,
contextExternalToolId: this.contextExternalTool.id,
schoolExternalToolId: this.contextExternalTool.schoolToolRef.schoolToolId,
status: { ...this.configStatus },
},
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CustomParameterLocation, ToolConfigType } from '../../common/enum';
import { ToolLaunchRequestResponse } from '../controller/dto';
import { LaunchRequestMethod, PropertyLocation, ToolLaunchDataType, ToolLaunchRequest } from '../types';
import { ToolLaunchMapper } from './tool-launch.mapper';
import { CustomParameterLocation, ToolConfigType } from '../../common/enum';

describe('ToolLaunchMapper', () => {
describe('mapToParameterLocation', () => {
Expand Down Expand Up @@ -33,15 +33,17 @@ describe('ToolLaunchMapper', () => {
url: 'url',
openNewTab: true,
payload: 'payload',
isDeepLink: false,
});

const result: ToolLaunchRequestResponse = ToolLaunchMapper.mapToToolLaunchRequestResponse(toolLaunchRequest);

expect(result).toEqual({
expect(result).toEqual<ToolLaunchRequestResponse>({
method: toolLaunchRequest.method,
url: toolLaunchRequest.url,
payload: toolLaunchRequest.payload,
openNewTab: toolLaunchRequest.openNewTab,
isDeepLink: toolLaunchRequest.isDeepLink,
});
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PropertyLocation, ToolLaunchDataType, ToolLaunchRequest } from '../types';
import { ToolLaunchRequestResponse } from '../controller/dto';
import { CustomParameterLocation, ToolConfigType } from '../../common/enum';
import { ToolLaunchRequestResponse } from '../controller/dto';
import { PropertyLocation, ToolLaunchDataType, ToolLaunchRequest } from '../types';

const customToParameterLocationMapping: Record<CustomParameterLocation, PropertyLocation> = {
[CustomParameterLocation.PATH]: PropertyLocation.PATH,
Expand All @@ -14,37 +14,22 @@ const toolConfigTypeToToolLaunchDataTypeMapping: Record<ToolConfigType, ToolLaun
[ToolConfigType.OAUTH2]: ToolLaunchDataType.OAUTH2,
};

const toolLaunchDataTypeToToolConfigTypeMapping: Record<ToolLaunchDataType, ToolConfigType> = {
[ToolLaunchDataType.BASIC]: ToolConfigType.BASIC,
[ToolLaunchDataType.LTI11]: ToolConfigType.LTI11,
[ToolLaunchDataType.OAUTH2]: ToolConfigType.OAUTH2,
};

export class ToolLaunchMapper {
static mapToParameterLocation(location: CustomParameterLocation): PropertyLocation {
const mappedLocation = customToParameterLocationMapping[location];

return mappedLocation;
}

static mapToToolLaunchDataType(configType: ToolConfigType): ToolLaunchDataType {
const mappedType = toolConfigTypeToToolLaunchDataTypeMapping[configType];
return mappedType;
}

static mapToToolConfigType(launchDataType: ToolLaunchDataType): ToolConfigType {
const mappedType = toolLaunchDataTypeToToolConfigTypeMapping[launchDataType];
return mappedType;
}

static mapToToolLaunchRequestResponse(toolLaunchRequest: ToolLaunchRequest): ToolLaunchRequestResponse {
const { method, url, payload, openNewTab } = toolLaunchRequest;

const response = new ToolLaunchRequestResponse({
method,
url,
payload,
openNewTab,
});
const response = new ToolLaunchRequestResponse(toolLaunchRequest);

return response;
}
}
Loading
Loading