diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml
index 7f621ef..c7607e6 100644
--- a/.github/workflows/cmake.yml
+++ b/.github/workflows/cmake.yml
@@ -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:
@@ -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
@@ -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
@@ -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:
diff --git a/.idea/sqldialects.xml b/.idea/sqldialects.xml
index 6c9a15b..bddfe6d 100644
--- a/.idea/sqldialects.xml
+++ b/.idea/sqldialects.xml
@@ -1,7 +1,8 @@
-
+
+
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c53fab3..da1a142 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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)
diff --git a/README.md b/README.md
index 63d2b49..1368086 100644
--- a/README.md
+++ b/README.md
@@ -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
@@ -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
diff --git a/infrastructure/Dockerfile b/infrastructure/Dockerfile
index aeeba00..8040e7b 100644
--- a/infrastructure/Dockerfile
+++ b/infrastructure/Dockerfile
@@ -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/
\ No newline at end of file
+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/
\ No newline at end of file
diff --git a/infrastructure/SQL_Scripts/1_users.sql b/infrastructure/SQL_Scripts/1_users.sql
new file mode 100644
index 0000000..f46ffdb
--- /dev/null
+++ b/infrastructure/SQL_Scripts/1_users.sql
@@ -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
+ );
\ No newline at end of file
diff --git a/infrastructure/SQL_Scripts/2_bankaccounts.sql b/infrastructure/SQL_Scripts/2_bankaccounts.sql
new file mode 100644
index 0000000..0d969cd
--- /dev/null
+++ b/infrastructure/SQL_Scripts/2_bankaccounts.sql
@@ -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)
+);
\ No newline at end of file
diff --git a/infrastructure/SQL_Scripts/3_emailaccounts.sql b/infrastructure/SQL_Scripts/3_emailaccounts.sql
new file mode 100644
index 0000000..8330187
--- /dev/null
+++ b/infrastructure/SQL_Scripts/3_emailaccounts.sql
@@ -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)
+);
\ No newline at end of file
diff --git a/infrastructure/SQL_Scripts/4_socialmediaaccounts.sql b/infrastructure/SQL_Scripts/4_socialmediaaccounts.sql
new file mode 100644
index 0000000..a9b6911
--- /dev/null
+++ b/infrastructure/SQL_Scripts/4_socialmediaaccounts.sql
@@ -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)
+);
\ No newline at end of file
diff --git a/infrastructure/SQL_Scripts/users.sql b/infrastructure/SQL_Scripts/users.sql
deleted file mode 100644
index 570ce88..0000000
--- a/infrastructure/SQL_Scripts/users.sql
+++ /dev/null
@@ -1,6 +0,0 @@
-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
-);
\ No newline at end of file
diff --git a/src/Accounts/Account.cpp b/src/Accounts/Account.cpp
new file mode 100644
index 0000000..6125a4e
--- /dev/null
+++ b/src/Accounts/Account.cpp
@@ -0,0 +1,23 @@
+#include
+
+#include
+#include
+
+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";
+}
diff --git a/src/Accounts/Account.h b/src/Accounts/Account.h
new file mode 100644
index 0000000..9dca5cd
--- /dev/null
+++ b/src/Accounts/Account.h
@@ -0,0 +1,30 @@
+#ifndef ACCOUNT_H
+#define ACCOUNT_H
+#include
+#include
+
+class Account {
+protected:
+ std::string username;
+ std::string password;
+
+ [[nodiscard]] virtual AccountType getAccountType() const = 0;
+
+ virtual void showAccountDetails() const = 0;
+
+public:
+ Account(std::string, std::string);
+
+ virtual void addAccount() = 0;
+
+ virtual ~Account() = default;
+
+ void show() const;
+
+ [[nodiscard]] virtual std::string getUsername() const;
+
+ [[nodiscard]] virtual std::string getPassword() const;
+};
+
+
+#endif //ACCOUNT_H
diff --git a/src/Accounts/AccountFactory.cpp b/src/Accounts/AccountFactory.cpp
new file mode 100644
index 0000000..607cb4b
--- /dev/null
+++ b/src/Accounts/AccountFactory.cpp
@@ -0,0 +1,27 @@
+#include
+#include
+
+#include
+#include
+#include
+
+std::shared_ptr AccountFactory::accountFactory(const AccountType accountType,
+ std::map accountDetails) {
+ switch (accountType) {
+ case AccountType::BankAccountType : {
+ return std::make_shared(accountDetails["username"], accountDetails["password"],
+ accountDetails["IBAN"], accountDetails["bank"]);
+ }
+ case AccountType::EmailAccountType : {
+ return std::make_shared(accountDetails["username"], accountDetails["password"],
+ accountDetails["emailAddress"], accountDetails["mailProvider"]);
+ }
+ case AccountType::SocialMediaAccountType : {
+ return std::make_shared(accountDetails["username"], accountDetails["password"],
+ accountDetails["platform"], accountDetails["profileUrl"]);
+ }
+ default: {
+ throw std::invalid_argument("Invalid accountType");
+ }
+ }
+}
diff --git a/src/Accounts/AccountFactory.h b/src/Accounts/AccountFactory.h
new file mode 100644
index 0000000..91d166a
--- /dev/null
+++ b/src/Accounts/AccountFactory.h
@@ -0,0 +1,16 @@
+#ifndef ACCOUNTFACTORY_H
+#define ACCOUNTFACTORY_H
+
+#include