Remove the unsafe user api

This commit is contained in:
2023-05-28 14:44:57 +09:00
parent 93ae411ebe
commit 2838beae12
4 changed files with 8 additions and 46 deletions
+2 -26
View File
@@ -1,31 +1,12 @@
import {
Controller,
Get,
Post,
Body,
Param,
Delete,
NotFoundException,
} from '@nestjs/common';
import { Controller, Get, Param, NotFoundException } from '@nestjs/common';
import { UsersService } from './users.service';
import { SettingsService } from 'src/settings/settings.service';
import { CreateUserDto } from './dto/create-user.dto';
import { ApiNotFoundResponse, ApiTags } from '@nestjs/swagger';
import { User } from 'src/models/user';
import { resolve } from 'path';
@ApiTags('users')
@Controller('users')
export class UsersController {
constructor(private readonly usersService: UsersService, private readonly settingsService: SettingsService) {}
@Post()
create(@Body() createUserDto: CreateUserDto): Promise<User> {
return this.usersService.createUser(createUserDto).then((user) => {
this.settingsService.createUserSetting(user.id);
return user;
}).catch((e) => e);
}
constructor(private readonly usersService: UsersService) {}
@Get()
findAll(): Promise<User[]> {
@@ -39,9 +20,4 @@ export class UsersController {
if (!ret) throw new NotFoundException();
return ret;
}
@Delete(':id')
remove(@Param('id') id: string): Promise<User> {
return this.usersService.deleteUser({ id: +id });
}
}
+4 -4
View File
@@ -34,7 +34,7 @@ Create and get an history record
Integer $[0].songID ${song.body.id}
Integer $[0].score 55
[Teardown] Run Keywords DELETE /users/${userID}
[Teardown] Run Keywords DELETE /auth/me
... AND DELETE /song/${song.body.id}
Create and get a duplicated history record
@@ -68,7 +68,7 @@ Create and get a duplicated history record
Integer $[1].songID ${song.body.id}
Integer $[1].score 55
[Teardown] Run Keywords DELETE /users/${userID}
[Teardown] Run Keywords DELETE /auth/me
... AND DELETE /song/${song.body.id}
Create and get a search history record
@@ -95,7 +95,7 @@ Create and get a search history record
${len}= Get Length ${res.body}
Should Be Equal As Integers ${len} 1
[Teardown] DELETE /users/${userID}
[Teardown] DELETE /auth/me
Get the history of a single song
[Documentation] Create an history item
@@ -137,6 +137,6 @@ Get the history of a single song
Integer $.history[1].score 55
Integer $.best 65
[Teardown] Run Keywords DELETE /users/${userID}
[Teardown] Run Keywords DELETE /auth/me
... AND DELETE /song/${song.body.id}
... AND DELETE /song/${song2.body.id}
+2 -2
View File
@@ -14,7 +14,7 @@ Get settings
Output
Should Be True ${get.body.emailNotification}
Integer response status 200
[Teardown] DELETE /users/${userID}
[Teardown] DELETE /auth/me
Patch settingspushNotification
${userID}= RegisterLogin 2na-min-faranssa-wa-2na-adrus-allu3'at-al3rabia
@@ -24,4 +24,4 @@ Patch settingspushNotification
Output
Should Not Be True ${patch.body.leaderBoard}
Integer response status 200
[Teardown] DELETE /users/${userID}
[Teardown] DELETE /auth/me
-14
View File
@@ -1,14 +0,0 @@
*** Settings ***
Documentation Tests of the /users route.
... Ensures that the users CRUD works corectly.
Resource ../rest.resource
*** Test Cases ***
Create a user
[Documentation] Create a user
&{res}= POST /users {"username": "louis-boufon", "password": "pass", "email": "wow@gmail.com"}
Output
Integer response status 201
[Teardown] DELETE /users/${res.body.id}