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

Milestone 2 - Added accounts #2

Merged
merged 11 commits into from
Jan 6, 2025
83 changes: 56 additions & 27 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches: [ '*' ] # NOTE: replace/update with appropriate branch name(s)
tags: [ '*' ]
pull_request:
types: [closed]
types: [ closed ]
branches: [ '*' ] # NOTE: replace/update with appropriate branch name(s)
workflow_dispatch:
inputs:
Expand Down Expand Up @@ -107,16 +107,16 @@ jobs:
fail-fast: false
matrix:
include:
# - os: ubuntu-22.04
# c: clang-18
# cxx: clang++-18
# clang_ver: "18"
# clang_ver_full: "18.1.8"
# name: "MSan: Ubuntu 22.04 Clang 18"
# cmake_flags: "-DUSE_MSAN=ON"
# cmake_generator: Ninja
# # This env runs memory sanitizers
# runs_msan: true
# - os: ubuntu-22.04
# c: clang-18
# cxx: clang++-18
# clang_ver: "18"
# clang_ver_full: "18.1.8"
# name: "MSan: Ubuntu 22.04 Clang 18"
# cmake_flags: "-DUSE_MSAN=ON"
# cmake_generator: Ninja
# # This env runs memory sanitizers
# runs_msan: true

- os: ubuntu-22.04
c: gcc-12
Expand Down Expand Up @@ -154,16 +154,16 @@ jobs:
# cmake_flags:
# cmake_generator: Ninja

# - os: windows-2022
# c: cl
# cxx: cl
# name: "ASan: Windows 2022 MSVC 19.41"
# cmake_flags: "-DUSE_ASAN=ON"
# # Ninja is not faster on MSVC because... MSVC
# # cmake_generator: "Ninja"
# # cmake_generator: "Ninja Multi-Config"
# # This env runs address sanitizers
# runs_asan: true
# - os: windows-2022
# c: cl
# cxx: cl
# name: "ASan: Windows 2022 MSVC 19.41"
# cmake_flags: "-DUSE_ASAN=ON"
# # Ninja is not faster on MSVC because... MSVC
# # cmake_generator: "Ninja"
# # cmake_generator: "Ninja Multi-Config"
# # This env runs address sanitizers
# runs_asan: true

- os: windows-2022
c: gcc
Expand Down Expand Up @@ -280,12 +280,41 @@ jobs:
- name: "Postgres setup"
run: |
export PGPASSWORD=pipeline_test_password
psql -h localhost -U pipeline_test_user -d pipeline_test_password_keeper -c "CREATE TABLE IF NOT EXISTS users (
id SERIAL PRIMARY KEY,
username VARCHAR(50) UNIQUE NOT NULL,
passwordSalt VARCHAR(150) NOT NULL,
passwordHash VARCHAR(150) NOT NULL
);"
psql -h localhost -U pipeline_test_user -d pipeline_test_password_keeper -c "
CREATE TABLE IF NOT EXISTS users (
id SERIAL PRIMARY KEY,
username VARCHAR(50) UNIQUE NOT NULL,
passwordSalt VARCHAR(150) NOT NULL,
passwordHash VARCHAR(150) NOT NULL
);

CREATE TABLE IF NOT EXISTS bankaccounts (
id SERIAL REFERENCES users (id),
username VARCHAR(50) NOT NULL,
password VARCHAR(50) NOT NULL,
IBAN VARCHAR(50) NOT NULL,
bank VARCHAR(50) NOT NULL,
CONSTRAINT pk_bankaccount PRIMARY KEY (id, username, password, IBAN, bank)
);

CREATE TABLE IF NOT EXISTS emailaccounts (
id SERIAL REFERENCES users (id),
username VARCHAR(50) NOT NULL,
password VARCHAR(50) NOT NULL,
emailAddress VARCHAR(50) NOT NULL,
mailProvider VARCHAR(50) NOT NULL,
CONSTRAINT pk_emailaccounts PRIMARY KEY (id, username, password, emailAddress, mailProvider)
);

