Skip to content

Commit

Permalink
Merge branch 'main' into EW-561
Browse files Browse the repository at this point in the history
  • Loading branch information
psachmann committed Oct 18, 2023
2 parents b5058b8 + 7c45f2c commit 9e0e08f
Show file tree
Hide file tree
Showing 43 changed files with 1,266 additions and 115 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/reusable_job_nest_test_sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
fileName: 'secrets.json'
fileDir: './config/'
# These are placeholder secrets without any significance
encodedString: ewogICAgIkRCIjogewogICAgICAgICJTRUNSRVQiOiAiVmVyeSBoaWRkZW4gc2VjcmV0IgogICAgfSwKICAgICJLRVlDTE9BSyI6IHsKICAgICAgICAiU0VDUkVUIjogIkNsaWVudCBTZWNyZXQiCiAgICB9Cn0=
encodedString: ewogICAgIkRCIjogewogICAgICAgICJTRUNSRVQiOiAiVmVyeSBoaWRkZW4gc2VjcmV0IgogICAgfSwKICAgICJLRVlDTE9BSyI6IHsKICAgICAgICAiQURNSU5fU0VDUkVUIjogIkNsaWVudCBTZWNyZXQiCiAgICB9Cn0=
- name: Setup node
uses: actions/setup-node@v3
with:
Expand Down
7 changes: 4 additions & 3 deletions config/config.dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
},
"KEYCLOAK": {
"BASE_URL": "http://127.0.0.1:8080",
"REALM_NAME": "master",
"CLIENT_ID": "admin-cli",
"SECRET": "topsecret"
"ADMIN_REALM_NAME": "master",
"ADMIN_CLIENT_ID": "admin-cli",
"REALM_NAME": "schulportal",
"CLIENT_ID": "schulportal"
}
}
6 changes: 4 additions & 2 deletions config/config.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
},
"KEYCLOAK": {
"BASE_URL": "http://127.0.0.1:8080",
"REALM_NAME": "master",
"CLIENT_ID": "admin-cli"
"ADMIN_REALM_NAME": "master",
"ADMIN_CLIENT_ID": "admin-cli",
"REALM_NAME": "schulportal",
"CLIENT_ID": "schulportal"
}
}
55 changes: 55 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"lodash-es": "^4.17.21",
"nest-commander": "^3.11.0",
"nest-keycloak-connect": "^1.9.2",
"openid-client": "^5.6.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.2.0"
},
Expand Down
8 changes: 5 additions & 3 deletions src/modules/health/health.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ describe('HealthController', () => {
let entityManager: SqlEntityManager;
let httpHealthIndicator: DeepMocked<HttpHealthIndicator>;
const keycloakConfig: KeycloakConfig = {
CLIENT_ID: '',
SECRET: '',
REALM_NAME: '',
ADMIN_CLIENT_ID: '',
ADMIN_SECRET: '',
ADMIN_REALM_NAME: '',
BASE_URL: 'http://keycloak.test',
REALM_NAME: '',
CLIENT_ID: '',
};
let configService: DeepMocked<ConfigService>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class KeycloakAdministrationService {

this.kcAdminClient.setConfig({
baseUrl: this.kcConfig.BASE_URL,
realmName: this.kcConfig.REALM_NAME,
realmName: this.kcConfig.ADMIN_REALM_NAME,
});
}

Expand All @@ -45,8 +45,8 @@ export class KeycloakAdministrationService {
try {
const credentials: Credentials = {
grantType: 'client_credentials',
clientId: this.kcConfig.CLIENT_ID,
clientSecret: this.kcConfig.SECRET,
clientId: this.kcConfig.ADMIN_CLIENT_ID,
clientSecret: this.kcConfig.ADMIN_SECRET,
};

await this.kcAdminClient.auth(credentials);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { AutoMap } from '@automapper/classes';
import { PagedDto } from '../../../shared/paging/index.js';
import { SichtfreigabeType } from './personen-query.param.js';

export class FindPersonDatensatzDTO extends PagedDto {
export class FindPersonendatensatzDto extends PagedDto {
@AutoMap()
public referrer?: string;

Expand All @@ -10,4 +11,7 @@ export class FindPersonDatensatzDTO extends PagedDto {

@AutoMap()
public vorname?: string;

@AutoMap()
public sichtfreigabe!: SichtfreigabeType;
}
20 changes: 20 additions & 0 deletions src/modules/person/api/find-personenkontext.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { AutoMap } from '@automapper/classes';
import { Rolle, Personenstatus } from '../domain/personenkontext.enums.js';
import { SichtfreigabeType } from './personen-query.param.js';

export class FindPersonenkontextDto {
@AutoMap()
public personId!: string;

@AutoMap()
public readonly referrer?: string;

@AutoMap()
public readonly rolle?: Rolle;

@AutoMap()
public readonly personenstatus?: Personenstatus;

@AutoMap()
public readonly sichtfreigabe: SichtfreigabeType = SichtfreigabeType.NEIN;
}
36 changes: 34 additions & 2 deletions src/modules/person/api/person-api.mapper.profile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { Jahrgangsstufe, Personenstatus, Rolle } from '../domain/personenkontext
import { PersonenkontextDo } from '../domain/personenkontext.do.js';
import { CreatedPersonenkontextDto } from './created-personenkontext.dto.js';
import { PersonenkontextResponse } from './personenkontext.response.js';
import { PersonenkontextQueryParams } from './personenkontext-query.params.js';
import { FindPersonenkontextDto } from './find-personenkontext.dto.js';

describe('PersonApiMapperProfile', () => {
let module: TestingModule;
Expand Down Expand Up @@ -166,8 +168,8 @@ describe('PersonApiMapperProfile', () => {
});

it('should map PersonenkontextDo to CreatedPersonenkontextDto', () => {
const personDo: PersonenkontextDo<true> = DoFactory.createPersonenkontext(true);
expect(() => sut.map(personDo, PersonenkontextDo, CreatedPersonenkontextDto)).not.toThrowError(
const personenkontextDo: PersonenkontextDo<true> = DoFactory.createPersonenkontext(true);
expect(() => sut.map(personenkontextDo, PersonenkontextDo, CreatedPersonenkontextDto)).not.toThrowError(
MappingError,
);
});
Expand All @@ -189,5 +191,35 @@ describe('PersonApiMapperProfile', () => {
MappingError,
);
});

it('should map PersonenkontextQueryParams to FindePersonenkontextDto', () => {
const params: PersonenkontextQueryParams = {
sichtfreigabe: SichtfreigabeType.JA,
personenstatus: Personenstatus.AKTIV,
referrer: 'referrer',
rolle: Rolle.LERNENDER,
};
expect(() => sut.map(params, PersonenkontextQueryParams, FindPersonenkontextDto)).not.toThrowError(
MappingError,
);
});

it('should map FindePersonenkontextDto to PersonenkontextDo', () => {
const dto: FindPersonenkontextDto = {
personId: faker.string.uuid(),
sichtfreigabe: SichtfreigabeType.JA,
personenstatus: Personenstatus.AKTIV,
referrer: 'referrer',
rolle: Rolle.LERNENDER,
};
expect(() => sut.map(dto, FindPersonenkontextDto, PersonenkontextDo)).not.toThrowError(MappingError);
});

it('should map PersonenkontextDo to PersonenkontextResponse', () => {
const personenkontextDo: PersonenkontextDo<true> = DoFactory.createPersonenkontext(true);
expect(() => sut.map(personenkontextDo, PersonenkontextDo, PersonenkontextResponse)).not.toThrowError(
MappingError,
);
});
});
});
Loading

0 comments on commit 9e0e08f

Please sign in to comment.