Skip to content

Commit

Permalink
move rules folder one level up
Browse files Browse the repository at this point in the history
  • Loading branch information
CeEv committed Oct 12, 2023
1 parent 88a8237 commit 97d9460
Show file tree
Hide file tree
Showing 29 changed files with 53 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
UserRule,
UserLoginMigrationRule,
LegacySchoolRule,
} from './domain/service/rules';
} from './domain/rules';
import { AuthorizationHelper, AuthorizationService, RuleManager } from './domain';
import { FeathersAuthorizationService, FeathersAuthProvider } from './feathers';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { roleFactory, setupEntities, userFactory } from '@shared/testing';
import { ObjectId } from 'bson';
import { BoardDoAuthorizable, BoardRoles, UserRoleEnum } from '@shared/domain/domainobject';
import { Permission } from '@shared/domain/interface';
import { Action } from '../../type';
import { AuthorizationHelper } from '../authorization.helper';
import { Action } from '../type';
import { AuthorizationHelper } from '../service/authorization.helper';
import { BoardDoRule } from './board-do.rule';

describe(BoardDoRule.name, () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Injectable } from '@nestjs/common';
import { BoardDoAuthorizable, BoardRoles } from '@shared/domain/domainobject';
import { User } from '@shared/domain/entity';
import { Action, AuthorizationContext, Rule } from '../../type';
import { AuthorizationHelper } from '../authorization.helper';
import { Action, AuthorizationContext, Rule } from '../type';
import { AuthorizationHelper } from '../service/authorization.helper';

@Injectable()
export class BoardDoRule implements Rule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { SchoolExternalToolEntity } from '@src/modules/tool/school-external-tool
import { Role, User } from '@shared/domain/entity';
import { Permission } from '@shared/domain/interface';
import { ContextExternalToolRule } from './context-external-tool.rule';
import { Action } from '../../type';
import { AuthorizationHelper } from '../authorization.helper';
import { Action } from '../type';
import { AuthorizationHelper } from '../service/authorization.helper';

describe('ContextExternalToolRule', () => {
let service: ContextExternalToolRule;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Injectable } from '@nestjs/common';
import { ContextExternalTool } from '@src/modules/tool/context-external-tool/domain';
import { ContextExternalToolEntity } from '@src/modules/tool/context-external-tool/entity';
import { User } from '@shared/domain/entity';
import { AuthorizationContext, Rule } from '../../type';
import { AuthorizationHelper } from '../authorization.helper';
import { AuthorizationContext, Rule } from '../type';
import { AuthorizationHelper } from '../service/authorization.helper';

@Injectable()
export class ContextExternalToolRule implements Rule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Permission } from '@shared/domain/interface';
import { courseFactory, courseGroupFactory, roleFactory, setupEntities, userFactory } from '@shared/testing';
import { CourseGroupRule } from './course-group.rule';
import { CourseRule } from './course.rule';
import { Action } from '../../type';
import { AuthorizationHelper } from '../authorization.helper';
import { Action } from '../type';
import { AuthorizationHelper } from '../service/authorization.helper';

describe('CourseGroupRule', () => {
let service: CourseGroupRule;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Injectable } from '@nestjs/common';
import { CourseGroup, User } from '@shared/domain/entity';
import { CourseRule } from './course.rule';
import { Action, AuthorizationContext, Rule } from '../../type';
import { AuthorizationHelper } from '../authorization.helper';
import { Action, AuthorizationContext, Rule } from '../type';
import { AuthorizationHelper } from '../service/authorization.helper';

@Injectable()
export class CourseGroupRule implements Rule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Course, User } from '@shared/domain/entity';
import { Permission } from '@shared/domain/interface';
import { courseFactory, roleFactory, setupEntities, userFactory } from '@shared/testing';
import { CourseRule } from './course.rule';
import { Action } from '../../type';
import { AuthorizationHelper } from '../authorization.helper';
import { Action } from '../type';
import { AuthorizationHelper } from '../service/authorization.helper';

