Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #246 from Arquisoft/develop
Browse files Browse the repository at this point in the history
Push dev to prod
  • Loading branch information
Manueluz authored Apr 25, 2024
2 parents d46d92d + 5536ff3 commit 88d9953
Show file tree
Hide file tree
Showing 104 changed files with 21,596 additions and 1,589 deletions.
139 changes: 139 additions & 0 deletions .codescene/code-health-rules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
{
"usage" : "Persist this file inside your repositories as .codescene/code-health-rules.json Keep the rules you want to override, remove the rest for simplicity and an easy overview.Override the code health rules by changing the default 1.0 value to a lower relative weight. A value of 0.0 disables the rule. A value of 0.5 still implies a code health hit but only at 50% of the default impact. Note that you can specify multiple rule sets and use the matching-content-path to control to which parts or languages the rules apply. This makes it possible to differentiate between test vs application code, or tailor rules to specific languages. In case multiple rule sets match a piece of content, then we prioritize the first mathcing set of rules.",
"rule_sets" : [ {
"thresholds" : [ {
"name" : "constructor_max_arguments",
"value" : "-"
}, {
"name" : "file_lines_of_code_for_alert",
"value" : "-"
}, {
"name" : "file_lines_of_code_for_critical_alert",
"value" : "-"
}, {
"name" : "file_lines_of_code_for_warning",
"value" : "-"
}, {
"name" : "file_mean_cyclomatic_complexity_warning",
"value" : "-"
}, {
"name" : "file_primitive_obsession_percentage_for_warning",
"value" : "-"
}, {
"name" : "function_bumpy_road_bumps_for_warning",
"value" : "-"
}, {
"name" : "function_bumpy_road_nesting_level_depth",
"value" : "-"
}, {
"name" : "function_complex_conditional_branches_alert",
"value" : "-"
}, {
"name" : "function_complex_conditional_branches_warning",
"value" : "-"
}, {
"name" : "function_cyclomatic_complexity_alert",
"value" : "-"
}, {
"name" : "function_cyclomatic_complexity_warning",
"value" : "-"
}, {
"name" : "function_embedded_content_lines_of_code_alert",
"value" : "-"
}, {
"name" : "function_embedded_content_lines_of_code_warning",
"value" : "-"
}, {
"name" : "function_lines_of_code_alert",
"value" : "-"
}, {
"name" : "function_lines_of_code_warning",
"value" : "-"
}, {
"name" : "function_max_arguments",
"value" : "-"
}, {
"name" : "function_nesting_depth_warning",
"value" : "-"
}, {
"name" : "unit_test_consecutive_asserts_for_large_block",
"value" : "-"
}, {
"name" : "unit_test_suite_number_of_large_assertion_blocks",
"value" : "-"
} ],
"thresholds_doc" : "The thresholds let you redefine the details of the code health issues. For example, specifying what a Complex Method means to you. Be restrictive with overrides.",
"matching_content_path" : "**/*",
"matching_content_path_doc" : "Specify a glob pattern relative to this repo root. **/* means all code, **/*.js means just JavaScript, test/** means all code in a top-level test folder.",
"rules" : [ {
"name" : "Brain Method",
"weight" : 1.0
}, {
"name" : "Bumpy Road Ahead",
"weight" : 1.0
}, {
"name" : "Code Duplication",
"weight" : 1.0
}, {
"name" : "Complex Conditional",
"weight" : 1.0
}, {
"name" : "Complex Method",
"weight" : 1.0
}, {
"name" : "Constructor Over-Injection",
"weight" : 1.0
}, {
"name" : "Deep, Global Nested Complexity",
"weight" : 1.0
}, {
"name" : "Deep, Nested Complexity",
"weight" : 1.0
}, {
"name" : "Duplicated Assertion Blocks",
"weight" : 1.0
}, {
"name" : "Excess Number of Function Arguments",
"weight" : 1.0
}, {
"name" : "Global Conditionals",
"weight" : 1.0
}, {
"name" : "Large Assertion Blocks",
"weight" : 1.0
}, {
"name" : "Large Embedded Code Block",
"weight" : 1.0
}, {
"name" : "Large Method",
"weight" : 100.0
}, {
"name" : "Lines of Code in a Single File",
"weight" : 1.0
}, {
"name" : "Lines of Declarations in a Single File",
"weight" : 1.0
}, {
"name" : "Low Cohesion",
"weight" : 1.0
}, {
"name" : "Missing Arguments Abstractions",
"weight" : 1.0
}, {
"name" : "Number of Functions in a Single Module",
"weight" : 1.0
}, {
"name" : "Overall Code Complexity",
"weight" : 1.0
}, {
"name" : "Overall Function Size",
"weight" : 1.0
}, {
"name" : "Primitive Obsession",
"weight" : 1.0
}, {
"name" : "String Heavy Function Arguments",
"weight" : 1.0
} ]
} ]
}
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ jobs:
- run: npm --prefix auth_service ci
- run: npm --prefix webapp ci
- run: npm --prefix game_service ci
- run: npm --prefix friends_service ci
- run: npm --prefix userdetails_service test -- --coverage
- run: npm --prefix question_service test -- --coverage
- run: npm --prefix auth_service test
- run: npm --prefix webapp test -- --coverage
- run: npm --prefix game_service test -- --coverage
- run: npm --prefix friends_service test -- --coverage
- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@master
env:
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ jobs:
- run: npm --prefix auth_service ci
- run: npm --prefix webapp ci
- run: npm --prefix game_service ci
- run: npm --prefix friends_service ci
- run: npm --prefix userdetails_service test -- --coverage
- run: npm --prefix question_service test -- --coverage
- run: npm --prefix auth_service test
- run: npm --prefix webapp test -- --coverage
- run: npm --prefix game_service test -- --coverage
- run: npm --prefix friends_service test -- --coverage
- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@master
env:
Expand Down Expand Up @@ -76,6 +78,23 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: userdetails_service
docker-push-friends:
name: Push friends service Docker Image to GitHub Packages
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: [unit-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: arquisoft/wiq_es1c/friends
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: friends_service
docker-push-game:
name: Push game service Docker Image to GitHub Packages
runs-on: ubuntu-latest
Expand Down Expand Up @@ -139,6 +158,15 @@ jobs:
user: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_KEY }}
command: |
mkdir grafana
mkdir grafana/provisioning
mkdir grafana/provisioning/dashboards
mkdir grafana/provisioning/datasources
mkdir prometheus
wget https://raw.githubusercontent.com/arquisoft/wiq_es1c/master/grafana/provisioning/datasources/datasource.yml -O grafana/provisioning/datasources/datasource.yml
wget https://raw.githubusercontent.com/arquisoft/wiq_es1c/master/grafana/provisioning/dashboards/dashboard.yml -O grafana/provisioning/dashboards/dashboard.yml
wget https://raw.githubusercontent.com/arquisoft/wiq_es1c/master/grafana/provisioning/dashboards/apiDashboard.json -O grafana/provisioning/dashboards/apiDashboard.json
wget https://raw.githubusercontent.com/arquisoft/wiq_es1c/master/prometheus/prometheus.yml -O prometheus/prometheus.yml
wget https://raw.githubusercontent.com/arquisoft/wiq_es1c/master/docker-compose.yml -O docker-compose.yml
wget https://raw.githubusercontent.com/arquisoft/wiq_es1c/master/.env -O .env
docker compose --profile prod down
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
node_modules
coverage
testDB.sqlite
**/*.sqlite
docs/build
.idea
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@

[![Deploy on release](https://github.com/Arquisoft/wiq_es1c/actions/workflows/release.yml/badge.svg)](https://github.com/Arquisoft/wiq_es1c/actions/workflows/release.yml)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Arquisoft_wiq_es1c&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Arquisoft_wiq_es1c)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=Arquisoft_wiq_es1c&metric=coverage)](https://sonarcloud.io/summary/new_code?id=Arquisoft_wiq_es1c) [![Open Issues](https://img.shields.io/github/issues-raw/Arquisoft/wiq_es1c)](https://github.com/Arquisoft/wiq_es1c/issues) [![Closed Issues](https://img.shields.io/github/issues-closed-raw/Arquisoft/wiq_es1c)](https://github.com/Arquisoft/wiq_es1c/issues?q=is%3Aissue+is%3Aclosed) [![Pull Requests](https://img.shields.io/github/issues-pr/Arquisoft/wiq_es1c)](https://github.com/Arquisoft/wiq_es1c/pulls) [![License](https://img.shields.io/github/license/Arquisoft/wiq_es1c)](https://github.com/Arquisoft/wiq_es1c/blob/main/LICENSE) [![Open Source](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://opensource.org/)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=Arquisoft_wiq_es1c&metric=coverage)](https://sonarcloud.io/summary/new_code?id=Arquisoft_wiq_es1c) [![Open Issues](https://img.shields.io/github/issues-raw/Arquisoft/wiq_es1c)](https://github.com/Arquisoft/wiq_es1c/issues) [![Closed Issues](https://img.shields.io/github/issues-closed-raw/Arquisoft/wiq_es1c)](https://github.com/Arquisoft/wiq_es1c/issues?q=is%3Aissue+is%3Aclosed) [![Pull Requests](https://img.shields.io/github/issues-pr/Arquisoft/wiq_es1c)](https://github.com/Arquisoft/wiq_es1c/pulls) [![Open Source](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://opensource.org/)
[![CodeScene Code Health](https://codescene.io/projects/52509/status-badges/code-health)](https://codescene.io/projects/52509) [![CodeScene System Mastery](https://codescene.io/projects/52509/status-badges/system-mastery)](https://codescene.io/projects/52509) [![CodeScene general](https://codescene.io/images/analyzed-by-codescene-badge.svg)](https://codescene.io/projects/52509)


[![Website](https://github.com/Arquisoft/wiq_es1c/blob/master/media/img/wiq_banner_readme.png)](http://wiqgame.run.place/)

This is a base repo for the [Software Architecture course](http://arquisoft.github.io/) in [2023/2024 edition](https://arquisoft.github.io/course2324.html).
<p align="center">
<a href = "http://wiqgame.run.place/" title= "Pagina web">
<img src="https://github.com/Arquisoft/wiq_es1c/blob/master/media/img/wiq_banner_readme.png">
</a>
</p>

This repo is a basic application composed of several components.

- **User service**. Express service that handles the insertion of new users in the system.
- **Auth service**. Express service that handles the authentication of users.
- **Game service**. Express service that handles the game itself.
- **Friend service**. Express service that handles the friends.
- **Question service**. Express service that handles the questions generation and distribution.
- **Webapp**. React web application that uses the gateway service to allow basic login and new user features.

Every service has its own MariaDB database in addition the question and game service have a MongoDB database for managing the questions and the communication with the Wikidata services.



## Description

This project has been developed by the contributors listed in the following section, as part of the **Software Architecture course at the University of Oviedo** for the academic year 2023/2024.
Expand Down
4 changes: 4 additions & 0 deletions auth_service/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const YAML = require('yaml')

// My own libs
const auth = require('./auth/authEndpoints');
const user = require('./user/userEndpoints')

const port = 8001;
const app = express();
Expand All @@ -28,6 +29,9 @@ app.post("/api/auth/register", auth.register);
app.post("/api/auth/login", auth.login);
app.post("/api/auth/verify", auth.verify);
app.post("/api/auth/getName", auth.getUsername);
app.get("/api/user/getUsers", user.getUsers);
app.get("/api/user/getUser", user.getUser);
app.post("/api/user/deleteUser", user.deleteUser);
app.get('/health', (req, res) => {
res.json({ status: 'OK' });
});
Expand Down
65 changes: 65 additions & 0 deletions auth_service/auth.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,69 @@ describe('Authentication Endpoints', () => {
expect(response.body.name).toBe(mockUser.name);
});

it("Should return 200 and the users", async() =>{

await User.create({
id: 2,
name: 'prueba2',
password: 'contraseña2'
});

const response = await request(app)
.get('/api/user/getUsers');
expect(response.statusCode).toBe(200);
expect(response.body).toEqual([{name: 'testuser', id:1},{name: 'prueba2',id:2}]);
});

it("Should return 200 and the mocked user",async()=>{
const response = await request(app)
.get('/api/user/getUser')
.query({user_id:1});
expect(response.statusCode).toBe(200);
expect(response.body.user.name).toEqual(mockUser.name)

});

it("Should return 401 because the user doesn't exist",async()=>{
const response = await request(app)
.get('/api/user/getUser')
.query({user_id:2});
expect(response.statusCode).toBe(401);

});

it("Should return 401 because it needs a parameter",async()=>{
const response = await request(app)
.get('/api/user/getUser')
expect(response.statusCode).toBe(401);

});

it("Shoud return 200 and delete the user",async()=>{
const response = await request(app)
.post('/api/user/deleteUser')
.query({user_id:1});
expect(response.statusCode).toBe(200);

//try to find the deleted user
const response2 = await request(app)
.get('/api/user/getUser')
.query({user_id:1});
expect(response2.statusCode).toBe(401);
});

it("Shoud return 401 because it needs a parameter in delete",async()=>{
const response = await request(app)
.post('/api/user/deleteUser')
expect(response.statusCode).toBe(401);
});

it("Shoud return 401 because the user doesn't exist in delete",async()=>{
console.log('este')
const response = await request(app)
.post('/api/user/deleteUser')
.query({user_id:8});
expect(response.statusCode).toBe(401);
});

});
2 changes: 2 additions & 0 deletions auth_service/auth/authEndpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,6 @@ const getUsername = async (req,res) => {
});
}



module.exports = {login, register, verify, getUsername}
4 changes: 2 additions & 2 deletions auth_service/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
},
"development": {
"dialect": "sqlite",
"storage": "./testDB.sqlite",
"storage": "./testDBAuth.sqlite",
"logging": false
},
"test": {
"dialect": "sqlite",
"storage": "./testDB.sqlite",
"storage": "./testDBAuth.sqlite",
"logging": false
}
}
Loading

0 comments on commit 88d9953

Please sign in to comment.