Merge pull request 'First feature version 0.1.0' (#102) from dev into main
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

Reviewed-on: #102
Reviewed-by: Philipp Dormann <philipp@philippdormann.de>
This commit is contained in:
Nicolai Ort 2021-01-15 19:31:40 +00:00
commit 38b9a772cd
32 changed files with 164 additions and 175 deletions

View File

@ -2,14 +2,54 @@
All notable changes to this project will be documented in this file. Dates are displayed in UTC. All notable changes to this project will be documented in this file. Dates are displayed in UTC.
#### [v0.1.0](https://git.odit.services/lfk/backend/compare/v0.0.12...v0.1.0)
- Removed useless parts from functions and updated comments [`c05834f`](https://git.odit.services/lfk/backend/commit/c05834f2a13eb838efbf61be803e4e320561718e)
- Switched tests over to the new id-only schema [`d88fb18`](https://git.odit.services/lfk/backend/commit/d88fb183198e66cadf5290c1ef7b7e4ccedad4f0)
- 🧾New changelog file version [CI SKIP] [skip ci] [`0e119e4`](https://git.odit.services/lfk/backend/commit/0e119e48340cd0a602a08da727b480aa2fe5500c)
- Refactoring: switched update team parent from objects to ids [`ed3b55a`](https://git.odit.services/lfk/backend/commit/ed3b55a1e2b6a8dd21c43d28e9fe69d86c327c27)
- Refactoring: switched from objects to ids [`6b6f345`](https://git.odit.services/lfk/backend/commit/6b6f3456183091468796e13e149db4d553d39155)
- Switched to full update from partial and resolved relation [`bae8290`](https://git.odit.services/lfk/backend/commit/bae8290273aa7b7436ea14a05d398aeda20c6642)
- Removed useless part from function and updated comments [`644d2b0`](https://git.odit.services/lfk/backend/commit/644d2b06ace012cb43d9d2b0ce38146b8586841f)
- Removed useless part from function [`8d4c8a4`](https://git.odit.services/lfk/backend/commit/8d4c8a455398a77ebe6aa53f1e3cc06bc5af4b3a)
- Refactoring: switched from objects to ids [`2ac9d3e`](https://git.odit.services/lfk/backend/commit/2ac9d3e977b8903351e5e3185f3454b4bf7763df)
- Removed useless part from function and updated comments [`22e6070`](https://git.odit.services/lfk/backend/commit/22e6070e5316b01a50fd29a4cfda2b3d0cef81c9)
- Fixed country code type issue [`a77e2eb`](https://git.odit.services/lfk/backend/commit/a77e2eb3ada5c646a4e18eff5ea25e9872dfb28f)
- Refactoring: switched update org address from objects to ids [`97c01ce`](https://git.odit.services/lfk/backend/commit/97c01ce81a48170be014084df8028091c43f03f4)
- Updated faulty getter function [`09ad081`](https://git.odit.services/lfk/backend/commit/09ad081b3727f37d1837420af6b81b5301170352)
- Refactoring: switched update runner group from objects to ids [`e966372`](https://git.odit.services/lfk/backend/commit/e96637219ff01d5da2feeb933538748fca440cbd)
- Clarified comments [`b895257`](https://git.odit.services/lfk/backend/commit/b89525746dbeed95a614aa863ce2cb7ff0ddfc5e)
- Fixed broken pkg stuff [`385a9bb`](https://git.odit.services/lfk/backend/commit/385a9bba73f66242caccc74f3bfed97f383037d4)
- Refactoring: switched update user groups from objects to ids [`aa0fd9c`](https://git.odit.services/lfk/backend/commit/aa0fd9cafd2196e2f0c93a42d6981cf125674abb)
- 🧾New changelog file version [CI SKIP] [skip ci] [`dc6ad9c`](https://git.odit.services/lfk/backend/commit/dc6ad9cdd3d8f29ef9a15bf7ac61c7c55c57e9fb)
- 🧾New changelog file version [CI SKIP] [skip ci] [`d1a0bed`](https://git.odit.services/lfk/backend/commit/d1a0bed00e01a0e9d8ba1165e3c6ca3dd910bd00)
- Clarified comments [`1b799a6`](https://git.odit.services/lfk/backend/commit/1b799a697305791c3f67ac4a738c7287d1ac553e)
- 🧾New changelog file version [CI SKIP] [skip ci] [`8218a45`](https://git.odit.services/lfk/backend/commit/8218a452bdf7550ec1eed2b0045e94ea4ae91d31)
- 🚀Bumped version to v0.1.0 [`80c5f9b`](https://git.odit.services/lfk/backend/commit/80c5f9b84de355b4408dcffd632589a9a0e4ad2e)
- 🧾New changelog file version [CI SKIP] [skip ci] [`79f46cb`](https://git.odit.services/lfk/backend/commit/79f46cb745e4cb4bdac7dbb6c6c2b8fdc9867592)
- 👊 Bumped dependency [`de32a98`](https://git.odit.services/lfk/backend/commit/de32a9862db3cb73a4863a1bd50bf68b9be12316)
- Merge pull request 'Switched to accepting ids (numbers/number arrays) feature/90-accept_objects' (#101) from feature/90-accept_objects into dev [`29c8e00`](https://git.odit.services/lfk/backend/commit/29c8e004772ac27b5e96361b7239bf61c2276400)
- Clarified comments [`93692ec`](https://git.odit.services/lfk/backend/commit/93692ec2553ded72e72c6ec0277081a5c235ea42)
- Clarified comments [`077174a`](https://git.odit.services/lfk/backend/commit/077174a9a2d2b97eda0c54ffe79ce3ebf61f72cc)
- Updated faulty getter function [`420e9c4`](https://git.odit.services/lfk/backend/commit/420e9c4662ee0bbdf2503f2d77d80d541dceba07)
- Fixed old reference [`98d6a1c`](https://git.odit.services/lfk/backend/commit/98d6a1cc641f76254e5d2dcb642f4a60f3158bf8)
- Clarified comments [`17244b0`](https://git.odit.services/lfk/backend/commit/17244b0006e9d8b6bde53c5eebe0371122a9e30d)
- Clarified comments [`99852f5`](https://git.odit.services/lfk/backend/commit/99852f591e1a785827c680b9c30b7855ed0ddb6f)
- Clarified comments [`9bbfb47`](https://git.odit.services/lfk/backend/commit/9bbfb4763de71c0046da9676adcc747901296e84)
- Made addresses optional gain [`ba218c8`](https://git.odit.services/lfk/backend/commit/ba218c85e0d2a31aaebc829e2be647f2b802a05b)
- Removed todo [`ce31b95`](https://git.odit.services/lfk/backend/commit/ce31b95fb744705130bdec64e5933e6b1b4aa62c)
#### [v0.0.12](https://git.odit.services/lfk/backend/compare/v0.0.11...v0.0.12) #### [v0.0.12](https://git.odit.services/lfk/backend/compare/v0.0.11...v0.0.12)
> 13 January 2021
- Merge pull request 'Fixed backend version related bugs' (#92) from bugfix/91-backend_version into dev [`#91`](https://git.odit.services/lfk/backend/issues/91) - Merge pull request 'Fixed backend version related bugs' (#92) from bugfix/91-backend_version into dev [`#91`](https://git.odit.services/lfk/backend/issues/91)
- Merge pull request 'Bugfix: resolved missing relation' (#89) from bugfix/88-user_update into dev [`#88`](https://git.odit.services/lfk/backend/issues/88) - Merge pull request 'Bugfix: resolved missing relation' (#89) from bugfix/88-user_update into dev [`#88`](https://git.odit.services/lfk/backend/issues/88)
- Merge pull request 'Alpha Release 0.0.12' (#98) from dev into main [`881eedb`](https://git.odit.services/lfk/backend/commit/881eedbf3a792c316ade70b6a898fc16807cf648)
- 🧾New changelog file version [CI SKIP] [skip ci] [`8cb67a8`](https://git.odit.services/lfk/backend/commit/8cb67a8d202527dcaa26d5f37b3fd03d90a897ca) - 🧾New changelog file version [CI SKIP] [skip ci] [`8cb67a8`](https://git.odit.services/lfk/backend/commit/8cb67a8d202527dcaa26d5f37b3fd03d90a897ca)
- 📖New license file version [CI SKIP] [skip ci] [`09b16c9`](https://git.odit.services/lfk/backend/commit/09b16c980b01db3233db7cd3161e58aa33498993) - 📖New license file version [CI SKIP] [skip ci] [`09b16c9`](https://git.odit.services/lfk/backend/commit/09b16c980b01db3233db7cd3161e58aa33498993)
- 🧾New changelog file version [CI SKIP] [`2947c41`](https://git.odit.services/lfk/backend/commit/2947c41a7241417d51f278d2e4f6195a3f3bc30d) - 🧾New changelog file version [CI SKIP] [`2947c41`](https://git.odit.services/lfk/backend/commit/2947c41a7241417d51f278d2e4f6195a3f3bc30d)
- Switched emails to being mandetory for users [`9feeb30`](https://git.odit.services/lfk/backend/commit/9feeb302e89049843564015c2dc2820ac2886e2d) - 🧾New changelog file version [CI SKIP] [skip ci] [`09cb6f7`](https://git.odit.services/lfk/backend/commit/09cb6f7b2bda342a73b91a7b6909b12c2531b0e5)
- Added a new endpoint that returns a users permissions as objects sorted into two arrays [`b01e1eb`](https://git.odit.services/lfk/backend/commit/b01e1eb8a1a36fc8e04e009cd6024495a70a10dd) - Added a new endpoint that returns a users permissions as objects sorted into two arrays [`b01e1eb`](https://git.odit.services/lfk/backend/commit/b01e1eb8a1a36fc8e04e009cd6024495a70a10dd)
- Added new pipeline to automagicly generate changelogs on pr to main [`6345666`](https://git.odit.services/lfk/backend/commit/6345666ae67846463f1dadeb13c0f5c46a0c74ae) - Added new pipeline to automagicly generate changelogs on pr to main [`6345666`](https://git.odit.services/lfk/backend/commit/6345666ae67846463f1dadeb13c0f5c46a0c74ae)
- Updated some openapi descriptions [`0724932`](https://git.odit.services/lfk/backend/commit/0724932152278a1dce94f17835e00fd1bbd808f9) - Updated some openapi descriptions [`0724932`](https://git.odit.services/lfk/backend/commit/0724932152278a1dce94f17835e00fd1bbd808f9)
@ -50,6 +90,7 @@ All notable changes to this project will be documented in this file. Dates are d
- Implemented fixed donation updateing [`9517df5`](https://git.odit.services/lfk/backend/commit/9517df50826aff1a1cb03e611b990de5829e2132) - Implemented fixed donation updateing [`9517df5`](https://git.odit.services/lfk/backend/commit/9517df50826aff1a1cb03e611b990de5829e2132)
- Added donation get tests [`63506da`](https://git.odit.services/lfk/backend/commit/63506dac1c86e4bf4cfae9d4b94d98ac3856bbaa) - Added donation get tests [`63506da`](https://git.odit.services/lfk/backend/commit/63506dac1c86e4bf4cfae9d4b94d98ac3856bbaa)
- Added cascading runner deletion tests [`b729a7c`](https://git.odit.services/lfk/backend/commit/b729a7ceadf25787066ddc4d9cb5f08d140c4cd8) - Added cascading runner deletion tests [`b729a7c`](https://git.odit.services/lfk/backend/commit/b729a7ceadf25787066ddc4d9cb5f08d140c4cd8)
- Switched emails to being mandetory for users [`9feeb30`](https://git.odit.services/lfk/backend/commit/9feeb302e89049843564015c2dc2820ac2886e2d)
- Implemented donation getting [`0df26cb`](https://git.odit.services/lfk/backend/commit/0df26cbd54bf914166bcb9ac1b03dee0c5dba07d) - Implemented donation getting [`0df26cb`](https://git.odit.services/lfk/backend/commit/0df26cbd54bf914166bcb9ac1b03dee0c5dba07d)
- Implemented distance donation updateing [`f7370bc`](https://git.odit.services/lfk/backend/commit/f7370bc8025f9a29b4c046ec1dd28b128398dab9) - Implemented distance donation updateing [`f7370bc`](https://git.odit.services/lfk/backend/commit/f7370bc8025f9a29b4c046ec1dd28b128398dab9)
- Implmented cascading donation deletion for runners and donors [`e716fae`](https://git.odit.services/lfk/backend/commit/e716fae1c5eec625e6d050ac8893dfbe2ff1d820) - Implmented cascading donation deletion for runners and donors [`e716fae`](https://git.odit.services/lfk/backend/commit/e716fae1c5eec625e6d050ac8893dfbe2ff1d820)

View File

@ -1,6 +1,6 @@
{ {
"name": "@odit/lfk-backend", "name": "@odit/lfk-backend",
"version": "0.0.12", "version": "0.1.0",
"main": "src/app.ts", "main": "src/app.ts",
"repository": "https://git.odit.services/lfk/backend", "repository": "https://git.odit.services/lfk/backend",
"author": { "author": {
@ -22,11 +22,11 @@
], ],
"license": "CC-BY-NC-SA-4.0", "license": "CC-BY-NC-SA-4.0",
"dependencies": { "dependencies": {
"@odit/class-validator-jsonschema": "2.1.1",
"argon2": "^0.27.1", "argon2": "^0.27.1",
"body-parser": "^1.19.0", "body-parser": "^1.19.0",
"class-transformer": "^0.3.1", "class-transformer": "0.3.1",
"class-validator": "^0.12.2", "class-validator": "^0.13.1",
"class-validator-jsonschema": "^2.1.0",
"consola": "^2.15.0", "consola": "^2.15.0",
"cookie": "^0.4.1", "cookie": "^0.4.1",
"cookie-parser": "^1.4.5", "cookie-parser": "^1.4.5",
@ -35,6 +35,7 @@
"dotenv": "^8.2.0", "dotenv": "^8.2.0",
"express": "^4.17.1", "express": "^4.17.1",
"jsonwebtoken": "^8.5.1", "jsonwebtoken": "^8.5.1",
"libphonenumber-js": "^1.9.7",
"mysql": "^2.18.1", "mysql": "^2.18.1",
"pg": "^8.5.1", "pg": "^8.5.1",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",

View File

@ -1,4 +1,4 @@
import { validationMetadatasToSchemas } from 'class-validator-jsonschema'; import { validationMetadatasToSchemas } from '@odit/class-validator-jsonschema';
import consola from "consola"; import consola from "consola";
import fs from "fs"; import fs from "fs";
import "reflect-metadata"; import "reflect-metadata";

View File

@ -1,4 +1,5 @@
import { config as configDotenv } from 'dotenv'; import { config as configDotenv } from 'dotenv';
import { CountryCode } from 'libphonenumber-js';
import ValidatorJS from 'validator'; import ValidatorJS from 'validator';
configDotenv(); configDotenv();
@ -6,7 +7,7 @@ export const config = {
internal_port: parseInt(process.env.APP_PORT) || 4010, internal_port: parseInt(process.env.APP_PORT) || 4010,
development: process.env.NODE_ENV === "production", development: process.env.NODE_ENV === "production",
jwt_secret: process.env.JWT_SECRET || "secretjwtsecret", jwt_secret: process.env.JWT_SECRET || "secretjwtsecret",
phone_validation_countrycode: process.env.PHONE_COUNTRYCODE || "ZZ", phone_validation_countrycode: getPhoneCodeLocale(),
postalcode_validation_countrycode: getPostalCodeLocale(), postalcode_validation_countrycode: getPostalCodeLocale(),
version: process.env.VERSION || require('../package.json').version version: process.env.VERSION || require('../package.json').version
} }
@ -14,15 +15,12 @@ let errors = 0
if (typeof config.internal_port !== "number") { if (typeof config.internal_port !== "number") {
errors++ errors++
} }
if (typeof config.phone_validation_countrycode !== "string") {
errors++
}
if (config.phone_validation_countrycode.length !== 2) {
errors++
}
if (typeof config.development !== "boolean") { if (typeof config.development !== "boolean") {
errors++ errors++
} }
function getPhoneCodeLocale(): CountryCode {
return (process.env.PHONE_COUNTRYCODE as CountryCode);
}
function getPostalCodeLocale(): any { function getPostalCodeLocale(): any {
try { try {
const stringArray: String[] = ValidatorJS.isPostalCodeLocales; const stringArray: String[] = ValidatorJS.isPostalCodeLocales;

View File

@ -90,7 +90,7 @@ export class PermissionController {
if (oldPermission.id != permission.id) { if (oldPermission.id != permission.id) {
throw new PermissionIdsNotMatchingError(); throw new PermissionIdsNotMatchingError();
} }
let existingPermission = await this.permissionRepository.findOne({ target: permission.target, action: permission.action, principal: permission.principal }, { relations: ['principal'] }); let existingPermission = await this.permissionRepository.findOne({ target: permission.target, action: permission.action, principal: await permission.getPrincipal() }, { relations: ['principal'] });
if (existingPermission) { if (existingPermission) {
await this.remove(permission.id, true); await this.remove(permission.id, true);
return new ResponsePermission(existingPermission); return new ResponsePermission(existingPermission);

View File

@ -1,4 +1,4 @@
import { validationMetadatasToSchemas } from "class-validator-jsonschema"; import { validationMetadatasToSchemas } from "@odit/class-validator-jsonschema";
import express, { Application } from "express"; import express, { Application } from "express";
import path from 'path'; import path from 'path';
import { getMetadataArgsStorage } from "routing-controllers"; import { getMetadataArgsStorage } from "routing-controllers";

View File

@ -32,7 +32,6 @@ export class CreateAddress {
/** /**
* The new address's postal code. * The new address's postal code.
* This will get checked against the postal code syntax for the configured country. * This will get checked against the postal code syntax for the configured country.
* TODO: Implement the config option.
*/ */
@IsString() @IsString()
@IsNotEmpty() @IsNotEmpty()

View File

@ -11,7 +11,7 @@ import { CreateDonation } from './CreateDonation';
export class CreateDistanceDonation extends CreateDonation { export class CreateDistanceDonation extends CreateDonation {
/** /**
* The donation's associated runner. * The donation's associated runner's id.
* This is important to link the runner's distance ran to the donation. * This is important to link the runner's distance ran to the donation.
*/ */
@IsInt() @IsInt()

View File

@ -9,7 +9,7 @@ import { Donor } from '../../entities/Donor';
*/ */
export abstract class CreateDonation { export abstract class CreateDonation {
/** /**
* The donation's associated donor. * The donation's associated donor's id.
* This is important to link donations to donors. * This is important to link donations to donors.
*/ */
@IsInt() @IsInt()

View File

@ -1,7 +1,7 @@
import { IsEmail, IsInt, IsNotEmpty, IsOptional, IsPhoneNumber, IsString } from 'class-validator'; import { IsEmail, IsInt, IsNotEmpty, IsOptional, IsPhoneNumber, IsString } from 'class-validator';
import { getConnectionManager } from 'typeorm'; import { getConnectionManager } from 'typeorm';
import { config } from '../../../config'; import { config } from '../../../config';
import { AddressNotFoundError, AddressWrongTypeError } from '../../../errors/AddressErrors'; import { AddressNotFoundError } from '../../../errors/AddressErrors';
import { Address } from '../../entities/Address'; import { Address } from '../../entities/Address';
import { GroupContact } from '../../entities/GroupContact'; import { GroupContact } from '../../entities/GroupContact';
@ -31,8 +31,7 @@ export class CreateGroupContact {
lastname: string; lastname: string;
/** /**
* The new contact's address. * The new contact's address's id.
* Must be the address's id.
*/ */
@IsInt() @IsInt()
@IsOptional() @IsOptional()
@ -57,16 +56,10 @@ export class CreateGroupContact {
* Gets the new contact's address by it's id. * Gets the new contact's address by it's id.
*/ */
public async getAddress(): Promise<Address> { public async getAddress(): Promise<Address> {
if (this.address === undefined || this.address === null) { if (!this.address) { return null; }
return null; let address = await getConnectionManager().get().getRepository(Address).findOne({ id: this.address });
} if (!address) { throw new AddressNotFoundError; }
if (!isNaN(this.address)) { return address;
let address = await getConnectionManager().get().getRepository(Address).findOne({ id: this.address });
if (!address) { throw new AddressNotFoundError; }
return address;
}
throw new AddressWrongTypeError;
} }
/** /**

View File

@ -1,7 +1,7 @@
import { IsEmail, IsInt, IsNotEmpty, IsOptional, IsPhoneNumber, IsString } from 'class-validator'; import { IsEmail, IsInt, IsNotEmpty, IsOptional, IsPhoneNumber, IsString } from 'class-validator';
import { getConnectionManager } from 'typeorm'; import { getConnectionManager } from 'typeorm';
import { config } from '../../../config'; import { config } from '../../../config';
import { AddressNotFoundError, AddressWrongTypeError } from '../../../errors/AddressErrors'; import { AddressNotFoundError } from '../../../errors/AddressErrors';
import { Address } from '../../entities/Address'; import { Address } from '../../entities/Address';
/** /**
@ -47,26 +47,19 @@ export abstract class CreateParticipant {
email?: string; email?: string;
/** /**
* The new participant's address. * The new participant's address's id.
* Must be of type number (address id).
*/ */
@IsInt() @IsInt()
@IsOptional() @IsOptional()
address?: number; address?: number;
/** /**
* Gets the new participant's address by it's address. * Gets the new participant's address by it's id.
*/ */
public async getAddress(): Promise<Address> { public async getAddress(): Promise<Address> {
if (this.address === undefined || this.address === null) { if (!this.address) { return null; }
return null; let address = await getConnectionManager().get().getRepository(Address).findOne({ id: this.address });
} if (!address) { throw new AddressNotFoundError; }
if (!isNaN(this.address)) { return address;
let address = await getConnectionManager().get().getRepository(Address).findOne({ id: this.address });
if (!address) { throw new AddressNotFoundError; }
return address;
}
throw new AddressWrongTypeError;
} }
} }

View File

@ -9,7 +9,7 @@ import { RunnerCard } from '../../entities/RunnerCard';
*/ */
export class CreateRunnerCard { export class CreateRunnerCard {
/** /**
* The card's associated runner. * The card's associated runner's id.
*/ */
@IsInt() @IsInt()
@IsOptional() @IsOptional()

View File

@ -1,6 +1,6 @@
import { IsInt, IsNotEmpty, IsOptional, IsString } from 'class-validator'; import { IsInt, IsNotEmpty, IsOptional, IsString } from 'class-validator';
import { getConnectionManager } from 'typeorm'; import { getConnectionManager } from 'typeorm';
import { GroupContactNotFoundError, GroupContactWrongTypeError } from '../../../errors/GroupContactErrors'; import { GroupContactNotFoundError } from '../../../errors/GroupContactErrors';
import { GroupContact } from '../../entities/GroupContact'; import { GroupContact } from '../../entities/GroupContact';
/** /**
@ -15,7 +15,7 @@ export abstract class CreateRunnerGroup {
name: string; name: string;
/** /**
* The new group's contact. * The new group's contact's id.
* Optional * Optional
*/ */
@IsInt() @IsInt()
@ -26,15 +26,10 @@ export abstract class CreateRunnerGroup {
* Gets the new group's contact by it's id. * Gets the new group's contact by it's id.
*/ */
public async getContact(): Promise<GroupContact> { public async getContact(): Promise<GroupContact> {
if (this.contact === undefined || this.contact === null) { if (!this.contact) { return null; }
return null; let contact = await getConnectionManager().get().getRepository(GroupContact).findOne({ id: this.contact });
} if (!contact) { throw new GroupContactNotFoundError; }
if (!isNaN(this.contact)) { return contact;
let contact = await getConnectionManager().get().getRepository(GroupContact).findOne({ id: this.contact });
if (!contact) { throw new GroupContactNotFoundError; }
return contact;
}
throw new GroupContactWrongTypeError;
} }
} }

View File

@ -1,6 +1,6 @@
import { IsInt, IsOptional } from 'class-validator'; import { IsInt, IsOptional } from 'class-validator';
import { getConnectionManager } from 'typeorm'; import { getConnectionManager } from 'typeorm';
import { AddressNotFoundError, AddressWrongTypeError } from '../../../errors/AddressErrors'; import { AddressNotFoundError } from '../../../errors/AddressErrors';
import { Address } from '../../entities/Address'; import { Address } from '../../entities/Address';
import { RunnerOrganisation } from '../../entities/RunnerOrganisation'; import { RunnerOrganisation } from '../../entities/RunnerOrganisation';
import { CreateRunnerGroup } from './CreateRunnerGroup'; import { CreateRunnerGroup } from './CreateRunnerGroup';
@ -10,8 +10,7 @@ import { CreateRunnerGroup } from './CreateRunnerGroup';
*/ */
export class CreateRunnerOrganisation extends CreateRunnerGroup { export class CreateRunnerOrganisation extends CreateRunnerGroup {
/** /**
* The new organisation's address. * The new organisation's address's id.
* Must be of type number (address id).
*/ */
@IsInt() @IsInt()
@IsOptional() @IsOptional()
@ -21,16 +20,10 @@ export class CreateRunnerOrganisation extends CreateRunnerGroup {
* Gets the org's address by it's id. * Gets the org's address by it's id.
*/ */
public async getAddress(): Promise<Address> { public async getAddress(): Promise<Address> {
if (this.address === undefined || this.address === null) { if (!this.address) { return null; }
return null; let address = await getConnectionManager().get().getRepository(Address).findOne({ id: this.address });
} if (!address) { throw new AddressNotFoundError; }
if (!isNaN(this.address)) { return address;
let address = await getConnectionManager().get().getRepository(Address).findOne({ id: this.address });
if (!address) { throw new AddressNotFoundError; }
return address;
}
throw new AddressWrongTypeError;
} }
/** /**
@ -41,7 +34,7 @@ export class CreateRunnerOrganisation extends CreateRunnerGroup {
newRunnerOrganisation.name = this.name; newRunnerOrganisation.name = this.name;
newRunnerOrganisation.contact = await this.getContact(); newRunnerOrganisation.contact = await this.getContact();
// newRunnerOrganisation.address = await this.getAddress(); newRunnerOrganisation.address = await this.getAddress();
return newRunnerOrganisation; return newRunnerOrganisation;
} }

View File

@ -1,6 +1,6 @@
import { IsInt, IsNotEmpty } from 'class-validator'; import { IsInt, IsNotEmpty } from 'class-validator';
import { getConnectionManager } from 'typeorm'; import { getConnectionManager } from 'typeorm';
import { RunnerOrganisationNotFoundError, RunnerOrganisationWrongTypeError } from '../../../errors/RunnerOrganisationErrors'; import { RunnerOrganisationNotFoundError } from '../../../errors/RunnerOrganisationErrors';
import { RunnerTeamNeedsParentError } from '../../../errors/RunnerTeamErrors'; import { RunnerTeamNeedsParentError } from '../../../errors/RunnerTeamErrors';
import { RunnerOrganisation } from '../../entities/RunnerOrganisation'; import { RunnerOrganisation } from '../../entities/RunnerOrganisation';
import { RunnerTeam } from '../../entities/RunnerTeam'; import { RunnerTeam } from '../../entities/RunnerTeam';
@ -12,7 +12,7 @@ import { CreateRunnerGroup } from './CreateRunnerGroup';
export class CreateRunnerTeam extends CreateRunnerGroup { export class CreateRunnerTeam extends CreateRunnerGroup {
/** /**
* The new team's parent group (organisation). * The new team's parent org's id.
*/ */
@IsInt() @IsInt()
@IsNotEmpty() @IsNotEmpty()
@ -25,13 +25,9 @@ export class CreateRunnerTeam extends CreateRunnerGroup {
if (this.parentGroup === undefined || this.parentGroup === null) { if (this.parentGroup === undefined || this.parentGroup === null) {
throw new RunnerTeamNeedsParentError(); throw new RunnerTeamNeedsParentError();
} }
if (!isNaN(this.parentGroup)) { let parentGroup = await getConnectionManager().get().getRepository(RunnerOrganisation).findOne({ id: this.parentGroup });
let parentGroup = await getConnectionManager().get().getRepository(RunnerOrganisation).findOne({ id: this.parentGroup }); if (!parentGroup) { throw new RunnerOrganisationNotFoundError();; }
if (!parentGroup) { throw new RunnerOrganisationNotFoundError();; } return parentGroup;
return parentGroup;
}
throw new RunnerOrganisationWrongTypeError;
} }
/** /**
@ -42,7 +38,6 @@ export class CreateRunnerTeam extends CreateRunnerGroup {
newRunnerTeam.name = this.name; newRunnerTeam.name = this.name;
newRunnerTeam.parentGroup = await this.getParent(); newRunnerTeam.parentGroup = await this.getParent();
newRunnerTeam.contact = await this.getContact() newRunnerTeam.contact = await this.getContact()
return newRunnerTeam; return newRunnerTeam;

View File

@ -9,7 +9,7 @@ import { Scan } from '../../entities/Scan';
*/ */
export abstract class CreateScan { export abstract class CreateScan {
/** /**
* The scan's associated runner. * The scan's associated runner's id.
* This is important to link ran distances to runners. * This is important to link ran distances to runners.
*/ */
@IsInt() @IsInt()

View File

@ -19,7 +19,7 @@ export class CreateScanStation {
description?: string; description?: string;
/** /**
* The station's associated track. * The station's associated track's id.
*/ */
@IsInt() @IsInt()
@IsPositive() @IsPositive()

View File

@ -12,7 +12,7 @@ import { TrackScan } from '../../entities/TrackScan';
*/ */
export class CreateTrackScan { export class CreateTrackScan {
/** /**
* The runnerCard associated with the scan. * The id of the runnerCard associated with the scan.
* This get's saved for documentation and management purposes. * This get's saved for documentation and management purposes.
*/ */
@IsInt() @IsInt()
@ -20,8 +20,8 @@ export class CreateTrackScan {
card: number; card: number;
/** /**
* The scanning station that created the scan. * The scanning station's id that created the scan.
* Mainly used for logging and traceing back scans (or errors) * Mainly used for logging and traceing back scans (or errors).
*/ */
@IsInt() @IsInt()
@IsPositive() @IsPositive()

View File

@ -71,7 +71,7 @@ export class CreateUser {
enabled?: boolean = true; enabled?: boolean = true;
/** /**
* The new user's groups' id(s). * The new user's groups' ids.
* You can provide either one groupId or an array of groupIDs. * You can provide either one groupId or an array of groupIDs.
*/ */
@IsOptional() @IsOptional()

View File

@ -11,7 +11,7 @@ import { UpdateDonation } from './UpdateDonation';
export class UpdateDistanceDonation extends UpdateDonation { export class UpdateDistanceDonation extends UpdateDonation {
/** /**
* The donation's associated runner. * The donation's associated runner's id.
* This is important to link the runner's distance ran to the donation. * This is important to link the runner's distance ran to the donation.
*/ */
@IsInt() @IsInt()

View File

@ -16,7 +16,7 @@ export abstract class UpdateDonation {
id: number; id: number;
/** /**
* The updated donation's associated donor. * The updated donation's associated donor's id.
* This is important to link donations to donors. * This is important to link donations to donors.
*/ */
@IsInt() @IsInt()

View File

@ -1,7 +1,7 @@
import { IsInt, IsNotEmpty, IsObject } from 'class-validator'; import { IsInt, IsNotEmpty, IsPositive } from 'class-validator';
import { getConnectionManager } from 'typeorm'; import { getConnectionManager } from 'typeorm';
import { PermissionNeedsPrincipalError } from '../../../errors/PermissionErrors'; import { PermissionNeedsPrincipalError } from '../../../errors/PermissionErrors';
import { PrincipalNotFoundError, PrincipalWrongTypeError } from '../../../errors/PrincipalErrors'; import { PrincipalNotFoundError } from '../../../errors/PrincipalErrors';
import { Permission } from '../../entities/Permission'; import { Permission } from '../../entities/Permission';
import { Principal } from '../../entities/Principal'; import { Principal } from '../../entities/Principal';
import { PermissionAction } from '../../enums/PermissionAction'; import { PermissionAction } from '../../enums/PermissionAction';
@ -20,12 +20,11 @@ export class UpdatePermission {
id: number; id: number;
/** /**
* The updated permissions's principal. * The updated permissions's principal's id.
* Just has to contain the principal's id -everything else won't be checked or changed.
*/ */
@IsObject() @IsInt()
@IsNotEmpty() @IsPositive()
principal: Principal; principal: number;
/** /**
* The permissions's target. * The permissions's target.
@ -57,12 +56,8 @@ export class UpdatePermission {
if (this.principal === undefined || this.principal === null) { if (this.principal === undefined || this.principal === null) {
throw new PermissionNeedsPrincipalError(); throw new PermissionNeedsPrincipalError();
} }
if (!isNaN(this.principal.id)) { let principal = await getConnectionManager().get().getRepository(Principal).findOne({ id: this.principal });
let principal = await getConnectionManager().get().getRepository(Principal).findOne({ id: this.principal.id }); if (!principal) { throw new PrincipalNotFoundError(); }
if (!principal) { throw new PrincipalNotFoundError(); } return principal;
return principal;
}
throw new PrincipalWrongTypeError();
} }
} }

View File

@ -1,7 +1,6 @@
import { IsInt, IsObject } from 'class-validator'; import { IsInt, IsPositive } from 'class-validator';
import { getConnectionManager } from 'typeorm'; import { getConnectionManager } from 'typeorm';
import { RunnerGroupNotFoundError } from '../../../errors/RunnerGroupErrors'; import { RunnerGroupNotFoundError } from '../../../errors/RunnerGroupErrors';
import { RunnerOrganisationWrongTypeError } from '../../../errors/RunnerOrganisationErrors';
import { RunnerTeamNeedsParentError } from '../../../errors/RunnerTeamErrors'; import { RunnerTeamNeedsParentError } from '../../../errors/RunnerTeamErrors';
import { Runner } from '../../entities/Runner'; import { Runner } from '../../entities/Runner';
import { RunnerGroup } from '../../entities/RunnerGroup'; import { RunnerGroup } from '../../entities/RunnerGroup';
@ -20,11 +19,11 @@ export class UpdateRunner extends CreateParticipant {
id: number; id: number;
/** /**
* The updated runner's new team/org. * The updated runner's group's id.
* Just has to contain the group's id -everything else won't be checked or changed.
*/ */
@IsObject() @IsInt()
group: RunnerGroup; @IsPositive()
group: number;
/** /**
* Updates a provided Runner entity based on this. * Updates a provided Runner entity based on this.
@ -48,12 +47,8 @@ export class UpdateRunner extends CreateParticipant {
if (this.group === undefined || this.group === null) { if (this.group === undefined || this.group === null) {
throw new RunnerTeamNeedsParentError(); throw new RunnerTeamNeedsParentError();
} }
if (!isNaN(this.group.id)) { let group = await getConnectionManager().get().getRepository(RunnerGroup).findOne({ id: this.group });
let group = await getConnectionManager().get().getRepository(RunnerGroup).findOne({ id: this.group.id }); if (!group) { throw new RunnerGroupNotFoundError; }
if (!group) { throw new RunnerGroupNotFoundError; } return group;
return group;
}
throw new RunnerOrganisationWrongTypeError;
} }
} }

View File

@ -17,7 +17,7 @@ export class UpdateRunnerCard {
id?: number; id?: number;
/** /**
* The updated card's associated runner. * The updated card's associated runner's id.
*/ */
@IsInt() @IsInt()
@IsOptional() @IsOptional()

View File

@ -18,22 +18,18 @@ export class UpdateRunnerOrganisation extends CreateRunnerGroup {
id: number; id: number;
/** /**
* The updated organisation's address. * The updated organisation's address's id.
* Just has to contain the address's id - everything else won't be checked or changed.
* Optional.
*/ */
@IsInt() @IsInt()
@IsOptional() @IsOptional()
address?: Address; address?: number;
/** /**
* Loads the organisation's address based on it's id. * Loads the organisation's address based on it's id.
*/ */
public async getAddress(): Promise<Address> { public async getAddress(): Promise<Address> {
if (this.address === undefined || this.address === null) { if (!this.address) { return null; }
return null; let address = await getConnectionManager().get().getRepository(Address).findOne({ id: this.address });
}
let address = await getConnectionManager().get().getRepository(Address).findOne({ id: this.address.id });
if (!address) { throw new AddressNotFoundError; } if (!address) { throw new AddressNotFoundError; }
return address; return address;
} }
@ -45,7 +41,7 @@ export class UpdateRunnerOrganisation extends CreateRunnerGroup {
organisation.name = this.name; organisation.name = this.name;
organisation.contact = await this.getContact(); organisation.contact = await this.getContact();
// organisation.address = await this.getAddress(); organisation.address = await this.getAddress();
return organisation; return organisation;
} }

View File

@ -1,6 +1,6 @@
import { IsInt, IsNotEmpty, IsObject } from 'class-validator'; import { IsInt, IsPositive } from 'class-validator';
import { getConnectionManager } from 'typeorm'; import { getConnectionManager } from 'typeorm';
import { RunnerOrganisationNotFoundError, RunnerOrganisationWrongTypeError } from '../../../errors/RunnerOrganisationErrors'; import { RunnerOrganisationNotFoundError } from '../../../errors/RunnerOrganisationErrors';
import { RunnerTeamNeedsParentError } from '../../../errors/RunnerTeamErrors'; import { RunnerTeamNeedsParentError } from '../../../errors/RunnerTeamErrors';
import { RunnerOrganisation } from '../../entities/RunnerOrganisation'; import { RunnerOrganisation } from '../../entities/RunnerOrganisation';
import { RunnerTeam } from '../../entities/RunnerTeam'; import { RunnerTeam } from '../../entities/RunnerTeam';
@ -19,12 +19,11 @@ export class UpdateRunnerTeam extends CreateRunnerGroup {
id: number; id: number;
/** /**
* The updated team's parentGroup. * The updated team's parentGroup's id.
* Just has to contain the organisation's id - everything else won't be checked or changed.
*/ */
@IsObject() @IsInt()
@IsNotEmpty() @IsPositive()
parentGroup: RunnerOrganisation; parentGroup: number;
/** /**
* Loads the updated teams's parentGroup based on it's id. * Loads the updated teams's parentGroup based on it's id.
@ -33,13 +32,9 @@ export class UpdateRunnerTeam extends CreateRunnerGroup {
if (this.parentGroup === undefined || this.parentGroup === null) { if (this.parentGroup === undefined || this.parentGroup === null) {
throw new RunnerTeamNeedsParentError(); throw new RunnerTeamNeedsParentError();
} }
if (!isNaN(this.parentGroup.id)) { let parentGroup = await getConnectionManager().get().getRepository(RunnerOrganisation).findOne({ id: this.parentGroup });
let parentGroup = await getConnectionManager().get().getRepository(RunnerOrganisation).findOne({ id: this.parentGroup.id }); if (!parentGroup) { throw new RunnerOrganisationNotFoundError();; }
if (!parentGroup) { throw new RunnerOrganisationNotFoundError();; } return parentGroup;
return parentGroup;
}
throw new RunnerOrganisationWrongTypeError;
} }
/** /**

View File

@ -16,7 +16,7 @@ export abstract class UpdateScan {
id: number; id: number;
/** /**
* The updated scan's associated runner. * The updated scan's associated runner's id.
* This is important to link ran distances to runners. * This is important to link ran distances to runners.
*/ */
@IsInt() @IsInt()

View File

@ -1,4 +1,4 @@
import { IsBoolean, IsInt, IsOptional } from 'class-validator'; import { IsBoolean, IsInt, IsOptional, IsPositive } from 'class-validator';
import { getConnection } from 'typeorm'; import { getConnection } from 'typeorm';
import { RunnerNotFoundError } from '../../../errors/RunnerErrors'; import { RunnerNotFoundError } from '../../../errors/RunnerErrors';
import { ScanStationNotFoundError } from '../../../errors/ScanStationErrors'; import { ScanStationNotFoundError } from '../../../errors/ScanStationErrors';
@ -18,12 +18,12 @@ export abstract class UpdateTrackScan {
id: number; id: number;
/** /**
* The updated scan's associated runner. * The updated scan's associated runner's id.
* This is important to link ran distances to runners. * This is important to link ran distances to runners.
*/ */
@IsInt() @IsInt()
@IsOptional() @IsPositive()
runner?: number; runner: number;
/** /**
* Is the updated scan valid (for fraud reasons). * Is the updated scan valid (for fraud reasons).
@ -33,12 +33,12 @@ export abstract class UpdateTrackScan {
valid?: boolean = true; valid?: boolean = true;
/** /**
* The updated scan's associated station. * The updated scan's associated station's id.
* This is important to link ran distances to runners. * This is important to link ran distances to runners.
*/ */
@IsInt() @IsInt()
@IsOptional() @IsPositive()
public station?: number; public station: number;
/** /**
* Update a TrackScan entity based on this. * Update a TrackScan entity based on this.
@ -46,12 +46,8 @@ export abstract class UpdateTrackScan {
*/ */
public async update(scan: TrackScan): Promise<TrackScan> { public async update(scan: TrackScan): Promise<TrackScan> {
scan.valid = this.valid; scan.valid = this.valid;
if (this.runner) { scan.runner = await this.getRunner();
scan.runner = await this.getRunner(); scan.station = await this.getStation();
}
if (this.station) {
scan.station = await this.getStation();
}
scan.track = scan.station.track; scan.track = scan.station.track;
return scan; return scan;
@ -72,7 +68,7 @@ export abstract class UpdateTrackScan {
* Gets a runner based on the runner id provided via this.runner. * Gets a runner based on the runner id provided via this.runner.
*/ */
public async getStation(): Promise<ScanStation> { public async getStation(): Promise<ScanStation> {
const station = await getConnection().getRepository(ScanStation).findOne({ id: this.station }); const station = await getConnection().getRepository(ScanStation).findOne({ id: this.station }, { relations: ['track'] });
if (!station) { if (!station) {
throw new ScanStationNotFoundError(); throw new ScanStationNotFoundError();
} }

View File

@ -79,11 +79,10 @@ export class UpdateUser {
enabled: boolean = true; enabled: boolean = true;
/** /**
* The updated user's groups. * The updated user's groups' ids.
* This just has to contain the group's id - everything else won't be changed.
*/ */
@IsOptional() @IsOptional()
groups?: UserGroup[] groups?: number | number[]
/** /**
* The user's profile pic (or rather a url pointing to it). * The user's profile pic (or rather a url pointing to it).
@ -124,7 +123,7 @@ export class UpdateUser {
} }
/** /**
* Loads the updated user's groups based on their ids. * Get's all groups for this user by their id's;
*/ */
public async getGroups() { public async getGroups() {
if (!this.groups) { return null; } if (!this.groups) { return null; }
@ -133,7 +132,7 @@ export class UpdateUser {
this.groups = [this.groups] this.groups = [this.groups]
} }
for (let group of this.groups) { for (let group of this.groups) {
let found = await getConnectionManager().get().getRepository(UserGroup).findOne({ id: group.id }); let found = await getConnectionManager().get().getRepository(UserGroup).findOne({ id: group });
if (!found) { throw new UserGroupNotFoundError(); } if (!found) { throw new UserGroupNotFoundError(); }
groups.push(found); groups.push(found);
} }

View File

@ -34,7 +34,7 @@ describe('POST /api/donors with errors', () => {
"firstname": "first", "firstname": "first",
"middlename": "middle", "middlename": "middle",
"lastname": "last", "lastname": "last",
"address": 0 "address": 99999999999999999999999999
}, axios_config); }, axios_config);
expect(res2.status).toEqual(404); expect(res2.status).toEqual(404);
expect(res2.headers['content-type']).toContain("application/json") expect(res2.headers['content-type']).toContain("application/json")

View File

@ -43,7 +43,7 @@ describe('adding + updating name', () => {
"id": added_team_id, "id": added_team_id,
"name": "testlelele", "name": "testlelele",
"contact": null, "contact": null,
"parentGroup": added_org "parentGroup": added_org.id
}, axios_config); }, axios_config);
expect(res3.status).toEqual(200); expect(res3.status).toEqual(200);
expect(res3.headers['content-type']).toContain("application/json") expect(res3.headers['content-type']).toContain("application/json")
@ -79,6 +79,7 @@ describe('adding + try updating id (should return 406)', () => {
}); });
it('update team', async () => { it('update team', async () => {
added_team.id = added_team.id + 1; added_team.id = added_team.id + 1;
added_team.parentGroup = added_team.parentGroup.id;
const res3 = await axios.put(base + '/api/teams/' + added_team_id, added_team, axios_config); const res3 = await axios.put(base + '/api/teams/' + added_team_id, added_team, axios_config);
expect(res3.status).toEqual(406); expect(res3.status).toEqual(406);
expect(res3.headers['content-type']).toContain("application/json") expect(res3.headers['content-type']).toContain("application/json")
@ -117,7 +118,7 @@ describe('add+update parent org (valid)', () => {
expect(res3.headers['content-type']).toContain("application/json") expect(res3.headers['content-type']).toContain("application/json")
}); });
it('update team', async () => { it('update team', async () => {
added_team.parentGroup = added_org2; added_team.parentGroup = added_org2.id;
const res4 = await axios.put(base + '/api/teams/' + added_team_id, added_team, axios_config); const res4 = await axios.put(base + '/api/teams/' + added_team_id, added_team, axios_config);
let updated_team = res4.data; let updated_team = res4.data;
expect(res4.status).toEqual(200); expect(res4.status).toEqual(200);
@ -125,6 +126,6 @@ describe('add+update parent org (valid)', () => {
delete added_org2.address; delete added_org2.address;
delete added_org2.contact; delete added_org2.contact;
delete added_org2.teams; delete added_org2.teams;
expect(updated_team).toEqual(added_team) expect(updated_team.parentGroup).toEqual(added_org2)
}); });
}); });

View File

@ -15,15 +15,14 @@ beforeAll(async () => {
}); });
describe('Update runner name after adding', () => { describe('Update runner name after adding', () => {
let added_org_id; let added_org;
let added_runner; let added_runner;
let updated_runner; let updated_runner;
it('creating a new org with just a name should return 200', async () => { it('creating a new org with just a name should return 200', async () => {
const res1 = await axios.post(base + '/api/organisations', { const res1 = await axios.post(base + '/api/organisations', {
"name": "test123" "name": "test123"
}, axios_config); }, axios_config);
let added_org = res1.data added_org = res1.data
added_org_id = added_org.id;
expect(res1.status).toEqual(200); expect(res1.status).toEqual(200);
expect(res1.headers['content-type']).toContain("application/json") expect(res1.headers['content-type']).toContain("application/json")
}); });
@ -31,7 +30,7 @@ describe('Update runner name after adding', () => {
const res2 = await axios.post(base + '/api/runners', { const res2 = await axios.post(base + '/api/runners', {
"firstname": "first", "firstname": "first",
"lastname": "last", "lastname": "last",
"group": added_org_id "group": added_org.id
}, axios_config); }, axios_config);
added_runner = res2.data; added_runner = res2.data;
expect(res2.status).toEqual(200); expect(res2.status).toEqual(200);
@ -40,10 +39,15 @@ describe('Update runner name after adding', () => {
it('valid update should return 200', async () => { it('valid update should return 200', async () => {
let runnercopy = added_runner let runnercopy = added_runner
runnercopy.firstname = "second" runnercopy.firstname = "second"
runnercopy.group = added_runner.group.id;
const res3 = await axios.put(base + '/api/runners/' + added_runner.id, runnercopy, axios_config); const res3 = await axios.put(base + '/api/runners/' + added_runner.id, runnercopy, axios_config);
expect(res3.status).toEqual(200); expect(res3.status).toEqual(200);
expect(res3.headers['content-type']).toContain("application/json") expect(res3.headers['content-type']).toContain("application/json")
updated_runner = res3.data updated_runner = res3.data;
delete added_org.address;
delete added_org.contact;
delete added_org.teams;
runnercopy.group = added_org;
expect(updated_runner).toEqual(runnercopy); expect(updated_runner).toEqual(runnercopy);
}); });
}); });
@ -83,13 +87,13 @@ describe('Update runner group after adding', () => {
expect(res3.status).toEqual(200); expect(res3.status).toEqual(200);
expect(res3.headers['content-type']).toContain("application/json") expect(res3.headers['content-type']).toContain("application/json")
}); });
it('valid update should return 200', async () => { it('valid group update should return 200', async () => {
added_runner.group = added_org_2; added_runner.group = added_org_2.id;
const res3 = await axios.put(base + '/api/runners/' + added_runner.id, added_runner, axios_config); const res3 = await axios.put(base + '/api/runners/' + added_runner.id, added_runner, axios_config);
expect(res3.status).toEqual(200); expect(res3.status).toEqual(200);
expect(res3.headers['content-type']).toContain("application/json") expect(res3.headers['content-type']).toContain("application/json")
updated_runner = res3.data updated_runner = res3.data
expect(updated_runner).toEqual(added_runner); expect(updated_runner.group).toEqual(added_org_2);
}); });
}); });
// --------------- // ---------------
@ -119,6 +123,7 @@ describe('Update runner id after adding(should fail)', () => {
}); });
it('invalid update should return 406', async () => { it('invalid update should return 406', async () => {
added_runner.id++; added_runner.id++;
added_runner.group = added_runner.group.id;
const res3 = await axios.put(base + '/api/runners/' + added_runner_id, added_runner, axios_config); const res3 = await axios.put(base + '/api/runners/' + added_runner_id, added_runner, axios_config);
expect(res3.status).toEqual(406); expect(res3.status).toEqual(406);
expect(res3.headers['content-type']).toContain("application/json") expect(res3.headers['content-type']).toContain("application/json")
@ -146,9 +151,8 @@ describe('Update runner group with invalid group after adding', () => {
expect(res2.status).toEqual(200); expect(res2.status).toEqual(200);
expect(res2.headers['content-type']).toContain("application/json") expect(res2.headers['content-type']).toContain("application/json")
}); });
it('invalid update should return 404', async () => { it('invalid group update should return 404', async () => {
added_org.id = 0; added_runner.group = 99999999999999999;
added_runner.group = added_org;
const res3 = await axios.put(base + '/api/runners/' + added_runner.id, added_runner, axios_config); const res3 = await axios.put(base + '/api/runners/' + added_runner.id, added_runner, axios_config);
expect(res3.status).toEqual(404); expect(res3.status).toEqual(404);
expect(res3.headers['content-type']).toContain("application/json") expect(res3.headers['content-type']).toContain("application/json")