Skip to content
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

Fase 2 del proyecto #1

Merged
merged 25 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ba337ff
Merge branch 'main' into develop
Tiwue Oct 18, 2024
786696c
[ADD] Se agregó la funcionalidad de favoritos
robinbuezo11 Oct 22, 2024
d4e1f42
Merge branch 'Feat/Favoritos_201944994' into develop
robinbuezo11 Oct 22, 2024
83f948f
[ADD] Se agregó la funcionalidad de compartir archivos - 201903974
Tiwue Oct 22, 2024
3f45a43
Merge branch 'develop' into Feature/CompartirArchivos_201903974
Tiwue Oct 22, 2024
d572042
[ADD] Se agregó ocultar/mostrar botón Shared en sidebar - 201903974
Tiwue Oct 22, 2024
ba32c2e
[ADD] Visualización de tooltip para ver si un archivo se comparte
Tiwue Oct 22, 2024
e9d319a
[ADD] Se agrego el visualizador de archivos
MaxDuran08 Oct 23, 2024
9939b79
Merge branch 'Freature/PrevisualizacionArchivos_201902219' into develop
MaxDuran08 Oct 23, 2024
c3c85fe
[ADD] se agregó funcionalidad para dejar de compartir archivos
Tiwue Oct 23, 2024
89dd676
[ADD] se agregó funcionalidad para enviar correo al compartir items
Tiwue Oct 23, 2024
b55fcf7
Merge branch 'develop' into Feature/CompartirArchivos_201903974
Tiwue Oct 23, 2024
582bbc3
Merge branch 'Feature/CompartirArchivos_201903974' into develop
Tiwue Oct 23, 2024
353da96
[FIX] se corrige bug al visualizar despues de subir un archivo
Tiwue Oct 23, 2024
87373b4
Merge branch 'Feature/CompartirArchivos_201903974' into develop
Tiwue Oct 23, 2024
9fee741
[UPDATE] Tests
Tiwue Oct 24, 2024
3616ca2
Merge branch 'Feature/CompartirArchivos_201903974' into develop
Tiwue Oct 24, 2024
2d791f7
[ADD] Se agregó etiquetado de carpetas
bryan967132 Oct 24, 2024
a233e88
Merge branch 'Feature/FolderTags_201908355' into develop
bryan967132 Oct 24, 2024
6971b61
[ADD] Se agregó vista de detalles de archivos y carpetas
bryan967132 Oct 24, 2024
d60e444
Merge branch 'Feature/DetallesFolderArchivos_201908355' into develop
bryan967132 Oct 24, 2024
bd7c8f4
[ADD] se agrega pipeline para cicd de backend - 201903974
Tiwue Oct 25, 2024
d2759d1
Merge branch 'Feature/pipeline-backend-201903974' into develop
Tiwue Oct 25, 2024
4458053
[ADD] se agrega dockerfile y dockerignore para dockerizar backend
Tiwue Oct 25, 2024
879bfa8
[FIX] Se corrige error al abrir dialogo de detalles
Tiwue Oct 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/cicd-backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: CI/CD Pipeline backend

on:
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: '18'

- name: Set environment variables
run: |
cd ./backend
echo "HOST=${{ secrets.HOST }}" >> .env
echo "PORT=${{ secrets.PORT }}" >> .env
echo "DB_HOST=${{ secrets.DB_HOST }}" >> .env
echo "DB_PORT=${{ secrets.DB_PORT }}" >> .env
echo "DB_NAME=${{ secrets.DB_NAME }}" >> .env
echo "DB_USER=${{ secrets.DB_USER }}" >> .env
echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" >> .env
echo "ACCESS_KEY_ID=${{ secrets.ACCESS_KEY_ID }}" >> .env
echo "SECRET_ACCESS_KEY=${{ secrets.SECRET_ACCESS_KEY }}" >> .env
echo "REGION=${{ secrets.REGION }}" >> .env
echo "BUCKET=${{ secrets.BUCKET }}" >> .env
echo "FRONT_URL=${{ secrets.FRONT_URL }}" >> .env
echo "EMAIL_ORIGIN=${{ secrets.EMAIL_ORIGIN }}" >> .env
echo "APP_KEY=${{ secrets.APP_KEY }}" >> .env
echo "EMAIL_HOST=${{ secrets.EMAIL_HOST }}" >> .env
echo "REACT_APP_API_HOST=${{ secrets.REACT_APP_API_HOST }}" >> .env

