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-4964 Rename and update stuff in school module #4388

Merged
merged 40 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
c90c196
Rename SchoolService
dyedwiper Aug 30, 2023
a84a9eb
Rename school service files
dyedwiper Aug 30, 2023
f7a0e96
Rename SchoolUc
dyedwiper Aug 30, 2023
d8dc1c1
Rename school uc files
dyedwiper Aug 30, 2023
85040e7
Rename SchoolRepo
dyedwiper Aug 30, 2023
8afc7b1
Rename school repo files
dyedwiper Aug 30, 2023
cc76a0b
Rename SchoolDO
dyedwiper Aug 30, 2023
577c597
Rename school do file
dyedwiper Aug 30, 2023
366d10a
Add deprecation markers
dyedwiper Aug 30, 2023
de82018
Fix imports in tests
dyedwiper Aug 30, 2023
7fe3f85
Update and rename SchoolRule
dyedwiper Aug 31, 2023
66d3a66
Rename school rule files
dyedwiper Aug 31, 2023
ef6884d
Merge branch 'main' into bc-4964-rename-school-stuff
dyedwiper Aug 31, 2023
0e9f23c
Rename schoolDOFactory
dyedwiper Aug 31, 2023
ab8e8e2
Rename school factory file
dyedwiper Aug 31, 2023
330ca33
Merge branch 'main' into bc-4964-rename-school-stuff
dyedwiper Sep 1, 2023
e0a7c2d
Merge branch 'main' into bc-4964-rename-school-stuff
dyedwiper Sep 1, 2023
162f73c
Rename parameter
dyedwiper Sep 1, 2023
7113e21
Merge branch 'main' into bc-4964-rename-school-stuff
dyedwiper Sep 1, 2023
9a4a0e3
Merge branch 'bc-4964-rename-school-stuff' of github.com:hpi-schul-cl…
dyedwiper Sep 1, 2023
7018f89
Merge branch 'bc-4964-rename-school-stuff' into bc-4964-rename-school…
dyedwiper Sep 5, 2023
8b9d35f
Rename school module folder
dyedwiper Sep 5, 2023
2990193
Rename school module
dyedwiper Sep 5, 2023
1948de2
Rename school module file
dyedwiper Sep 5, 2023
f09fea2
Rename SchoolApiModule
dyedwiper Sep 5, 2023
6fa4563
Rename SchoolApiModule file
dyedwiper Sep 5, 2023
3cb3505
Merge branch 'main' into bc-4964-rename-school-stuff-v2
dyedwiper Sep 5, 2023
e142a83
Merge branch 'main' into bc-4964-rename-school-stuff-v2
SevenWaysDP Sep 11, 2023
5d10a41
Rename module
dyedwiper Sep 18, 2023
aa2cdc6
Rename module file
dyedwiper Sep 18, 2023
05b4c92
Rename api module
dyedwiper Sep 18, 2023
6088d61
Rename api module file
dyedwiper Sep 18, 2023
be06e53
Rename folder
dyedwiper Sep 18, 2023
273c3d1
Add deprecation markers
dyedwiper Sep 18, 2023
ff06db0
Rename controller
dyedwiper Sep 18, 2023
e01580c
Rename controller file
dyedwiper Sep 18, 2023
35bfd65
Rename controller test file
dyedwiper Sep 18, 2023
b8c7dd7
Merge branch 'main' into bc-4964-rename-school-stuff-v2
dyedwiper Sep 18, 2023
6a7af38
Merge branch 'main' into bc-4964-rename-school-stuff-v2
dyedwiper Sep 19, 2023
df224de
Merge branch 'main' into bc-4964-rename-school-stuff-v2
dyedwiper Sep 20, 2023
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 @@ -3,7 +3,7 @@ import { JwtModule, JwtModuleOptions } from '@nestjs/jwt';
import { PassportModule } from '@nestjs/passport';
import { CacheWrapperModule } from '@shared/infra/cache';
import { IdentityManagementModule } from '@shared/infra/identity-management';
import { SchoolRepo, SystemRepo, UserRepo } from '@shared/repo';
import { LegacySchoolRepo, SystemRepo, UserRepo } from '@shared/repo';
import { LoggerModule } from '@src/core/logger';
import { AccountModule } from '@src/modules/account';
import { OauthModule } from '@src/modules/oauth/oauth.module';
Expand Down Expand Up @@ -70,7 +70,7 @@ const jwtModuleOptions: JwtModuleOptions = {
JwtValidationAdapter,
UserRepo,
SystemRepo,
SchoolRepo,
LegacySchoolRepo,
LocalStrategy,
AuthenticationService,
LdapService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest';
import { UnauthorizedException } from '@nestjs/common';
import { PassportModule } from '@nestjs/passport';
import { Test, TestingModule } from '@nestjs/testing';
import { RoleName, System, User } from '@shared/domain';
import { SchoolDO } from '@shared/domain/domainobject/school.do';
import { SchoolRepo, SystemRepo, UserRepo } from '@shared/repo';
import { LegacySchoolDo, RoleName, System, User } from '@shared/domain';
import { LegacySchoolRepo, SystemRepo, UserRepo } from '@shared/repo';
import {
accountDtoFactory,
defaultTestPassword,
defaultTestPasswordHash,
schoolDOFactory,
legacySchoolDoFactory,
schoolFactory,
setupEntities,
systemFactory,
Expand All @@ -28,7 +27,7 @@ describe('LdapStrategy', () => {
let strategy: LdapStrategy;

let userRepoMock: DeepMocked<UserRepo>;
let schoolRepoMock: DeepMocked<SchoolRepo>;
let schoolRepoMock: DeepMocked<LegacySchoolRepo>;
let authenticationServiceMock: DeepMocked<AuthenticationService>;
let ldapServiceMock: DeepMocked<LdapService>;
let systemRepo: DeepMocked<SystemRepo>;
Expand All @@ -53,8 +52,8 @@ describe('LdapStrategy', () => {
useValue: createMock<UserRepo>(),
},
{
provide: SchoolRepo,
useValue: createMock<SchoolRepo>(),
provide: LegacySchoolRepo,
useValue: createMock<LegacySchoolRepo>(),
},
{
provide: SystemRepo,
Expand All @@ -69,7 +68,7 @@ describe('LdapStrategy', () => {

strategy = module.get(LdapStrategy);
authenticationServiceMock = module.get(AuthenticationService);
schoolRepoMock = module.get(SchoolRepo);
schoolRepoMock = module.get(LegacySchoolRepo);
userRepoMock = module.get(UserRepo);
ldapServiceMock = module.get(LdapService);
systemRepo = module.get(SystemRepo);
Expand All @@ -92,7 +91,7 @@ describe('LdapStrategy', () => {

const user: User = userFactory.withRoleByName(RoleName.STUDENT).buildWithId({ ldapDn: undefined });

const school: SchoolDO = schoolDOFactory.buildWithId({ systems: [system.id] }, user.school.id);
const school: LegacySchoolDo = legacySchoolDoFactory.buildWithId({ systems: [system.id] }, user.school.id);

const account: AccountDto = accountDtoFactory.build({
systemId: system.id,
Expand Down Expand Up @@ -139,7 +138,7 @@ describe('LdapStrategy', () => {

const user: User = userFactory.withRoleByName(RoleName.STUDENT).buildWithId({ ldapDn: 'mockLdapDn' });

const school: SchoolDO = schoolDOFactory.buildWithId({ systems: [] }, user.school.id);
const school: LegacySchoolDo = legacySchoolDoFactory.buildWithId({ systems: [] }, user.school.id);

const account: AccountDto = accountDtoFactory.build({
systemId: system.id,
Expand Down Expand Up @@ -186,7 +185,7 @@ describe('LdapStrategy', () => {

const user: User = userFactory.withRoleByName(RoleName.STUDENT).buildWithId({ ldapDn: 'mockLdapDn' });

const school: SchoolDO = schoolDOFactory.buildWithId({ systems: undefined }, user.school.id);
const school: LegacySchoolDo = legacySchoolDoFactory.buildWithId({ systems: undefined }, user.school.id);

const account: AccountDto = accountDtoFactory.build({
systemId: system.id,
Expand Down Expand Up @@ -233,7 +232,7 @@ describe('LdapStrategy', () => {

const user: User = userFactory.withRoleByName(RoleName.STUDENT).buildWithId({ ldapDn: 'mockLdapDn' });

const school: SchoolDO = schoolDOFactory.buildWithId({ systems: [system.id] }, user.school.id);
const school: LegacySchoolDo = legacySchoolDoFactory.buildWithId({ systems: [system.id] }, user.school.id);

const account: AccountDto = accountDtoFactory.build({
systemId: system.id,
Expand Down Expand Up @@ -280,7 +279,7 @@ describe('LdapStrategy', () => {

const user: User = userFactory.withRoleByName(RoleName.STUDENT).buildWithId({ ldapDn: 'mockLdapDn' });

const school: SchoolDO = schoolDOFactory.buildWithId({ systems: [system.id] }, user.school.id);
const school: LegacySchoolDo = legacySchoolDoFactory.buildWithId({ systems: [system.id] }, user.school.id);

const account: AccountDto = accountDtoFactory.build({
systemId: system.id,
Expand Down Expand Up @@ -332,7 +331,7 @@ describe('LdapStrategy', () => {

const user: User = userFactory.withRoleByName(RoleName.STUDENT).buildWithId({ ldapDn: 'mockLdapDn' });

const school: SchoolDO = schoolDOFactory.buildWithId({ systems: [system.id] }, user.school.id);
const school: LegacySchoolDo = legacySchoolDoFactory.buildWithId({ systems: [system.id] }, user.school.id);

const account: AccountDto = accountDtoFactory.build({
systemId: system.id,
Expand Down Expand Up @@ -389,7 +388,7 @@ describe('LdapStrategy', () => {
.withRoleByName(RoleName.STUDENT)
.buildWithId({ ldapDn: 'mockLdapDn', school: schoolFactory.buildWithId() });

const school: SchoolDO = schoolDOFactory.buildWithId(
const school: LegacySchoolDo = legacySchoolDoFactory.buildWithId(
{ systems: [system.id], previousExternalId: undefined },
user.school.id
);
Expand Down Expand Up @@ -451,7 +450,7 @@ describe('LdapStrategy', () => {
.withRoleByName(RoleName.STUDENT)
.buildWithId({ ldapDn: 'mockLdapDn', school: schoolFactory.buildWithId() });

const school: SchoolDO = schoolDOFactory.buildWithId(
const school: LegacySchoolDo = legacySchoolDoFactory.buildWithId(
{ systems: [system.id], previousExternalId: 'previousExternalId' },
user.school.id
);
Expand Down
11 changes: 5 additions & 6 deletions apps/server/src/modules/authentication/strategy/ldap.strategy.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Injectable, UnauthorizedException } from '@nestjs/common';
import { PassportStrategy } from '@nestjs/passport';
import { System, User } from '@shared/domain';
import { SchoolDO } from '@shared/domain/domainobject/school.do';
import { SchoolRepo, SystemRepo, UserRepo } from '@shared/repo';
import { LegacySchoolDo, System, User } from '@shared/domain';
import { LegacySchoolRepo, SystemRepo, UserRepo } from '@shared/repo';
import { ErrorLoggable } from '@src/core/error/loggable/error.loggable';
import { Logger } from '@src/core/logger';
import { AccountDto } from '@src/modules/account/services/dto';
Expand All @@ -17,7 +16,7 @@ import { LdapService } from '../services/ldap.service';
export class LdapStrategy extends PassportStrategy(Strategy, 'ldap') {
constructor(
private readonly systemRepo: SystemRepo,
private readonly schoolRepo: SchoolRepo,
private readonly schoolRepo: LegacySchoolRepo,
private readonly ldapService: LdapService,
private readonly authenticationService: AuthenticationService,
private readonly userRepo: UserRepo,
Expand All @@ -31,7 +30,7 @@ export class LdapStrategy extends PassportStrategy(Strategy, 'ldap') {

const system: System = await this.systemRepo.findById(systemId);

const school: SchoolDO = await this.schoolRepo.findById(schoolId);
const school: LegacySchoolDo = await this.schoolRepo.findById(schoolId);

if (!school.systems || !school.systems.includes(systemId)) {
throw new UnauthorizedException(`School ${schoolId} does not have the selected system ${systemId}`);
Expand Down Expand Up @@ -84,7 +83,7 @@ export class LdapStrategy extends PassportStrategy(Strategy, 'ldap') {
}
}

private async loadAccount(username: string, systemId: string, school: SchoolDO): Promise<AccountDto> {
private async loadAccount(username: string, systemId: string, school: LegacySchoolDo): Promise<AccountDto> {
const externalSchoolId = this.checkValue(school.externalId);

let account: AccountDto;
Expand Down
14 changes: 10 additions & 4 deletions apps/server/src/modules/authorization/authorization.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import {
CourseRepo,
LessonRepo,
SchoolExternalToolRepo,
SchoolRepo,
LegacySchoolRepo,
SubmissionRepo,
TaskRepo,
TeamsRepo,
UserRepo,
} from '@shared/repo';
import { LoggerModule } from '@src/core/logger';
import { SchoolModule } from '@src/modules/school';
import { LegacySchoolModule } from '@src/modules/legacy-school';
import { ToolModule } from '@src/modules/tool';
import { BoardModule } from '../board';
import { AuthorizationHelper } from './authorization.helper';
Expand All @@ -24,7 +24,13 @@ import { RuleManager } from './rule-manager';

@Module({
// TODO: remove forwardRef to TooModule N21-1055
imports: [FeathersModule, LoggerModule, SchoolModule, forwardRef(() => ToolModule), forwardRef(() => BoardModule)],
imports: [
FeathersModule,
LoggerModule,
LegacySchoolModule,
forwardRef(() => ToolModule),
forwardRef(() => BoardModule),
],
providers: [
FeathersAuthorizationService,
FeathersAuthProvider,
Expand All @@ -35,7 +41,7 @@ import { RuleManager } from './rule-manager';
CourseRepo,
CourseGroupRepo,
TaskRepo,
SchoolRepo,
LegacySchoolRepo,
LessonRepo,
TeamsRepo,
SubmissionRepo,
Expand Down
10 changes: 5 additions & 5 deletions apps/server/src/modules/authorization/reference.loader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
CourseRepo,
LessonRepo,
SchoolExternalToolRepo,
SchoolRepo,
LegacySchoolRepo,
SubmissionRepo,
TaskRepo,
TeamsRepo,
Expand All @@ -26,7 +26,7 @@ describe('reference.loader', () => {
let courseRepo: DeepMocked<CourseRepo>;
let courseGroupRepo: DeepMocked<CourseGroupRepo>;
let taskRepo: DeepMocked<TaskRepo>;
let schoolRepo: DeepMocked<SchoolRepo>;
let schoolRepo: DeepMocked<LegacySchoolRepo>;
let lessonRepo: DeepMocked<LessonRepo>;
let teamsRepo: DeepMocked<TeamsRepo>;
let submissionRepo: DeepMocked<SubmissionRepo>;
Expand Down Expand Up @@ -58,8 +58,8 @@ describe('reference.loader', () => {
useValue: createMock<TaskRepo>(),
},
{
provide: SchoolRepo,
useValue: createMock<SchoolRepo>(),
provide: LegacySchoolRepo,
useValue: createMock<LegacySchoolRepo>(),
},
{
provide: LessonRepo,
Expand Down Expand Up @@ -93,7 +93,7 @@ describe('reference.loader', () => {
courseRepo = await module.get(CourseRepo);
courseGroupRepo = await module.get(CourseGroupRepo);
taskRepo = await module.get(TaskRepo);
schoolRepo = await module.get(SchoolRepo);
schoolRepo = await module.get(LegacySchoolRepo);
lessonRepo = await module.get(LessonRepo);
teamsRepo = await module.get(TeamsRepo);
submissionRepo = await module.get(SubmissionRepo);
Expand Down
6 changes: 3 additions & 3 deletions apps/server/src/modules/authorization/reference.loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
CourseRepo,
LessonRepo,
SchoolExternalToolRepo,
SchoolRepo,
LegacySchoolRepo,
SubmissionRepo,
TaskRepo,
TeamsRepo,
Expand All @@ -21,7 +21,7 @@ type RepoType =
| TaskRepo
| CourseRepo
| UserRepo
| SchoolRepo
| LegacySchoolRepo
| LessonRepo
| TeamsRepo
| CourseGroupRepo
Expand All @@ -44,7 +44,7 @@ export class ReferenceLoader {
private readonly courseRepo: CourseRepo,
private readonly courseGroupRepo: CourseGroupRepo,
private readonly taskRepo: TaskRepo,
private readonly schoolRepo: SchoolRepo,
private readonly schoolRepo: LegacySchoolRepo,
private readonly lessonRepo: LessonRepo,
private readonly teamsRepo: TeamsRepo,
private readonly submissionRepo: SubmissionRepo,
Expand Down
16 changes: 8 additions & 8 deletions apps/server/src/modules/authorization/rule-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
CourseRule,
LessonRule,
SchoolExternalToolRule,
SchoolRule,
LegacySchoolRule,
SubmissionRule,
TaskRule,
TeamRule,
Expand All @@ -24,7 +24,7 @@ describe('RuleManager', () => {
let courseRule: DeepMocked<CourseRule>;
let courseGroupRule: DeepMocked<CourseGroupRule>;
let lessonRule: DeepMocked<LessonRule>;
let schoolRule: DeepMocked<SchoolRule>;
let legacySchoolRule: DeepMocked<LegacySchoolRule>;
let userRule: DeepMocked<UserRule>;
let taskRule: DeepMocked<TaskRule>;
let teamRule: DeepMocked<TeamRule>;
Expand All @@ -43,7 +43,7 @@ describe('RuleManager', () => {
{ provide: CourseRule, useValue: createMock<CourseRule>() },
{ provide: CourseGroupRule, useValue: createMock<CourseGroupRule>() },
{ provide: LessonRule, useValue: createMock<LessonRule>() },
{ provide: SchoolRule, useValue: createMock<SchoolRule>() },
{ provide: LegacySchoolRule, useValue: createMock<LegacySchoolRule>() },
{ provide: UserRule, useValue: createMock<UserRule>() },
{ provide: TaskRule, useValue: createMock<TaskRule>() },
{ provide: TeamRule, useValue: createMock<TeamRule>() },
Expand All @@ -59,7 +59,7 @@ describe('RuleManager', () => {
courseRule = await module.get(CourseRule);
courseGroupRule = await module.get(CourseGroupRule);
lessonRule = await module.get(LessonRule);
schoolRule = await module.get(SchoolRule);
legacySchoolRule = await module.get(LegacySchoolRule);
userRule = await module.get(UserRule);
taskRule = await module.get(TaskRule);
teamRule = await module.get(TeamRule);
Expand Down Expand Up @@ -89,7 +89,7 @@ describe('RuleManager', () => {
courseRule.isApplicable.mockReturnValueOnce(true);
courseGroupRule.isApplicable.mockReturnValueOnce(false);
lessonRule.isApplicable.mockReturnValueOnce(false);
schoolRule.isApplicable.mockReturnValueOnce(false);
legacySchoolRule.isApplicable.mockReturnValueOnce(false);
userRule.isApplicable.mockReturnValueOnce(false);
taskRule.isApplicable.mockReturnValueOnce(false);
teamRule.isApplicable.mockReturnValueOnce(false);
Expand All @@ -110,7 +110,7 @@ describe('RuleManager', () => {
expect(courseRule.isApplicable).toBeCalled();
expect(courseGroupRule.isApplicable).toBeCalled();
expect(lessonRule.isApplicable).toBeCalled();
expect(schoolRule.isApplicable).toBeCalled();
expect(legacySchoolRule.isApplicable).toBeCalled();
expect(userRule.isApplicable).toBeCalled();
expect(taskRule.isApplicable).toBeCalled();
expect(teamRule.isApplicable).toBeCalled();
Expand Down Expand Up @@ -139,7 +139,7 @@ describe('RuleManager', () => {
courseRule.isApplicable.mockReturnValueOnce(false);
courseGroupRule.isApplicable.mockReturnValueOnce(false);
lessonRule.isApplicable.mockReturnValueOnce(false);
schoolRule.isApplicable.mockReturnValueOnce(false);
legacySchoolRule.isApplicable.mockReturnValueOnce(false);
userRule.isApplicable.mockReturnValueOnce(false);
taskRule.isApplicable.mockReturnValueOnce(false);
teamRule.isApplicable.mockReturnValueOnce(false);
Expand Down Expand Up @@ -168,7 +168,7 @@ describe('RuleManager', () => {
courseRule.isApplicable.mockReturnValueOnce(true);
courseGroupRule.isApplicable.mockReturnValueOnce(true);
lessonRule.isApplicable.mockReturnValueOnce(false);
schoolRule.isApplicable.mockReturnValueOnce(false);
legacySchoolRule.isApplicable.mockReturnValueOnce(false);
userRule.isApplicable.mockReturnValueOnce(false);
taskRule.isApplicable.mockReturnValueOnce(false);
teamRule.isApplicable.mockReturnValueOnce(false);
Expand Down
6 changes: 3 additions & 3 deletions apps/server/src/modules/authorization/rule-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
CourseRule,
LessonRule,
SchoolExternalToolRule,
SchoolRule,
LegacySchoolRule,
SubmissionRule,
TaskRule,
TeamRule,
Expand All @@ -25,7 +25,7 @@ export class RuleManager {
private readonly courseRule: CourseRule,
private readonly courseGroupRule: CourseGroupRule,
private readonly lessonRule: LessonRule,
private readonly schoolRule: SchoolRule,
private readonly legaySchoolRule: LegacySchoolRule,
private readonly taskRule: TaskRule,
private readonly userRule: UserRule,
private readonly teamRule: TeamRule,
Expand All @@ -42,7 +42,7 @@ export class RuleManager {
this.taskRule,
this.teamRule,
this.userRule,
this.schoolRule,
this.legaySchoolRule,
this.submissionRule,
this.schoolExternalToolRule,
this.boardDoRule,
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/modules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export * from './oauth-provider';
export * from './provisioning';
export * from './rocketchat';
export * from './role';
export * from './school';
export * from './legacy-school';
export * from './sharing';
export * from './system';
export * from './task';
Expand Down
Loading
Loading