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

BC-8551 - Delete const ALL_ENTITIES #5446

Open
wants to merge 103 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 65 commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
c6f90a6
Initial removing all entities by directly import same data to every u…
CeEv Jan 17, 2025
9ca120b
fix import order
CeEv Jan 17, 2025
b2bae87
Add linter rule for deep imports into .modules and .app.modules.
CeEv Jan 17, 2025
738f432
Merge branch 'main' into BC-8551-remove-all-entities
CeEv Jan 20, 2025
a0241e5
Reduce available entities for feathers to minimal needed.
CeEv Jan 21, 2025
f13549e
Merge branch 'main' into BC-8551-remove-all-entities
CeEv Jan 21, 2025
d90b433
Change linter rule to match for file names with numbers.
CeEv Jan 21, 2025
2d10afe
Change linter rule from error to warn. Error was wrong commited.
CeEv Jan 22, 2025
558e01b
Merge branch 'main' into BC-8551-remove-all-entities
CeEv Jan 23, 2025
7b083be
Update mikro-orm-cli.config.ts
CeEv Jan 23, 2025
0e7f1a8
fix unresolved merge conflict
CeEv Jan 23, 2025
fcdb973
BC-8551 - reduce used entities of `board-collaboration.app.module.ts`
bergatco Jan 23, 2025
3c03f90
BC-8551 - remove `MikroOrmModule` from `common-cartridge.module.ts`
bergatco Jan 24, 2025
14ca6a9
BC-8551 - remove `MikroOrmModule` from `deletion-console.app.module.ts`
bergatco Jan 24, 2025
3b08726
BC-8551 - reduce used entities of `idp-console.app.module.ts`
bergatco Jan 24, 2025
42d6ab4
BC-8551 - reduce used entities of `management-server.app.module.ts`
bergatco Jan 24, 2025
57439fd
@bergatco
bergatco Jan 24, 2025
043a5d3
BC-8551 - reduce used entities of `server.app.module.ts`
bergatco Jan 24, 2025
050a1e5
BC-8551 - fix entities array in `server.app.module.ts`
bergatco Jan 24, 2025
dc391de
BC-8551 - readd and reduce used entities of `deletion-console.app.mod…
bergatco Jan 24, 2025
4dd09a3
@bergatco
bergatco Jan 24, 2025
1b3507c
Merge branch 'main' into BC-8551-remove-all-entities
bergatco Jan 24, 2025
399debb
Make more entities available for feathers tests
CeEv Jan 24, 2025
23ff8c7
Merge branch 'BC-8551-remove-all-entities' of https://github.com/hpi-…
CeEv Jan 24, 2025
2e3a005
Merge branch 'main' into BC-8551-remove-all-entities
CeEv Jan 24, 2025
b7bbc82
Add todos
CeEv Jan 24, 2025
6c51ce7
Merge branch 'BC-8551-remove-all-entities' of https://github.com/hpi-…
CeEv Jan 24, 2025
187d424
Try regex search for entities
CeEv Jan 24, 2025
73c91e0
Change entity detection for legacy to regex. Rename file that do not …
CeEv Jan 24, 2025
2835248
Cleanup code
CeEv Jan 24, 2025
f5e32e1
Refactor entity paths in setupNestServices for consistency
SevenWaysDP Jan 27, 2025
db526d6
BC-8551 - readd and reduce entities to `files-storage-test.module.ts`
bergatco Jan 27, 2025
bd922ce
BC-8551 - remove `courseFactory` from `files-storage.consumer.spec.ts`
bergatco Jan 27, 2025
62210d8
BC-8551 - remove `courseFactory` from `files-storage-copy-files.api.s…
bergatco Jan 27, 2025
134fd5b
Merge branch 'main' into BC-8551-remove-all-entities
CeEv Jan 27, 2025
26ad5a7
Fix test setup for legacy registrationPins. It want to try cleanup pi…
CeEv Jan 27, 2025
352a363
Resolve unnecessary dependencies to other entities by using UserAndAc…
CeEv Jan 27, 2025
640e7e2
Refactor import path for DashboardEntity and GridElement in dashboard…
SevenWaysDP Jan 27, 2025
0555a25
Remove added entities in files-storage for tests.
CeEv Jan 27, 2025
c9353d0
Merge branch 'main' into BC-8551-remove-all-entities
CeEv Jan 27, 2025
1ea9298
Merge remote-tracking branch 'origin/BC-8551-remove-all-entities' int…
SevenWaysDP Jan 27, 2025
e6481a4
Refactor import path for GridElement in dashboardElement.entity.spec.ts
SevenWaysDP Jan 27, 2025
42c2d55
Modified helper to work without persists.
CeEv Jan 27, 2025
2f48846
linter
CeEv Jan 27, 2025
7b4fd21
Merge branch 'main' into BC-8551-remove-all-entities
CeEv Jan 28, 2025
5ccfe8b
Add loginByUser method to TestApiClient for JWT authentication
SevenWaysDP Jan 28, 2025
04e3a6b
Refactor H5P editor tests to use loginByUser method
SevenWaysDP Jan 28, 2025
615b5fe
Add getAuthHeader method and refactor file storage tests to use TestA…
SevenWaysDP Jan 28, 2025
532b093
Update CurrentUserMapper tests to use user school ID and add User and…
SevenWaysDP Jan 28, 2025
967993e
Refactor entity imports in FwuLearningContents modules for better org…
SevenWaysDP Jan 29, 2025
6012321
Integrate MikroOrmModule for MongoDB support in FilesStorage modules …
SevenWaysDP Jan 29, 2025
562cea5
Refactor H5P editor module to use centralized entity exports for impr…
SevenWaysDP Jan 29, 2025
a606f33
Refactor management module to centralize entity imports for improved …
SevenWaysDP Jan 30, 2025
7f81788
Refactor MikroORM configuration to separate entity imports into a ded…
SevenWaysDP Jan 30, 2025
41afc94
Refactor server module to centralize entity imports into a dedicated …
SevenWaysDP Jan 30, 2025
e3b827a
Refactor board module to centralize entity imports into a dedicated f…
SevenWaysDP Jan 30, 2025
c6379d7
Refactor files-storage module to separate test entities for improved …
SevenWaysDP Jan 30, 2025
d3b4a9b
Refactor fwu-learning-contents module to separate test entities for i…
SevenWaysDP Jan 30, 2025
4107f40
Refactor admin API server module to centralize entity imports and imp…
SevenWaysDP Jan 30, 2025
152c283
Refactor admin API server entity imports to include additional tool e…
SevenWaysDP Jan 30, 2025
6d86f2d
Refactor server module to include TEST_ENTITIES for improved testing …
SevenWaysDP Jan 30, 2025
359671c
Merge branch 'main' into BC-8551-remove-all-entities
SevenWaysDP Jan 30, 2025
d29a2fa
Merge remote-tracking branch 'origin/BC-8551-remove-all-entities' int…
SevenWaysDP Jan 30, 2025
155b811
Refactor MongoMemoryDatabaseModule to use TEST_ENTITIES for improved …
SevenWaysDP Jan 30, 2025
1f8aae0
Add migrations.entity.imports for centralized entity imports in serve…
SevenWaysDP Jan 30, 2025
9159ae5
Refactor setupNestServices to use TEST_ENTITIES for improved testing …
SevenWaysDP Jan 31, 2025
75d0b5f
Remove TEST_ENTITIES from MongoMemoryDatabaseModule for improved conf…
SevenWaysDP Jan 31, 2025
2e90bb5
Merge branch 'main' into BC-8551-remove-all-entities
SevenWaysDP Jan 31, 2025
f0e1318
Update MongoMemoryDatabaseModule imports to specify entities for *.r…
SevenWaysDP Jan 31, 2025
041c476
Add entities to repo tests
bischofmax Jan 31, 2025
449ef07
fixup! Update MongoMemoryDatabaseModule imports to specify entities f…
SevenWaysDP Jan 31, 2025
504c312
Merge remote-tracking branch 'origin/BC-8551-remove-all-entities' int…
SevenWaysDP Jan 31, 2025
d6e0143
Refactor H5P editor module to use TEST_ENTITIES for MongoMemoryDataba…
SevenWaysDP Jan 31, 2025
cec4322
Add entities to integration tests
bischofmax Jan 31, 2025
9213dd3
Merge branch 'BC-8551-remove-all-entities' of github.com:hpi-schul-cl…
bischofmax Jan 31, 2025
7450d45
Update MongoMemoryDatabaseModule imports to specify entities in ident…
SevenWaysDP Jan 31, 2025
be9efe9
Refactor deletion-console module to centralize entity imports and use…
SevenWaysDP Jan 31, 2025
06bf1b1
Merge remote-tracking branch 'origin/BC-8551-remove-all-entities' int…
SevenWaysDP Jan 31, 2025
49ec7dc
Add entities to more tests
bischofmax Jan 31, 2025
cc6878d
Refactor server-console module to management-console, removing unused…
SevenWaysDP Jan 31, 2025
88f88a8
Add entities to tests
bischofmax Jan 31, 2025
0631e7a
Merge remote-tracking branch 'origin/main' into BC-8551-remove-all-en…
SevenWaysDP Feb 3, 2025
d2d75db
Refactor database management module: move service and tests to manage…
SevenWaysDP Feb 3, 2025
41c0333
Refactor IDP console module: consolidate entity imports and update te…
SevenWaysDP Feb 3, 2025
20cf968
Fix import issue in setup-entities.ts: temporarily disable eslint rul…
SevenWaysDP Feb 3, 2025
9e6541a
Remove unused MikroORM CLI configuration and entity imports; update d…
SevenWaysDP Feb 4, 2025
f3e1123
fixup! Remove unused MikroORM CLI configuration and entity imports; u…
SevenWaysDP Feb 4, 2025
aec7720
Update sonar-project.properties: add setup-entities.ts to CPD exclusions
SevenWaysDP Feb 4, 2025
864e9fa
Merge remote-tracking branch 'origin/main' into BC-8551-remove-all-en…
SevenWaysDP Feb 4, 2025
620ef66
Update sonar-project.properties to correct CPD exclusions for setup-e…
SevenWaysDP Feb 4, 2025
2b35c62
code review
SevenWaysDP Feb 4, 2025
7690a35
check entities in deletion-console entity imports
SevenWaysDP Feb 4, 2025
edd6a39
Add missing entity imports to admin-api-server.entity.imports.ts
SevenWaysDP Feb 4, 2025
3f8f5f8
Refactor user module to integrate FilesStorageClientAdapterService an…
SevenWaysDP Feb 5, 2025
209e447
Refactor management-console module imports for clarity and consistency
SevenWaysDP Feb 5, 2025
0958e65
Merge branch 'main' into BC-8551-remove-all-entities
SevenWaysDP Feb 5, 2025
988adde
Integrate RabbitMQWrapperModule into deletion-console and files-stora…
SevenWaysDP Feb 5, 2025
6026e0c
Remove RabbitMQWrapperModule and related test modules from deletion-c…
SevenWaysDP Feb 6, 2025
f8d9db6
revert remove MikroORM from common-cartridge module
SevenWaysDP Feb 6, 2025
004e887
Revert "Refactor user module to integrate FilesStorageClientAdapterSe…
SevenWaysDP Feb 6, 2025
6900e4f
Merge remote-tracking branch 'origin/main' into BC-8551-remove-all-en…
SevenWaysDP Feb 6, 2025
e322d63
Merge remote-tracking branch 'origin/main' into BC-8551-remove-all-en…
SevenWaysDP Feb 7, 2025
20c135e
Merge branch 'main' into BC-8551-remove-all-entities
SevenWaysDP Feb 7, 2025
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
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ module.exports = {
},
overrides: [
{
files: ['apps/**/*.ts'],
files: ['apps/server/src/**/*.ts'],
env: {
node: true,
es6: true,
Expand All @@ -92,7 +92,7 @@ module.exports = {
'class-methods-use-this': 'off',
'no-param-reassign': 'off',
'no-underscore-dangle': 'off',
'filename-rules/match': [1, 'kebabcase'],
'filename-rules/match': [1, /^([a-z0-9]+-)*[a-z]+(?:\..*)?$/],
'require-await': 'warn',
'@typescript-eslint/unbound-method': 'error',
'@typescript-eslint/no-non-null-assertion': 'warn',
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/apps/server.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ async function bootstrap(): Promise<void> {

// logger middleware for deprecated paths
// TODO remove when all calls to the server are migrated
const logDeprecatedPaths = (req: express.Request, res: express.Response, next: express.NextFunction) => {
const logDeprecatedPaths = (req: express.Request, res: express.Response, next: express.NextFunction): void => {
legacyLogger.error(req.path, 'DEPRECATED-PATH');
next();
};
Expand Down
12 changes: 8 additions & 4 deletions apps/server/src/config/mikro-orm-cli.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// TODO: Rename file it is only used for migrations
SevenWaysDP marked this conversation as resolved.
Show resolved Hide resolved
import { DB_PASSWORD, DB_URL, DB_USERNAME } from '@imports-from-feathers';
import type { MikroOrmModuleSyncOptions } from '@mikro-orm/nestjs/typings';
import { FileRecord } from '@modules/files-storage/entity';
import { FileEntity } from '@modules/files/entity';
import { ALL_ENTITIES } from '@shared/domain/entity';
import path from 'path';
import { ENTITIES } from './mikro-orm-cli.entity.imports';

const migrationsPath = path.resolve(__dirname, '..', 'migrations', 'mikro-orm');

Expand All @@ -13,7 +12,12 @@ export const mikroOrmCliConfig: MikroOrmModuleSyncOptions = {
clientUrl: DB_URL,
password: DB_PASSWORD,
user: DB_USERNAME,
entities: [...ALL_ENTITIES, FileEntity, FileRecord],
entities: ENTITIES,
// TODO: use regex instead https://github.com/mikro-orm/nestjs-realworld-example-app/blob/master/src/mikro-orm.config.ts.example
// metadataProvider: TsMorphMetadataProvider,
// entities: ['dist/apps/server/modules/**/*.entity.js', 'dist/apps/server/shared/domain/entity/*.entity.js'],
// entitiesTs: ['apps/server/src/modules/**/*.entity.ts', 'apps/server/src/shared/domain/entity/*.entity.ts'],
// extensions: [Migrator, EntityGenerator],
allowGlobalContext: true,
/*
findOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) =>
Expand Down
112 changes: 112 additions & 0 deletions apps/server/src/config/mikro-orm-cli.entity.imports.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// TODO: Rename file it is only used for migrations
import { AccountEntity } from '@modules/account/domain/entity/account.entity';
import { BoardNodeEntity } from '@modules/board/repo/entity';
import { ClassEntity } from '@modules/class/entity';
import { DeletionLogEntity } from '@modules/deletion/repo/entity/deletion-log.entity';
import { DeletionRequestEntity } from '@modules/deletion/repo/entity/deletion-request.entity';
import { GroupEntity } from '@modules/group/entity';
import { InstanceEntity } from '@modules/instance';
import { SchoolSystemOptionsEntity } from '@modules/legacy-school/entity';
import { MediaSourceEntity } from '@modules/media-source/entity';
import { OauthSessionTokenEntity } from '@modules/oauth/entity';
import { ExternalToolPseudonymEntity, PseudonymEntity } from '@modules/pseudonym/entity';
import { RegistrationPinEntity } from '@modules/registration-pin/entity';
import { RocketChatUserEntity } from '@modules/rocketchat-user/entity';
import { RoomMembershipEntity } from '@modules/room-membership/repo/entity/room-membership.entity';
import { RoomEntity } from '@modules/room/repo/entity';
import { MediaSchoolLicenseEntity, SchoolLicenseEntity } from '@modules/school-license/entity';
import { ShareToken } from '@modules/sharing/entity/share-token.entity';
import { SystemEntity } from '@modules/system/entity/system.entity';
import { ContextExternalToolEntity, LtiDeepLinkTokenEntity } from '@modules/tool/context-external-tool/entity';
import { ExternalToolEntity } from '@modules/tool/external-tool/entity';
import { SchoolExternalToolEntity } from '@modules/tool/school-external-tool/entity';
import { ImportUser } from '@modules/user-import/entity';
import { MediaUserLicenseEntity, UserLicenseEntity } from '@modules/user-license/entity';
import { ColumnBoardNode } from '@shared/domain/entity/column-board-node.entity';
import { Course } from '@shared/domain/entity/course.entity';
import { CourseGroup } from '@shared/domain/entity/coursegroup.entity';
import { DashboardGridElementModel, DashboardModelEntity } from '@shared/domain/entity/dashboard.model.entity';
import { CountyEmbeddable, FederalStateEntity } from '@shared/domain/entity/federal-state.entity';
import {
ColumnboardBoardElement,
LegacyBoard,
LegacyBoardElement,
LessonBoardElement,
TaskBoardElement,
} from '@shared/domain/entity/legacy-board';
import { LessonEntity } from '@shared/domain/entity/lesson.entity';
import { LtiTool } from '@shared/domain/entity/ltitool.entity';
import { Material } from '@shared/domain/entity/materials.entity';
import { CourseNews, News, SchoolNews, TeamNews } from '@shared/domain/entity/news.entity';
import { Role } from '@shared/domain/entity/role.entity';
import { SchoolEntity, SchoolRolePermission, SchoolRoles } from '@shared/domain/entity/school.entity';
import { SchoolYearEntity } from '@shared/domain/entity/schoolyear.entity';
import { StorageProviderEntity } from '@shared/domain/entity/storageprovider.entity';
import { Submission } from '@shared/domain/entity/submission.entity';
import { Task } from '@shared/domain/entity/task.entity';
import { TeamEntity, TeamUserEntity } from '@shared/domain/entity/team.entity';
import { UserLoginMigrationEntity } from '@shared/domain/entity/user-login-migration.entity';
import { User } from '@shared/domain/entity/user.entity';
import { VideoConference } from '@shared/domain/entity/video-conference.entity';

export const ENTITIES = [
AccountEntity,
LegacyBoard,
LegacyBoardElement,
BoardNodeEntity,
ColumnboardBoardElement,
ColumnBoardNode,
ClassEntity,
DeletionRequestEntity,
DeletionLogEntity,
ContextExternalToolEntity,
CountyEmbeddable,
Course,
CourseGroup,
CourseNews,
DashboardGridElementModel,
DashboardModelEntity,
ExternalToolEntity,
FederalStateEntity,
ImportUser,
LessonEntity,
LessonBoardElement,
LtiTool,
Material,
News,
PseudonymEntity,
ExternalToolPseudonymEntity,
RocketChatUserEntity,
Role,
RoomEntity,
RoomMembershipEntity,
SchoolEntity,
SchoolExternalToolEntity,
SchoolNews,
SchoolRolePermission,
SchoolRoles,
SchoolSystemOptionsEntity,
SchoolYearEntity,
ShareToken,
StorageProviderEntity,
Submission,
SystemEntity,
Task,
TaskBoardElement,
TeamEntity,
TeamNews,
TeamUserEntity,
User,
UserLoginMigrationEntity,
VideoConference,
GroupEntity,
RegistrationPinEntity,
UserLicenseEntity,
MediaUserLicenseEntity,
InstanceEntity,
MediaSourceEntity,
SchoolLicenseEntity,
MediaSchoolLicenseEntity,
OauthSessionTokenEntity,
LtiDeepLinkTokenEntity,
];
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
import { MikroORM } from '@mikro-orm/core';
import { MikroOrmModule, MikroOrmModuleAsyncOptions } from '@mikro-orm/nestjs';
import { DynamicModule, Inject, Module, OnModuleDestroy } from '@nestjs/common';
import { ALL_ENTITIES } from '@shared/domain/entity';
import _ from 'lodash';

import { defineConfig } from '@mikro-orm/mongodb';
// Will be removed by https://ticketsystem.dbildungscloud.de/browse/BC-8880
import { TEST_ENTITIES } from '@modules/server/server.entity.imports';
import { MongoDatabaseModuleOptions } from './types';

const dbName = () => _.times(20, () => _.random(35).toString(36)).join('');
const dbName = (): string => _.times(20, () => _.random(35).toString(36)).join('');

const createMikroOrmModule = (options: MikroOrmModuleAsyncOptions): DynamicModule => {
const mikroOrmModule = MikroOrmModule.forRootAsync({
useFactory: () => {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions, no-process-env
const clientUrl = `${process.env.MONGO_TEST_URI}/${dbName()}`;
return {
return defineConfig({
allowGlobalContext: true, // can be overridden by options
...options,
type: 'mongo',
clientUrl,
};
});
},
});

Expand All @@ -28,9 +31,9 @@ const createMikroOrmModule = (options: MikroOrmModuleAsyncOptions): DynamicModul
export class MongoMemoryDatabaseModule implements OnModuleDestroy {
constructor(@Inject(MikroORM) private orm: MikroORM) {}

static forRoot(options?: MongoDatabaseModuleOptions): DynamicModule {
public static forRoot(options?: MongoDatabaseModuleOptions): DynamicModule {
const defaultOptions = {
entities: ALL_ENTITIES,
entities: TEST_ENTITIES,
};
return {
module: MongoMemoryDatabaseModule,
Expand All @@ -39,7 +42,7 @@ export class MongoMemoryDatabaseModule implements OnModuleDestroy {
};
}

async onModuleDestroy(): Promise<void> {
public async onModuleDestroy(): Promise<void> {
await this.orm.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { KeycloakAdministrationService } from '../../keycloak-administration/ser

@Injectable()
export class KeycloakIdentityManagementService extends IdentityManagementService {
public constructor(private readonly kcAdminClient: KeycloakAdministrationService) {
constructor(private readonly kcAdminClient: KeycloakAdministrationService) {
super();
}

async createAccount(account: IdmAccount, password?: string): Promise<string> {
public async createAccount(account: IdmAccount, password?: string): Promise<string> {
const kc = await this.kcAdminClient.callKcAdminClient();
const id = await kc.users.create({
username: account.username,
Expand Down Expand Up @@ -44,7 +44,7 @@ export class KeycloakIdentityManagementService extends IdentityManagementService
return id.id;
}

async updateAccount(id: string, account: IdmAccountUpdate): Promise<string> {
public async updateAccount(id: string, account: IdmAccountUpdate): Promise<string> {
await (
await this.kcAdminClient.callKcAdminClient()
).users.update(
Expand All @@ -60,7 +60,7 @@ export class KeycloakIdentityManagementService extends IdentityManagementService
return id;
}

async updateAccountPassword(id: string, password: string): Promise<string> {
public async updateAccountPassword(id: string, password: string): Promise<string> {
await (
await this.kcAdminClient.callKcAdminClient()
).users.resetPassword({
Expand All @@ -74,15 +74,15 @@ export class KeycloakIdentityManagementService extends IdentityManagementService
return id;
}

async findAccountById(id: string): Promise<IdmAccount> {
public async findAccountById(id: string): Promise<IdmAccount> {
const keycloakUser = await (await this.kcAdminClient.callKcAdminClient()).users.findOne({ id });
if (!keycloakUser) {
throw new Error(`Account '${id}' not found`);
}
return this.extractAccount(keycloakUser);
}

async findAccountByDbcAccountId(accountDbcAccountId: string): Promise<IdmAccount> {
public async findAccountByDbcAccountId(accountDbcAccountId: string): Promise<IdmAccount> {
const keycloakUsers = await (
await this.kcAdminClient.callKcAdminClient()
).users.find({ q: `dbcAccountId:${accountDbcAccountId} }` });
Expand All @@ -96,7 +96,7 @@ export class KeycloakIdentityManagementService extends IdentityManagementService
return this.extractAccount(keycloakUsers[0]);
}

async findAccountByDbcUserId(accountDbcUserId: string): Promise<IdmAccount> {
public async findAccountByDbcUserId(accountDbcUserId: string): Promise<IdmAccount> {
const keycloakUsers = await (
await this.kcAdminClient.callKcAdminClient()
).users.find({ q: `dbcUserId:${accountDbcUserId} }` });
Expand All @@ -111,7 +111,7 @@ export class KeycloakIdentityManagementService extends IdentityManagementService
return this.extractAccount(keycloakUsers[0]);
}

async findAccountsByUsername(username: string, options?: SearchOptions): Promise<Counted<IdmAccount[]>> {
public async findAccountsByUsername(username: string, options?: SearchOptions): Promise<Counted<IdmAccount[]>> {
const kc = await this.kcAdminClient.callKcAdminClient();
const total = await kc.users.count({ username });
const results = await kc.users.find({
Expand All @@ -124,17 +124,17 @@ export class KeycloakIdentityManagementService extends IdentityManagementService
return [accounts, total];
}

async getAllAccounts(): Promise<IdmAccount[]> {
public async getAllAccounts(): Promise<IdmAccount[]> {
const keycloakUsers = await (await this.kcAdminClient.callKcAdminClient()).users.find();
return keycloakUsers.map((user: UserRepresentation) => this.extractAccount(user));
}

async deleteAccountById(id: string): Promise<string> {
public async deleteAccountById(id: string): Promise<string> {
await (await this.kcAdminClient.callKcAdminClient()).users.del({ id });
return id;
}

async getUserAttribute<TValue extends boolean | number | string | unknown = unknown>(
public async getUserAttribute<TValue extends boolean | number | string | unknown = unknown>(
userId: string,
attributeName: string
): Promise<TValue | null> {
Expand All @@ -150,7 +150,7 @@ export class KeycloakIdentityManagementService extends IdentityManagementService
return null;
}

async setUserAttribute<TValue extends boolean | number | string>(
public async setUserAttribute<TValue extends boolean | number | string>(
userId: string,
attributeName: string,
attributeValue: TValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('CurrentUserMapper', () => {
accountId,
systemId: undefined,
roles: [teacherRole.id],
schoolId: null,
schoolId: user.school.id,
isExternalUser: false,
});
});
Expand All @@ -70,7 +70,7 @@ describe('CurrentUserMapper', () => {
accountId,
systemId: undefined,
roles: [],
schoolId: null,
schoolId: user.school.id,
isExternalUser: true,
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { createConfigModuleOptions } from '@shared/common/config-module-options';
import { defaultMikroOrmOptions } from '@shared/common/defaultMikroOrmOptions';
import { ALL_ENTITIES } from '@shared/domain/entity/all-entities';
import { AuthorizationModule } from '../authorization';
import { serverConfig } from '../server';
import { config } from './board-collaboration.config';
import { BoardWsApiModule } from './board-ws-api.module';
import { ENTITIES, TEST_ENTITIES } from './board.entity.imports';
import { BoardModule } from './board.module';

const imports = [
Expand All @@ -34,7 +34,7 @@ const imports = [
clientUrl: DB_URL, // TODO: check if this needs to be different
password: DB_PASSWORD,
user: DB_USERNAME,
entities: ALL_ENTITIES,
entities: ENTITIES,
}),
],
providers: [],
Expand All @@ -52,7 +52,7 @@ const testConfig = () => {
ConfigModule.forRoot(createConfigModuleOptions(testConfig)),
MongoMemoryDatabaseModule.forRoot({
...defaultMikroOrmOptions,
entities: ALL_ENTITIES,
entities: TEST_ENTITIES,
}),
],
})
Expand Down
Loading
Loading