- name: Install dependencies
run: |
cd ./backend
npm install

- name: Run tests
run: |
cd ./backend
npm test

- name: Log in to DockerHub
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin

- name: Build and push Docker image
run: |
cd ./backend
docker build -t ${{ secrets.DOCKER_USERNAME }}/backend-ayd-image:latest .
docker push ${{ secrets.DOCKER_USERNAME }}/backend-ayd-image:latest

deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Run deployment script via SSH
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_KEY }}
script: |
docker pull ${{ secrets.DOCKER_USERNAME }}/backend-ayd-image:latest
docker stop backend-ayd-container || true
docker rm backend-ayd-container || true
docker run -d --name backend-ayd-container --env-file /home/ubuntu/ayd/AyD1S2-Proyecto_F1_9/backend/.env -p ${{ secrets.PORT }}:4000 ${{ secrets.DOCKER_USERNAME }}/backend-ayd-image:latest
13 changes: 13 additions & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Ignorar dependencias instaladas
node_modules

# Ignorar archivos de pruebas
**/*.test.mjs
**/*.spec.mjs
__tests__/

# Ignorar archivos de configuración y caché
.env
npm-debug.log
yarn-debug.log
yarn-error.log
20 changes: 20 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Usa una imagen base de Node.js
FROM node:18

# Establece el directorio de trabajo en el contenedor
WORKDIR /app

# Copia el archivo package.json y package-lock.json
COPY package*.json ./

# Instala las dependencias de la aplicación
RUN npm install

# Copia el resto del código de la aplicación
COPY . .

# Expone el puerto en el que la aplicación escucha
EXPOSE 4000

# Comando para ejecutar la aplicación
CMD ["npm", "start"]
10 changes: 0 additions & 10 deletions backend/__tests__/changeStorageRequest.test.js

This file was deleted.

10 changes: 5 additions & 5 deletions backend/__tests__/files.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import request from 'supertest';
import app from '../server.mjs'; // Puedes seguir usando import para tus módulos
import app from '../index.test.mjs'; // Puedes seguir usando import para tus módulos

