Skip to content

Commit

Permalink
Intentando eliminar securityHospots y código duplicado
Browse files Browse the repository at this point in the history
  • Loading branch information
baraganio committed Apr 27, 2024
1 parent 7289f7d commit 6116650
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
7 changes: 3 additions & 4 deletions users/authservice/auth-service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@ let app;
//test user
const user = {
username: 'testuser',
password: 'testpassword',
password: 'a8d4Ae6_Ws',
};

const user2 = {
username: 'testuser',
password: 'wrongpass',
password: 'md32_sU634',
};

async function addUser(user){
const hashedPassword = await bcrypt.hash(user.password, 10);
const newUser = new User({
username: user.username,
password: hashedPassword,
password: await bcrypt.hash(user.password, 10),
});

await newUser.save();
Expand Down
10 changes: 5 additions & 5 deletions users/userservice/user-service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ let mongoServer;
let app;

const user = {
username: 'testuser',
password: 'testpassword',
username: 'usernameTest1',
password: 'Egw23_f8',
};

async function addUser(user){
Expand Down Expand Up @@ -42,14 +42,14 @@ describe('User Service', () => {
const response = await request(app).get('/getregisteredusers');
expect(response.status).toBe(200);
expect(response.body.length).toBe(1);
expect(Array.from(response.body[0])[0]).toBe('testuser');
expect(Array.from(response.body[0])[0]).toBe('usernameTest1');
});

//
it('should add a new user on POST /adduser', async () => {
const newUser = {
username: 'testuser2',
password: 'testpassword2',
password: 'aUf54_f',
};

const response = await request(app).post('/adduser').send(newUser);
Expand All @@ -60,7 +60,7 @@ describe('User Service', () => {
//
it('trying to add a user without username', async () => {
const newUser = {
password: 'testpassword',
password: 'emcio74_ws',
};

const response = (await request(app).post('/adduser').send(newUser));
Expand Down

0 comments on commit 6116650

Please sign in to comment.