CREATE TABLE IF NOT EXISTS socialmediaaccounts (
id SERIAL REFERENCES users (id),
username VARCHAR(50) NOT NULL,
password VARCHAR(50) NOT NULL,
platform VARCHAR(50) NOT NULL,
profileUrl VARCHAR(50) NOT NULL,
CONSTRAINT pk_socialmediaaccounts PRIMARY KEY (id, username, password, platform, profileUrl)
);
"

- name: "Run tests"
env:
Expand Down
3 changes: 2 additions & 1 deletion .idea/sqldialects.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ FetchContent_MakeAvailable(pqxx)
find_package(PostgreSQL)

add_subdirectory(src)
if(RUN_TESTS)
if (RUN_TESTS)
include(CTest)
enable_testing()
add_subdirectory(tests)
Expand Down
98 changes: 49 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,51 @@
[ENG]

# Password-Keeper

## Project Description

The Password Keeper application enables users to manage their passwords in a secure database.
It offers functionality to efficiently and safely store and organize passwords, as well as the option to generate new, customized passwords on demand.
It offers functionality to efficiently and safely store and organize passwords, as well as the option to generate new,
customized passwords on demand.

## Notes

1. PostgreSQL Installation:
- To build the project, you must first install [PostgreSQL](https://www.postgresql.org/download/) on your computer.
2. Running the Application Locally:
- To use the application locally, you need to install [Docker](https://docs.docker.com/engine/install/), use the command
`docker compose up` in the project's [infrastructure](./infrastructure) folder, and create a new file named `.env` in the src folder.
Fill this file with the details from [compose.yml](./infrastructure/compose.yaml) , following the format described in the .env.template file.
- To use the application locally, you need to install [Docker](https://docs.docker.com/engine/install/), use the
command
`docker compose up` in the project's [infrastructure](./infrastructure) folder, and create a new file named `.env`
in the src folder.
Fill this file with the details from [compose.yml](./infrastructure/compose.yaml) , following the format described
in the .env.template file.
3. Running Tests:
- To run the tests, add either the env.bat or env.sh file (the former for Windows, the latter for POSIX systems)
to the environment file settings of your toolchain (File | Settings | Build, Execution, Deployment | Toolchains) under the Environment File section.
Tests can be run either by executing the cmake-build-debug/tests/Password-Keeper-Test-Runner file or by running the ctest command in the cmake-build-debug folder.
- To run the tests, you have to compile them first. To do so you have to add the `-DRUN_TESTS=ON` argument when
compiling the app.
- Tests can be run either by executing the `cmake-build-debug/tests/Password-Keeper-Test-Runner` file or by running
the `ctest` command in the `cmake-build-debug` folder.

## CI/CD Pipeline
The CI/CD pipeline is configured in GitHub Actions and includes multiple stages to ensure code quality, compatibility, and functionality across various platforms.

The CI/CD pipeline is configured in GitHub Actions and includes multiple stages to ensure code quality, compatibility,
and functionality across various platforms.

1. Code Quality Validation:
- The first two stages validate code correctness and ensure no warnings are generated (using Cppcheck and Clang-Tidy).
- The first two stages validate code correctness and ensure no warnings are generated (using Cppcheck and
Clang-Tidy).

2. Compatibility Testing Across Multiple Operating Systems:
- The next five stages ensure proper code execution on major operating systems (Linux, macOS, and Windows) and perform memory checks using MSAN, ASAN, and Valgrind to identify potential memory leaks and other memory-related issues.
- The next five stages ensure proper code execution on major operating systems (Linux, macOS, and Windows) and
perform memory checks using ASAN and Valgrind to identify potential memory leaks and other memory-related issues.

3. Functional Test Execution:
- The final stage runs functional tests to verify that the application behaves as expected.
- The final stage runs functional tests to verify that the application behaves as expected.

In all stages involving the execution of the application, a PostgreSQL service is included to ensure proper application functionality.
In all stages involving the execution of the application, a PostgreSQL service is included to ensure proper application
functionality.

[RO]

# Password-Keeper

## Descriere proiect
Expand All @@ -40,57 +55,42 @@ Aceasta oferă funcționalitatea de a stoca și organiza parolele într-un mod e
genera parole noi, personalizate, la cerere.

## Mentiuni

1. Instalare PostgreSQL:
- Pentru a construi proiectul trebuie sa instalati mai intai [PostgreSQL](https://www.postgresql.org/download/) pe
calculatorul dumneavoastra.
- Pentru a construi proiectul trebuie sa instalati mai intai [PostgreSQL](https://www.postgresql.org/download/) pe
calculatorul dumneavoastra.
2. Folosirea aplicatiei local:
- Pentru a folosi aplicatia local trebuie sa instalati [Docker](https://docs.docker.com/engine/install/),sa folositi comanda
`docker compose up` in folderul [infrastructure](./infrastructure) din proiect, sa create un nou fisier numit `.env` in
folderul [src](./src) si sa il completati cu datale din [compose.yml](./infrastructure/compose.yaml)
- Pentru a folosi aplicatia local trebuie sa instalati [Docker](https://docs.docker.com/engine/install/),sa folositi
comanda
`docker compose up` in folderul [infrastructure](./infrastructure) din proiect, sa create un nou fisier numit
`.env` in
folderul [src](./src) si sa il completati cu datale din [compose.yml](./infrastructure/compose.yaml)
in modul prezentat in fisierul [.env.template](.env.template)
3. Rularea testelor:
- Pentru a rula testele trebuie sa adaugati unul dintre fisierele [env.bat](env.bat) sau [env.sh](env.sh) (primul pentru
Windows, al doilea pentru sisteme POSIX) in setarile toolchain-ului pe care il folositi (`File | Settings | Build, Execution, Deployment | Toolchains`)
la rubrica `Environment File`. Testele se ruleaza ori ruland executabilul `cmake-build-debug/tests/Password-Keeper-Test-Runner` ori ruland comanda ctest in folderul `cmake-build-debug`.
- Pentru a rula testele acestea trebuie compilate. Pentru a face acest lucru trebuie sa adaugati comanda
`-DRUN_TESTS=ON` atunci cand compilati.
- Testele se ruleaza ori ruland executabilul
`cmake-build-debug/tests/Password-Keeper-Test-Runner` ori ruland comanda ctest in folderul `cmake-build-debug`.

## Pipeline
Pipeline-ul CI/CD este configurat în [GitHub Actions](./.github/workflows/cmake.yml) și include mai multe etape pentru a asigura calitatea codului, compatibilitatea și funcționalitatea pe diferite platforme.

Pipeline-ul CI/CD este configurat în [GitHub Actions](./.github/workflows/cmake.yml) și include mai multe etape pentru a
asigura calitatea codului, compatibilitatea și funcționalitatea pe diferite platforme.

Verificarea calității codului:
Primele două etape validează corectitudinea codului și se asigură că nu generează warnings ( folosind `Cppcheck` si `Clang-Tidy` ).
Primele două etape validează corectitudinea codului și se asigură că nu generează warnings ( folosind `Cppcheck` si
`Clang-Tidy` ).

Testarea compatibilității pe multiple sisteme de operare:
Următoarele cinci etape asigură rularea corectă a codului pe principalele sisteme de operare (Linux, macOS și Windows) și efectuează verificări de memorie folosind MSAN, ASAN și Valgrind, pentru a identifica posibile memory leaks și alte probleme legate de memorie.
Următoarele cinci etape asigură rularea corectă a codului pe principalele sisteme de operare (Linux, macOS și Windows)
și efectuează verificări de memorie folosind ASAN și Valgrind, pentru a identifica posibile memory leaks și alte
probleme legate de memorie.

Rularea testelor funcționale:
Ultima etapă rulează testele pentru a verifica dacă aplicația funcționează conform așteptărilor.

În toate etapele care implică rularea aplicatiei este inclus un serviciu PostgreSQL pentru a permite rularea corectă a aplicației.

## Milestone #0

- [ ] Nume proiect (poate fi schimbat ulterior)
- [ ] Scurtă descriere a temei alese, ce v-ați propus să implementați

## Milestone #1

#### Cerințe

- [ ] definirea a minim **3-4 clase** folosind compunere cu clasele definite de voi
- [ ] constructori de inițializare cu parametri
- [ ] pentru o aceeași (singură) clasă: constructor de copiere, `operator=` de copiere, destructor
- [ ] `operator<<` pentru toate clasele pentru afișare (std::ostream)
- [ ] cât mai multe `const` (unde este cazul)
- [ ] implementarea a minim 3 funcții membru publice pentru funcționalități specifice temei alese, dintre care cel puțin
1-2 funcții mai complexe
- nu doar citiri/afișări sau adăugat/șters elemente într-un/dintr-un vector
- [ ] scenariu de utilizare a claselor definite:
- preferabil sub formă de teste unitare, mai ales dacă vorbim de aplicații consolă
- crearea de obiecte și apelarea tuturor funcțiilor membru publice în main
- vor fi adăugate în fișierul `tastatura.txt` DOAR exemple de date de intrare de la tastatură (dacă există); dacă
aveți nevoie de date din fișiere, creați alte fișiere separat
- [ ] tag de `git`: de exemplu `v0.1`
- [ ] serviciu de integrare continuă (CI); exemplu: GitHub Actions
În toate etapele care implică rularea aplicatiei este inclus un serviciu PostgreSQL pentru a permite rularea corectă a
aplicației.

## Milestone #2

Expand Down
5 changes: 4 additions & 1 deletion infrastructure/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ ENV POSTGRES_DB=password_keeper
ENV POSTGRES_USER=user
ENV POSTGRES_PASSWORD=temp

COPY SQL_Scripts/users.sql /docker-entrypoint-initdb.d/
COPY SQL_Scripts/1_users.sql /docker-entrypoint-initdb.d/
COPY SQL_Scripts/2_bankaccounts.sql /docker-entrypoint-initdb.d/
COPY SQL_Scripts/3_emailaccounts.sql /docker-entrypoint-initdb.d/
COPY SQL_Scripts/4_socialmediaaccounts.sql /docker-entrypoint-initdb.d/
20 changes: 20 additions & 0 deletions infrastructure/SQL_Scripts/1_users.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
CREATE TABLE IF NOT EXISTS users
(
id
SERIAL
PRIMARY
KEY,
username
VARCHAR
(
50
) UNIQUE NOT NULL,
passwordSalt VARCHAR
(
150
) NOT NULL,
passwordHash VARCHAR
(
150
) NOT NULL
);
9 changes: 9 additions & 0 deletions infrastructure/SQL_Scripts/2_bankaccounts.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE TABLE IF NOT EXISTS bankaccounts
(
id SERIAL references users (id),
username VARCHAR(50) NOT NULL,
password varchar(50) NOT NULL,
IBAN varchar(50) NOT NULL,
bank varchar(50) NOT NULL,
constraint pk_bankaccount PRIMARY KEY (id, username, password, IBAN, bank)
);
9 changes: 9 additions & 0 deletions infrastructure/SQL_Scripts/3_emailaccounts.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE TABLE IF NOT EXISTS emailaccounts
(
id SERIAL references users (id),
username VARCHAR(50) NOT NULL,
password varchar(50) NOT NULL,
emailAddress varchar(50) NOT NULL,
mailProvider varchar(50) NOT NULL,
constraint pk_emailaccounts PRIMARY KEY (id, username, password, emailAddress, mailProvider)
);
9 changes: 9 additions & 0 deletions infrastructure/SQL_Scripts/4_socialmediaaccounts.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE TABLE IF NOT EXISTS socialmediaaccounts
(
id SERIAL references users (id),
username VARCHAR(50) NOT NULL,
password varchar(50) NOT NULL,
platform varchar(50) NOT NULL,
profileUrl varchar(50) NOT NULL,
constraint pk_socialmediaaccounts PRIMARY KEY (id, username, password, platform, profileUrl)
);
6 changes: 0 additions & 6 deletions infrastructure/SQL_Scripts/users.sql

This file was deleted.

23 changes: 23 additions & 0 deletions src/Accounts/Account.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <Account.h>

#include <iostream>
#include <utility>

Account::Account(std::string username, std::string password) : username(std::move(username)),
password(std::move(password)) {
}

std::string Account::getUsername() const {
return this->username;
}

std::string Account::getPassword() const {
return this->password;
}

void Account::show() const {
std::cout << "---------------------------------\n";
std::cout << "Account details:\n";
showAccountDetails();
std::cout << "\n";
}
Loading
Loading