Skip to content

Commit

Permalink
Merge branch 'release-0101' into SPSH-1378
Browse files Browse the repository at this point in the history
  • Loading branch information
clauyan authored Dec 12, 2024
2 parents 0903236 + 8f74727 commit c7d33b9
Show file tree
Hide file tree
Showing 40 changed files with 1,019 additions and 176 deletions.
57 changes: 38 additions & 19 deletions migrations/.snapshot-dbildungs-iam-server.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@
"PERSON_SYNCHRONISIEREN",
"CRON_DURCHFUEHREN",
"PERSONEN_ANLEGEN",
"IMPORT_DURCHFUEHREN"
"IMPORT_DURCHFUEHREN",
"PERSONEN_LESEN"
]
},
"service_provider_target_enum": {
Expand Down Expand Up @@ -418,7 +419,8 @@
"PERSON_SYNCHRONISIEREN",
"CRON_DURCHFUEHREN",
"PERSONEN_ANLEGEN",
"IMPORT_DURCHFUEHREN"
"IMPORT_DURCHFUEHREN",
"PERSONEN_LESEN"
]
},
"service_provider_target_enum": {
Expand Down Expand Up @@ -655,7 +657,8 @@
"PERSON_SYNCHRONISIEREN",
"CRON_DURCHFUEHREN",
"PERSONEN_ANLEGEN",
"IMPORT_DURCHFUEHREN"
"IMPORT_DURCHFUEHREN",
"PERSONEN_LESEN"
]
},
"service_provider_target_enum": {
Expand Down Expand Up @@ -884,7 +887,8 @@
"PERSON_SYNCHRONISIEREN",
"CRON_DURCHFUEHREN",
"PERSONEN_ANLEGEN",
"IMPORT_DURCHFUEHREN"
"IMPORT_DURCHFUEHREN",
"PERSONEN_LESEN"
]
},
"service_provider_target_enum": {
Expand Down Expand Up @@ -1105,7 +1109,8 @@
"PERSON_SYNCHRONISIEREN",
"CRON_DURCHFUEHREN",
"PERSONEN_ANLEGEN",
"IMPORT_DURCHFUEHREN"
"IMPORT_DURCHFUEHREN",
"PERSONEN_LESEN"
]
},
"service_provider_target_enum": {
Expand Down Expand Up @@ -1374,7 +1379,8 @@
"PERSON_SYNCHRONISIEREN",
"CRON_DURCHFUEHREN",
"PERSONEN_ANLEGEN",
"IMPORT_DURCHFUEHREN"
"IMPORT_DURCHFUEHREN",
"PERSONEN_LESEN"
]
},
"service_provider_target_enum": {
Expand Down Expand Up @@ -1739,7 +1745,8 @@
"PERSON_SYNCHRONISIEREN",
"CRON_DURCHFUEHREN",
"PERSONEN_ANLEGEN",
"IMPORT_DURCHFUEHREN"
"IMPORT_DURCHFUEHREN",
"PERSONEN_LESEN"
]
},
"service_provider_target_enum": {
Expand Down Expand Up @@ -2509,7 +2516,8 @@
"PERSON_SYNCHRONISIEREN",
"CRON_DURCHFUEHREN",
"PERSONEN_ANLEGEN",
"IMPORT_DURCHFUEHREN"
"IMPORT_DURCHFUEHREN",
"PERSONEN_LESEN"
]
},
"service_provider_target_enum": {
Expand Down Expand Up @@ -2802,7 +2810,8 @@
"PERSON_SYNCHRONISIEREN",
"CRON_DURCHFUEHREN",
"PERSONEN_ANLEGEN",
"IMPORT_DURCHFUEHREN"
"IMPORT_DURCHFUEHREN",
"PERSONEN_LESEN"
]
},
"service_provider_target_enum": {
Expand Down Expand Up @@ -3073,7 +3082,8 @@
"PERSON_SYNCHRONISIEREN",
"CRON_DURCHFUEHREN",
"PERSONEN_ANLEGEN",
"IMPORT_DURCHFUEHREN"
"IMPORT_DURCHFUEHREN",
"PERSONEN_LESEN"
]
},
"service_provider_target_enum": {
Expand Down Expand Up @@ -3465,7 +3475,8 @@
"PERSON_SYNCHRONISIEREN",
"CRON_DURCHFUEHREN",
"PERSONEN_ANLEGEN",
"IMPORT_DURCHFUEHREN"
"IMPORT_DURCHFUEHREN",
"PERSONEN_LESEN"
]
},
"service_provider_target_enum": {
Expand Down Expand Up @@ -3698,7 +3709,8 @@
"PERSON_SYNCHRONISIEREN",
"CRON_DURCHFUEHREN",
"PERSONEN_ANLEGEN",
"IMPORT_DURCHFUEHREN"
"IMPORT_DURCHFUEHREN",
"PERSONEN_LESEN"
]
},
"service_provider_target_enum": {
Expand Down Expand Up @@ -3762,7 +3774,8 @@
"PERSON_SYNCHRONISIEREN",
"CRON_DURCHFUEHREN",
"PERSONEN_ANLEGEN",
"IMPORT_DURCHFUEHREN"
"IMPORT_DURCHFUEHREN",
"PERSONEN_LESEN"
],
"mappedType": "enum"
}
Expand Down Expand Up @@ -3940,7 +3953,8 @@
"PERSON_SYNCHRONISIEREN",
"CRON_DURCHFUEHREN",
"PERSONEN_ANLEGEN",
"IMPORT_DURCHFUEHREN"
"IMPORT_DURCHFUEHREN",
"PERSONEN_LESEN"
]
},
"service_provider_target_enum": {
Expand Down Expand Up @@ -4251,7 +4265,8 @@
"PERSON_SYNCHRONISIEREN",
"CRON_DURCHFUEHREN",
"PERSONEN_ANLEGEN",
"IMPORT_DURCHFUEHREN"
"IMPORT_DURCHFUEHREN",
"PERSONEN_LESEN"
]
},
"service_provider_target_enum": {
Expand Down Expand Up @@ -4585,7 +4600,8 @@
"PERSON_SYNCHRONISIEREN",
"CRON_DURCHFUEHREN",
"PERSONEN_ANLEGEN",
"IMPORT_DURCHFUEHREN"
"IMPORT_DURCHFUEHREN",
"PERSONEN_LESEN"
]
},
"service_provider_target_enum": {
Expand Down Expand Up @@ -4815,7 +4831,8 @@
"PERSON_SYNCHRONISIEREN",
"CRON_DURCHFUEHREN",
"PERSONEN_ANLEGEN",
"IMPORT_DURCHFUEHREN"
"IMPORT_DURCHFUEHREN",
"PERSONEN_LESEN"
]
},
"service_provider_target_enum": {
Expand Down Expand Up @@ -5091,7 +5108,8 @@
"PERSON_SYNCHRONISIEREN",
"CRON_DURCHFUEHREN",
"PERSONEN_ANLEGEN",
"IMPORT_DURCHFUEHREN"
"IMPORT_DURCHFUEHREN",
"PERSONEN_LESEN"
]
},
"service_provider_target_enum": {
Expand Down Expand Up @@ -5259,7 +5277,8 @@
"PERSON_SYNCHRONISIEREN",
"CRON_DURCHFUEHREN",
"PERSONEN_ANLEGEN",
"IMPORT_DURCHFUEHREN"
"IMPORT_DURCHFUEHREN",
"PERSONEN_LESEN"
]
},
"service_provider_target_enum": {
Expand Down
8 changes: 8 additions & 0 deletions migrations/Migration20241207094524-S.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Migration } from '@mikro-orm/migrations';

