-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#187419063- Build Rest End Points for ROLE #19
Conversation
src/__test__/role.test.ts
Outdated
@@ -0,0 +1,185 @@ | |||
import app from "../app"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
7fdce1f
to
4089153
Compare
@@ -0,0 +1,98 @@ | |||
import { Request, Response } from "express"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
"use strict"; | ||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
async up(queryInterface, Sequelize) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: Unexpected token up
import { DataTypes, Model, Optional, UUIDV4 } from "sequelize"; | ||
import { sequelizeConnection } from "../config/db.config"; | ||
|
||
import { DataTypes, Model, Optional, Sequelize, UUIDV4 } from "sequelize"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
src/documention/role/index.ts
Outdated
responses, | ||
}, | ||
}, | ||
"/roles/{id}": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
await queryInterface.bulkInsert( | ||
"users", | ||
[ | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 3 locations. Consider refactoring.
createdAt: new Date(), | ||
updatedAt: new Date(), | ||
}, | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 3 locations. Consider refactoring.
createdAt: new Date(), | ||
updatedAt: new Date(), | ||
}, | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 3 locations. Consider refactoring.
import { NextFunction, Request, Response } from "express"; | ||
import { HttpException } from "../utils/http.exception"; | ||
|
||
export const roleNameValid = async ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
4089153
to
23c9398
Compare
@@ -0,0 +1,10 @@ | |||
import { Sequelize } from "sequelize"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
@@ -0,0 +1,35 @@ | |||
import { DataTypes, Sequelize, Model, Optional, UUIDV4 } from "sequelize"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
|
||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
async up(queryInterface) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: Unexpected token up
@@ -0,0 +1,58 @@ | |||
const bcrypt = require("bcrypt"); | |||
const hashPassword = async (password) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: Unexpected token =>
@@ -0,0 +1,100 @@ | |||
import { responses } from "../responses"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
@@ -0,0 +1,64 @@ | |||
import { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
@@ -0,0 +1,18 @@ | |||
import { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
@@ -0,0 +1,25 @@ | |||
import Joi from "joi"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
expect(body.message).toStrictEqual("Please Login Again"); | ||
}); | ||
|
||
it("it should return Invalid token and return 403 ", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
} | ||
}; | ||
|
||
export const roleIdValidations = async ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
} from "../mock/static"; | ||
const role = database_models["role"]; | ||
jest.setTimeout(30000); | ||
function logErrors( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
UserId?: JwtPayload; | ||
} | ||
|
||
function logErrors( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
src/documention/role/index.ts
Outdated
responses, | ||
}, | ||
}, | ||
"/users/{userId}/roles": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
23c9398
to
382514f
Compare
|
||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
async up(queryInterface, Sequelize) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing error: Unexpected token up
UserId?: JwtPayload; | ||
} | ||
|
||
function logErrors( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 3 locations. Consider refactoring.
// await deleteTableData(database_models.role, "roles"); | ||
}); | ||
|
||
it("it should register a user and return 201", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
expect(body.message).toStrictEqual("Role assigned successfully!"); | ||
}); | ||
|
||
it("it should return please login and return 401 ", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
expect(body.status).toStrictEqual(409); | ||
}); | ||
|
||
it("it should return role not found and return 404 ", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
expect(body.message).toStrictEqual("role not found"); | ||
}); | ||
|
||
it("it should assign user to role and return 201 ", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
Code Climate has analyzed commit 382514f and detected 19 issues on this pull request. Here's the issue category breakdown:
The test coverage on the diff in this pull request is 91.1% (60% is the threshold). This pull request will bring the total coverage in the repository to 91.2% (0.0% change). View more on Code Climate. |
What does this PR do?
Admin should be able to assign various users to various roles
Description of Task to be completed?
having following endpoints working
-POST api/v1/roles
-POST api/v1/users/:userId/roles
-PATCH api/v1/roles/:id
-DELETE api/v1/roles/:id
How should this be manually tested?
Using Postman test every endpoint above with this header:
key: Content-Type value: application/json
To test authentication, add this to the header: Get TOKEN from login endpoint
key: Authorization value: JWT TOKEN