-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'refs/heads/main' into N21-2191-fix-lti-encryption
- Loading branch information
Showing
24 changed files
with
295 additions
and
24 deletions.
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
apps/server/src/modules/tool/external-tool/entity/external-tool.entity.ts
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
17 changes: 17 additions & 0 deletions
17
apps/server/src/modules/user-license/domain/media-source-oauth-config.ts
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { AuthorizableObject, DomainObject } from '@shared/domain/domain-object'; | ||
import { EntityId } from '@shared/domain/types'; | ||
import { MediaSourceAuthMethod } from '../enum'; | ||
|
||
export interface MediaSourceOauthConfigProps extends AuthorizableObject { | ||
id: EntityId; | ||
|
||
clientId: string; | ||
|
||
clientSecret: string; | ||
|
||
authEndpoint: string; | ||
|
||
method: MediaSourceAuthMethod; | ||
} | ||
|
||
export class MediaSourceOauthConfig extends DomainObject<MediaSourceOauthConfigProps> {} |
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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
export { UserLicenseType } from './user-license-type'; | ||
export { UserLicenseType } from '../enum/user-license-type'; | ||
export { MediaUserLicenseEntity, MediaUserLicenseEntityProps } from './media-user-license.entity'; | ||
export { UserLicenseEntity } from './user-license.entity'; | ||
export { MediaSourceEntity, MediaSourceEntityProps } from './media-source.entity'; | ||
export { MediaSourceDataFormat } from '../enum/media-source-data-format.enum'; | ||
export { MediaSourceAuthMethod } from '../enum/media-source-auth-method.enum'; |
41 changes: 41 additions & 0 deletions
41
apps/server/src/modules/user-license/entity/media-source-oauth-config.embeddable.ts
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Embeddable, Enum, Property } from '@mikro-orm/core'; | ||
import { ObjectId } from '@mikro-orm/mongodb'; | ||
import { MediaSourceAuthMethod } from '../enum/media-source-auth-method.enum'; | ||
|
||
export interface MediaSourceConfigEmbeddableProps { | ||
_id: ObjectId; | ||
|
||
clientId: string; | ||
|
||
clientSecret: string; | ||
|
||
authEndpoint: string; | ||
|
||
method: MediaSourceAuthMethod; | ||
} | ||
|
||
@Embeddable() | ||
export class MediaSourceConfigEmbeddable { | ||
@Property() | ||
_id: ObjectId; | ||
|
||
@Property() | ||
clientId: string; | ||
|
||
@Property() | ||
clientSecret: string; | ||
|
||
@Property() | ||
authEndpoint: string; | ||
|
||
@Enum({ nullable: false }) | ||
method: MediaSourceAuthMethod; | ||
|
||
constructor(props: MediaSourceConfigEmbeddableProps) { | ||
this._id = props._id; | ||
this.clientId = props.clientId; | ||
this.clientSecret = props.clientSecret; | ||
this.authEndpoint = props.authEndpoint; | ||
this.method = props.method; | ||
} | ||
} |
26 changes: 20 additions & 6 deletions
26
apps/server/src/modules/user-license/entity/media-source.entity.ts
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 |
---|---|---|
@@ -1,30 +1,44 @@ | ||
import { Entity, Index, Property } from '@mikro-orm/core'; | ||
import { Embedded, Entity, Index, Property } from '@mikro-orm/core'; | ||
import { BaseEntityWithTimestamps } from '@shared/domain/entity/base.entity'; | ||
import { EntityId } from '@shared/domain/types'; | ||
import { MediaSourceDataFormat } from '../enum/media-source-data-format.enum'; | ||
import { MediaSourceConfigEmbeddable } from './media-source-oauth-config.embeddable'; | ||
|
||
export interface MediaSourceEntityProps { | ||
id?: EntityId; | ||
|
||
name?: string; | ||
|
||
sourceId: string; | ||
|
||
config?: MediaSourceConfigEmbeddable; | ||
|
||
format?: MediaSourceDataFormat; | ||
} | ||
|
||
@Entity({ tableName: 'media-sources' }) | ||
export class MediaSourceEntity extends BaseEntityWithTimestamps { | ||
constructor(props: MediaSourceEntityProps) { | ||
super(); | ||
if (props.id != null) { | ||
if (props.id) { | ||
this.id = props.id; | ||
} | ||
this.name = props.name; | ||
this.sourceId = props.sourceId; | ||
this.name = props.name; | ||
this.format = props.format; | ||
this.config = props.config; | ||
} | ||
|
||
@Property({ nullable: true }) | ||
name?: string; | ||
|
||
@Index() | ||
@Property() | ||
sourceId: string; | ||
|
||
@Property({ nullable: true }) | ||
name?: string; | ||
|
||
@Property({ nullable: true }) | ||
format?: MediaSourceDataFormat; | ||
|
||
@Embedded(() => MediaSourceConfigEmbeddable, { object: true, nullable: true }) | ||
config?: MediaSourceConfigEmbeddable; | ||
} |
2 changes: 1 addition & 1 deletion
2
apps/server/src/modules/user-license/entity/media-user-license.entity.ts
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { UserLicenseType } from './user-license-type'; | ||
export { MediaSourceDataFormat } from './media-source-data-format.enum'; | ||
export { MediaSourceAuthMethod } from './media-source-auth-method.enum'; |
3 changes: 3 additions & 0 deletions
3
apps/server/src/modules/user-license/enum/media-source-auth-method.enum.ts
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export enum MediaSourceAuthMethod { | ||
CLIENT_CREDENTIALS = 'CLIENT_CREDENTIALS', | ||
} |
3 changes: 3 additions & 0 deletions
3
apps/server/src/modules/user-license/enum/media-source-data-format.enum.ts
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export enum MediaSourceDataFormat { | ||
BILDUNGSLOGIN = 'BILDUNGSLOGIN', | ||
} |
File renamed without changes.
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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
export { UserLicenseModule } from './user-license.module'; | ||
export { MediaUserLicenseService, MediaSourceService } from './service'; | ||
export { MediaUserLicense, MediaSource, MediaUserLicenseProps, MediaSourceProps, AnyUserLicense } from './domain'; | ||
export { UserLicenseType } from './entity/user-license-type'; | ||
export { AnyUserLicense, MediaSource, MediaSourceProps, MediaUserLicense, MediaUserLicenseProps } from './domain'; | ||
export { MediaSourceEntity } from './entity'; | ||
export { UserLicenseType } from './enum/user-license-type'; | ||
export { MediaSourceService, MediaUserLicenseService } from './service'; | ||
export { | ||
mediaUserLicenseFactory, | ||
mediaSourceFactory, | ||
mediaSourceEntityFactory, | ||
mediaSourceFactory, | ||
mediaUserLicenseEntityFactory, | ||
mediaUserLicenseFactory, | ||
} from './testing'; | ||
export { UserLicenseModule } from './user-license.module'; |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { MediaSourceConfigMapper } from './media-source-config.mapper'; | ||
export { MediaSourceRepo } from './media-source.repo'; | ||
export { MediaUserLicenseRepo } from './media-user-license.repo'; | ||
export { UserLicenseQuery } from './user-license-query'; | ||
export { MediaSourceRepo } from './media-source.repo'; |
79 changes: 79 additions & 0 deletions
79
apps/server/src/modules/user-license/repo/media-source-config.mapper.spec.ts
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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { ObjectId } from '@mikro-orm/mongodb'; | ||
import { setupEntities } from '@shared/testing'; | ||
import { MediaSourceOauthConfig } from '../domain/media-source-oauth-config'; | ||
import { MediaSourceConfigEmbeddable } from '../entity/media-source-oauth-config.embeddable'; | ||
import { mediaSourceConfigEmbeddableFactory } from '../testing/media-source-config.embeddable.factory'; | ||
import { mediaSourceConfigFactory } from '../testing/media-source-config.factory'; | ||
import { MediaSourceConfigMapper } from './media-source-config.mapper'; | ||
|
||
describe('MediaSourceConfigMapper', () => { | ||
describe('mapToDo', () => { | ||
describe('when entity is passed', () => { | ||
const setup = async () => { | ||
await setupEntities(); | ||
|
||
const entity = mediaSourceConfigEmbeddableFactory.build(); | ||
const expected = new MediaSourceOauthConfig({ | ||
id: entity._id.toHexString(), | ||
clientId: entity.clientId, | ||
clientSecret: entity.clientSecret, | ||
authEndpoint: entity.authEndpoint, | ||
method: entity.method, | ||
}); | ||
|
||
return { entity, expected }; | ||
}; | ||
|
||
it('should return an instance of config', async () => { | ||
const { entity } = await setup(); | ||
|
||
const result = MediaSourceConfigMapper.mapToDo(entity); | ||
|
||
expect(result).toBeInstanceOf(MediaSourceOauthConfig); | ||
}); | ||
|
||
it('should return a do with all properties', async () => { | ||
const { entity, expected } = await setup(); | ||
|
||
const result = MediaSourceConfigMapper.mapToDo(entity); | ||
|
||
expect(result).toEqual(expected); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('mapToEntity', () => { | ||
describe('when config do is passed', () => { | ||
const setup = async () => { | ||
await setupEntities(); | ||
|
||
const configDo = mediaSourceConfigFactory.build(); | ||
const expected = new MediaSourceConfigEmbeddable({ | ||
_id: new ObjectId(configDo.id), | ||
clientId: configDo.getProps().clientId, | ||
clientSecret: configDo.getProps().clientSecret, | ||
authEndpoint: configDo.getProps().authEndpoint, | ||
method: configDo.getProps().method, | ||
}); | ||
|
||
return { configDo, expected }; | ||
}; | ||
|
||
it('should return an instance of config embeddable', async () => { | ||
const { configDo } = await setup(); | ||
|
||
const result = MediaSourceConfigMapper.mapToEntity(configDo); | ||
|
||
expect(result).toBeInstanceOf(MediaSourceConfigEmbeddable); | ||
}); | ||
|
||
it('should return an embeddable with all properties', async () => { | ||
const { configDo, expected } = await setup(); | ||
|
||
const result = MediaSourceConfigMapper.mapToEntity(configDo); | ||
|
||
expect(result).toEqual(expected); | ||
}); | ||
}); | ||
}); | ||
}); |
25 changes: 25 additions & 0 deletions
25
apps/server/src/modules/user-license/repo/media-source-config.mapper.ts
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ObjectId } from '@mikro-orm/mongodb'; | ||
import { MediaSourceOauthConfig } from '../domain/media-source-oauth-config'; | ||
import { MediaSourceConfigEmbeddable } from '../entity/media-source-oauth-config.embeddable'; | ||
|
||
export class MediaSourceConfigMapper { | ||
static mapToEntity(config: MediaSourceOauthConfig): MediaSourceConfigEmbeddable { | ||
const configProps = config.getProps(); | ||
|
||
const configEmbeddable = new MediaSourceConfigEmbeddable({ ...configProps, _id: new ObjectId(configProps.id) }); | ||
|
||
return configEmbeddable; | ||
} | ||
|
||
static mapToDo(embeddable: MediaSourceConfigEmbeddable): MediaSourceOauthConfig { | ||
const config = new MediaSourceOauthConfig({ | ||
id: embeddable._id.toHexString(), | ||
clientId: embeddable.clientId, | ||
clientSecret: embeddable.clientSecret, | ||
method: embeddable.method, | ||
authEndpoint: embeddable.authEndpoint, | ||
}); | ||
|
||
return config; | ||
} | ||
} |
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
Oops, something went wrong.