export class Migration20241207094524 extends Migration {
async up(): Promise<void> {
this.addSql('alter type "rollen_system_recht_enum" add value if not exists \'PERSONEN_LESEN\';');
this.addSql("update rolle set ist_technisch = true where name = 'Technical User NextCloud';");
}
}
12 changes: 11 additions & 1 deletion seeding/dev/01/04_rolle.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
{
"id": 14,
"administeredBySchulstrukturknoten": 0,
"name": "IQSH Mitarbeiter ohne Landes-E-Mail",
"name": "IQSH Mitarbeiter",
"rollenart": "LEHR",
"merkmale": ["KOPERS_PFLICHT"],
"systemrechte": [],
Expand Down Expand Up @@ -191,6 +191,16 @@
],
"serviceProviderIds": [],
"istTechnisch": true
},
{
"id": 102,
"administeredBySchulstrukturknoten": 0,
"name": "Technical User NextCloud",
"rollenart": "SYSADMIN",
"merkmale": [],
"systemrechte": ["PERSONEN_LESEN"],
"serviceProviderIds": [],
"istTechnisch": true
}
]
}
10 changes: 8 additions & 2 deletions seeding/dev/01/05_technical-user.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@
"username": "cron-runner",
"vorname": "cron-runner",
"familienname": "cron-runner",
"keycloakUserId": "7baf74aa-565f-4cfc-9d5a-8f1a3f374dc9",
"personalnummer": "7777777"
"keycloakUserId": "7baf74aa-565f-4cfc-9d5a-8f1a3f374dc9"
},
{
"id": 7777778,
"username": "nextcloud",
"vorname": "nextcloud",
"password": "SPSHnextcloud1!",
"familienname": "nextcloud"
}
]
}
5 changes: 5 additions & 0 deletions seeding/dev/01/06_personenkontext.json
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,11 @@
"personId": 60,
"organisationId": 702,
"rolleId": 1
},
{
"personId": 7777778,
"organisationId": 0,
"rolleId": 102
}
]
}
12 changes: 11 additions & 1 deletion seeding/prod/01/04_rolle.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
{
"id": 14,
"administeredBySchulstrukturknoten": 0,
"name": "IQSH Mitarbeiter ohne Landes-E-Mail",
"name": "IQSH Mitarbeiter",
"rollenart": "LEHR",
"merkmale": ["KOPERS_PFLICHT"],
"systemrechte": [],
Expand Down Expand Up @@ -191,6 +191,16 @@
],
"serviceProviderIds": [],
"istTechnisch": true
},
{
"id": 102,
"administeredBySchulstrukturknoten": 0,
"name": "Technical User NextCloud",
"rollenart": "SYSADMIN",
"merkmale": [],
"systemrechte": ["PERSONEN_LESEN"],
"serviceProviderIds": [],
"istTechnisch": true
}
]
}
9 changes: 7 additions & 2 deletions seeding/prod/01/05_technical-user.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
"username": "cron-runner",
"vorname": "cron-runner",
"familienname": "cron-runner",
"keycloakUserId": "7baf74aa-565f-4cfc-9d5a-8f1a3f374dc9",
"personalnummer": "7777777"
"keycloakUserId": "7baf74aa-565f-4cfc-9d5a-8f1a3f374dc9"
},
{
"id": 7777778,
"username": "nextcloud",
"vorname": "nextcloud",
"familienname": "nextcloud"
}
]
}
6 changes: 5 additions & 1 deletion seeding/prod/01/06_personenkontext.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
"personId": 7777777,
"organisationId": 0,
"rolleId": 100
},
{
"personId": 7777778,
"organisationId": 0,
"rolleId": 102
}
]
}

