Skip to content

Commit

Permalink
fix "security hotspot" and coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinOehlerkingCap committed Nov 23, 2023
1 parent 44c575b commit 9c2c94e
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 6 deletions.
57 changes: 56 additions & 1 deletion apps/server/src/modules/system/repo/system.repo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { Test, TestingModule } from '@nestjs/testing';
import { LdapConfigEntity, OauthConfigEntity, SystemEntity } from '@shared/domain';
import { SystemProvisioningStrategy } from '@shared/domain/interface/system-provisioning.strategy';
import { cleanupCollections, systemEntityFactory } from '@shared/testing';
import { SystemProps } from '../domain';
import { System, SystemProps } from '../domain';
import { SystemDomainMapper } from './system-domain.mapper';
import { SystemRepo } from './system.repo';

describe(SystemRepo.name, () => {
Expand Down Expand Up @@ -119,4 +120,58 @@ describe(SystemRepo.name, () => {
});
});
});

describe('delete', () => {
describe('when the system exists', () => {
const setup = async () => {
const systemEntity: SystemEntity = systemEntityFactory.buildWithId();

await em.persistAndFlush([systemEntity]);
em.clear();

const props: SystemProps = SystemDomainMapper.mapEntityToDomainObjectProperties(systemEntity);
const system: System = new System(props);

return {
system,
};
};

it('should delete the system', async () => {
const { system } = await setup();

await repo.delete(system);

expect(await em.findOne(SystemEntity, { id: system.id })).toBeNull();
});

it('should return true', async () => {
const { system } = await setup();

const result = await repo.delete(system);

expect(result).toEqual(true);
});
});

describe('when the system does not exists', () => {
const setup = () => {
const systemEntity: SystemEntity = systemEntityFactory.buildWithId();
const props: SystemProps = SystemDomainMapper.mapEntityToDomainObjectProperties(systemEntity);
const system: System = new System(props);

return {
system,
};
};

it('should return false', async () => {
const { system } = setup();

const result = await repo.delete(system);

expect(result).toEqual(false);
});
});
});
});
10 changes: 5 additions & 5 deletions apps/server/src/shared/testing/factory/systemEntityFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ export class SystemEntityFactory extends BaseFactory<SystemEntity, SystemEntityP
clientId: '12345',
clientSecret: 'mocksecret',
idpHint: 'mock-oauth-idpHint',
tokenEndpoint: 'http://mock.de/mock/auth/public/mockToken',
tokenEndpoint: 'https://mock.de/mock/auth/public/mockToken',
grantType: 'authorization_code',
redirectUri: 'http://mockhost:3030/api/v3/sso/oauth/',
redirectUri: 'https://mockhost:3030/api/v3/sso/oauth/',
scope: 'openid uuid',
responseType: 'code',
authEndpoint: 'http://mock.de/auth',
authEndpoint: 'https://mock.de/auth',
provider: 'mock_type',
logoutEndpoint: 'http://mock.de/logout',
logoutEndpoint: 'https://mock.de/logout',
issuer: 'mock_issuer',
jwksEndpoint: 'http://mock.de/jwks',
jwksEndpoint: 'https://mock.de/jwks',
}),
};
return this.params(params);
Expand Down

0 comments on commit 9c2c94e

Please sign in to comment.