describe('CourseRule', () => {
let service: CourseRule;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
import { Course, User } from '@shared/domain/entity';
import { Action, AuthorizationContext, Rule } from '../../type';
import { AuthorizationHelper } from '../authorization.helper';
import { Action, AuthorizationContext, Rule } from '../type';
import { AuthorizationHelper } from '../service/authorization.helper';

@Injectable()
export class CourseRule implements Rule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Test, TestingModule } from '@nestjs/testing';
import { Permission } from '@shared/domain/interface';
import { roleFactory, legacySchoolDoFactory, setupEntities, userFactory } from '@shared/testing';
import { ObjectID } from 'bson';
import { Action } from '../../type';
import { AuthorizationHelper } from '../authorization.helper';
import { Action } from '../type';
import { AuthorizationHelper } from '../service/authorization.helper';
import { LegacySchoolRule } from './legacy-school.rule';

describe('LegacySchoolRule', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Injectable } from '@nestjs/common';
import { BaseDO, LegacySchoolDo } from '@shared/domain';
import { User } from '@shared/domain/entity';
import { AuthorizableObject } from '@shared/domain/domain-object';
import { AuthorizationContext, Rule } from '../../type';
import { AuthorizationHelper } from '../authorization.helper';
import { AuthorizationContext, Rule } from '../type';
import { AuthorizationHelper } from '../service/authorization.helper';

/**
* @deprecated because it uses the deprecated LegacySchoolDo.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
setupEntities,
userFactory,
} from '@shared/testing';
import { Action } from '../../type';
import { AuthorizationHelper } from '../authorization.helper';
import { Action } from '../type';
import { AuthorizationHelper } from '../service/authorization.helper';
import { CourseGroupRule } from './course-group.rule';
import { CourseRule } from './course.rule';
import { LessonRule } from './lesson.rule';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
import { Course, CourseGroup, LessonEntity, User } from '@shared/domain/entity';
import { Action, AuthorizationContext, Rule } from '../../type';
import { AuthorizationHelper } from '../authorization.helper';
import { Action, AuthorizationContext, Rule } from '../type';
import { AuthorizationHelper } from '../service/authorization.helper';
import { CourseGroupRule } from './course-group.rule';
import { CourseRule } from './course.rule';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
import { SchoolExternalTool } from '@src/modules/tool/school-external-tool/domain';
import { SchoolExternalToolEntity } from '@src/modules/tool/school-external-tool/entity';
import { Role, User, Permission } from '@shared/domain';
import { Action } from '../../type';
import { AuthorizationHelper } from '../authorization.helper';
import { Action } from '../type';
import { AuthorizationHelper } from '../service/authorization.helper';
import { SchoolExternalToolRule } from './school-external-tool.rule';

describe('SchoolExternalToolRule', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Injectable } from '@nestjs/common';
import { SchoolExternalTool } from '@src/modules/tool/school-external-tool/domain';
import { SchoolExternalToolEntity } from '@src/modules/tool/school-external-tool/entity';
import { User } from '@shared/domain/entity';
import { AuthorizationContext, Rule } from '../../type';
import { AuthorizationHelper } from '../authorization.helper';
import { AuthorizationContext, Rule } from '../type';
import { AuthorizationHelper } from '../service/authorization.helper';

@Injectable()
export class SchoolExternalToolRule implements Rule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
taskFactory,
userFactory,
} from '@shared/testing';
import { Action } from '../../type';
import { AuthorizationHelper } from '../authorization.helper';
import { Action } from '../type';
import { AuthorizationHelper } from '../service/authorization.helper';
import { SubmissionRule } from './submission.rule';
import { TaskRule } from './task.rule';
import { CourseRule } from './course.rule';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
import { Submission, User } from '@shared/domain/entity';
import { Action, AuthorizationContext, Rule } from '../../type';
import { AuthorizationHelper } from '../authorization.helper';
import { Action, AuthorizationContext, Rule } from '../type';
import { AuthorizationHelper } from '../service/authorization.helper';
import { TaskRule } from './task.rule';

@Injectable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { DeepPartial } from '@mikro-orm/core';
import { Test, TestingModule } from '@nestjs/testing';
import { Permission, RoleName } from '@shared/domain/interface';
import { courseFactory, lessonFactory, roleFactory, setupEntities, taskFactory, userFactory } from '@shared/testing';
import { Action } from '../../type';
import { AuthorizationHelper } from '../authorization.helper';
import { Action } from '../type';
import { AuthorizationHelper } from '../service/authorization.helper';
import { CourseGroupRule } from './course-group.rule';
import { TaskRule } from './task.rule';
import { CourseRule } from './course.rule';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
import { Task, User } from '@shared/domain/entity';
import { Action, AuthorizationContext, Rule } from '../../type';
import { AuthorizationHelper } from '../authorization.helper';
import { Action, AuthorizationContext, Rule } from '../type';
import { AuthorizationHelper } from '../service/authorization.helper';
import { CourseRule } from './course.rule';
import { LessonRule } from './lesson.rule';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Test, TestingModule } from '@nestjs/testing';
import { Permission } from '@shared/domain/interface';
import { roleFactory, setupEntities, userFactory, teamFactory } from '@shared/testing';
import { AuthorizationHelper } from '../authorization.helper';
import { AuthorizationHelper } from '../service/authorization.helper';
import { TeamRule } from './team.rule';
import { AuthorizationContextBuilder } from '../../mapper';
import { AuthorizationContextBuilder } from '../mapper';

describe('TeamRule', () => {
let rule: TeamRule;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
import { TeamEntity, TeamUserEntity, User } from '@shared/domain/entity';
import { AuthorizationContext, Rule } from '../../type';
import { AuthorizationHelper } from '../authorization.helper';
import { AuthorizationContext, Rule } from '../type';
import { AuthorizationHelper } from '../service/authorization.helper';

@Injectable()
export class TeamRule implements Rule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Test, TestingModule } from '@nestjs/testing';
import { schoolFactory, setupEntities, userFactory, userLoginMigrationDOFactory } from '@shared/testing';
import { UserLoginMigrationDO } from '@shared/domain/domainobject';
import { Permission } from '@shared/domain/interface';
import { Action, AuthorizationContext } from '../../type';
import { AuthorizationHelper } from '../authorization.helper';
import { Action, AuthorizationContext } from '../type';
import { AuthorizationHelper } from '../service/authorization.helper';
import { UserLoginMigrationRule } from './user-login-migration.rule';

describe('UserLoginMigrationRule', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Injectable } from '@nestjs/common';
import { UserLoginMigrationDO } from '@shared/domain/domainobject';
import { User } from '@shared/domain/entity';
import { AuthorizationContext, Rule } from '../../type';
import { AuthorizationHelper } from '../authorization.helper';
import { AuthorizationContext, Rule } from '../type';
import { AuthorizationHelper } from '../service/authorization.helper';

@Injectable()
export class UserLoginMigrationRule implements Rule<UserLoginMigrationDO> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Test, TestingModule } from '@nestjs/testing';
import { Role, User } from '@shared/domain/entity';
import { Permission } from '@shared/domain/interface';
import { roleFactory, setupEntities, userFactory } from '@shared/testing';
import { Action } from '../../type';
import { AuthorizationHelper } from '../authorization.helper';
import { Action } from '../type';
import { AuthorizationHelper } from '../service/authorization.helper';
import { UserRule } from './user.rule';

describe('UserRule', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
import { User } from '@shared/domain/entity';
import { AuthorizationContext, Rule } from '../../type';
import { AuthorizationHelper } from '../authorization.helper';
import { AuthorizationContext, Rule } from '../type';
import { AuthorizationHelper } from '../service/authorization.helper';

@Injectable()
export class UserRule implements Rule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
TeamRule,
UserRule,
UserLoginMigrationRule,
} from './rules';
} from '../rules';
import { RuleManager } from './rule-manager';

describe('RuleManager', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
TeamRule,
UserLoginMigrationRule,
UserRule,
} from './rules';
} from '../rules';

@Injectable()
export class RuleManager {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Request } from 'express';
import request from 'supertest';
import { Configuration } from '@hpi-schul-cloud/commons/lib';
import { EntityManager } from '@mikro-orm/mongodb';
import { EntityManager, ObjectId } from '@mikro-orm/mongodb';
import { ExecutionContext, HttpStatus, INestApplication } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { ApiValidationError } from '@shared/common';
Expand Down Expand Up @@ -116,9 +116,8 @@ describe(`share token creation (api)`, () => {
});

it('should return status 404 when parent id is not found', async () => {
// validation of parentId should be failed on mongoId
const response = await api.post({
parentId: '000011112222333344445555',
parentId: new ObjectId().toHexString(),
parentType: ShareTokenParentType.Course,
});

Expand Down

0 comments on commit 97d9460

Please sign in to comment.