27 changes: 24 additions & 3 deletions src/console/dbseed/domain/db-seed.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ describe('DbSeedService', () => {
let personenkontextServiceMock: DeepMocked<DBiamPersonenkontextService>;
let dbSeedReferenceRepoMock: DeepMocked<DbSeedReferenceRepo>;
let kcUserService: DeepMocked<KeycloakUserService>;
let personFactory: DeepMocked<PersonFactory>;

beforeAll(async () => {
module = await Test.createTestingModule({
Expand Down Expand Up @@ -108,6 +109,7 @@ describe('DbSeedService', () => {
personenkontextServiceMock = module.get(DBiamPersonenkontextService);
dbSeedReferenceRepoMock = module.get(DbSeedReferenceRepo);
kcUserService = module.get(KeycloakUserService);
personFactory = module.get(PersonFactory);
});

afterAll(async () => {
Expand Down Expand Up @@ -467,15 +469,34 @@ describe('DbSeedService', () => {
'utf-8',
);

const person: Person<true> = createMock<Person<true>>();

personRepoMock.create.mockResolvedValue(person);
const person: Person<false> = createMock<Person<true>>();
const personPersisted: Person<true> = createMock<Person<true>>();
personFactory.createNew.mockResolvedValueOnce(person);
personRepoMock.create.mockResolvedValue(personPersisted);

await dbSeedService.seedTechnicalUser(fileContentAsStr);

expect(dbSeedReferenceRepoMock.create).toHaveBeenCalledTimes(0);
});
});

describe('error in person factory', () => {
it('should throw Domain Error', async () => {
const fileContentAsStr: string = fs.readFileSync(
`./seeding/seeding-integration-test/invalidPerson/06_technical-user.json`,
'utf-8',
);

// return DomainError
personFactory.createNew.mockResolvedValueOnce(new NameForOrganisationWithTrailingSpaceError());

await expect(dbSeedService.seedTechnicalUser(fileContentAsStr)).rejects.toThrow(
NameForOrganisationWithTrailingSpaceError,
);
expect(personRepoMock.create).toHaveBeenCalledTimes(0);
expect(dbSeedReferenceRepoMock.create).toHaveBeenCalledTimes(0);
});
});
});

describe('seedPersonkontext', () => {
Expand Down
Loading

0 comments on commit c7d33b9

Please sign in to comment.