test('POST /uploadFile, debe retornar un atributo status=200, file', async () => {
const res = await request(app).post('/uploadFile').send({
idUser: 2,
username: 'tiky',
username: 'test',
folder: 1,
file: {
name: 'test.txt',
Expand All @@ -22,11 +22,11 @@ import app from '../server.mjs'; // Puedes seguir usando import para tus módulo
test('POST /createFolder, debe retornar un atributo status=200, y el id del folder', async () => {
const res = await request(app).post('/createFolder').send({
idUser: 2,
username: 'tiky',
username: 'test',
parentFolder: 1,
name: 'test'
name: 'test folder'
});
expect(res.status).toBe(200);
expect(res.body).toHaveProperty('status', 200);
expect(res.body).toHaveProperty('file');
expect(res.body).toHaveProperty('folder');
}, 30000); // 30 segundos de timeout
4 changes: 2 additions & 2 deletions backend/__tests__/profile.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import request from 'supertest'
import app from '../server.mjs'
import app from '../index.test.mjs'

test('POST /uploadProfile, debe retornar un atributo status=200, icon, message', async () => {
const res = await request(app).post('/uploadProfile').send({ ID_USUARIO: 2, changes: {NOMBRE: 'John', APELLIDO: 'Connor'}})
const res = await request(app).post('/uploadProfile').send({ ID_USUARIO: 2, changes: {NOMBRE: 'Steven', APELLIDO: 'Gonzalez'}})
expect(res.status).toBe(200);
expect(res.body).toHaveProperty('status', 200);
expect(res.body).toHaveProperty('icon');
Expand Down
10 changes: 0 additions & 10 deletions backend/__tests__/registerDeleteAccountRquest.test.js

This file was deleted.

68 changes: 68 additions & 0 deletions backend/__tests__/share.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import request from 'supertest';
import app from '../index.test.mjs';

describe('Share items tests', () => {

test('POST /shareItem should share a file successfully', async () => {
const res = await request(app).post('/shareItem').send({
currentUserId: 2, // Propietario
userIdentifier: '[email protected]', // Destinatario
idFile: 1, // Suponemos un archivo con ID 1
type: 'file'
});
expect(res.status).toBe(200);
expect(res.body).toHaveProperty('status', 200);
expect(res.body).toHaveProperty('message', 'File shared successfully');
});

test('POST /shareItem should return 400 when trying to share with oneself', async () => {
const res = await request(app).post('/shareItem').send({
currentUserId: 2, // Propietario
userIdentifier: '[email protected]', // Mismo usuario que el propietario
idFile: 1,
type: 'file'
});
expect(res.status).toBe(400);
expect(res.body).toHaveProperty('message', 'You cannot share the file with yourself');
});

test('POST /getSharedWithMeItems should return shared items for user', async () => {
const res = await request(app).post('/getSharedWithMeItems').send({
idUsuario: 3, // Destinatario
});
expect(res.status).toBe(200);
expect(res.body).toHaveProperty('status', 200);
expect(res.body).toHaveProperty('children');
});

test('POST /showSharedIconInSideBar should return icon visibility for shared items', async () => {
const res = await request(app).post('/showSharedIconInSideBar').send({
idUsuario: 3, // Destinatario
});
expect(res.status).toBe(200);
expect(res.body).toHaveProperty('status', 200);
expect(res.body).toHaveProperty('icon');
});

test('POST /getUsersWithItemShared should return users with whom the file is shared', async () => {
const res = await request(app).post('/getUsersWithItemShared').send({
idItem: 1, // Suponemos un archivo con ID 1
type: 'file'
});
expect(res.status).toBe(200);
expect(res.body).toHaveProperty('status', 200);
expect(res.body).toHaveProperty('users');
});

test('POST /stopSharing should unshare the file', async () => {
const res = await request(app).post('/stopSharing').send({
idItem: 1, // Archivo con ID 1
type: 'file',
idUser: 3, // Destinatario
});
expect(res.status).toBe(200);
expect(res.body).toHaveProperty('status', 200);
expect(res.body).toHaveProperty('message', 'File unshared successfully');
});

});
9 changes: 2 additions & 7 deletions backend/__tests__/storage.test.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import request from 'supertest';
import app from '../server.mjs'; // Puedes seguir usando import para tus módulos
import app from '../index.test.mjs'; // Puedes seguir usando import para tus módulos

test('POST /getStorage debería devolver un json con los tributos status:200, used, total', async () => {
const res = await request(app).post('/getStorage').send({ username: 'tiky' });
const res = await request(app).post('/getStorage').send({ username: 'test' });
expect(res.status).toBe(200);
expect(res.body).toHaveProperty('status', 200);
expect(res.body).toHaveProperty('used');
expect(res.body).toHaveProperty('total');
});

test('POST /getStorage debería retornar status 400 ya que los parametros estan nulos', async () => {
const res = await request(app).post('/getStorage').send({ username: undefined });
expect(res.status).toBe(400);
expect(res.body).toHaveProperty('message', 'User ID is required to get storage used');
});
10 changes: 0 additions & 10 deletions backend/__tests__/user.test.js

This file was deleted.

Loading
Loading