diff --git a/.drone.yml b/.drone.yml index 72aa85d..253b4fd 100644 --- a/.drone.yml +++ b/.drone.yml @@ -15,6 +15,7 @@ steps: - dotnet restore CI_MAUI.sln - dotnet build CI_MAUI.sln -c Release --no-restore - dotnet publish CI_MAUI.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release + - name: tests image: mcr.microsoft.com/dotnet/sdk:6.0 commands: @@ -22,6 +23,7 @@ steps: - dotnet restore CI_MAUI.sln - dotnet test CI_MAUI.sln --no-restore depends_on: [build] + - name: code-analysis image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 commands: @@ -42,13 +44,52 @@ steps: sonar_token: from_secret: SECRET_SONAR_LOGIN depends_on: [tests] - # database container deployment + - name: deploy-container-mysql image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest environment: - IMAGENAME: postgres - CONTAINERNAME: mysql - COMMAND: create - PRIVATE: true - POSTGRES_PASSWORD: oui - \ No newline at end of file + IMAGENAME: mariadb:latest + CONTAINERNAME: mariadb + COMMAND: create + OVERWRITE: true + PRIVATE: false + CODEFIRST_CLIENTDRONE_ENV_MARIADB_ROOT_PASSWORD: + from_secret: db_root_password + CODEFIRST_CLIENTDRONE_ENV_MARIADB_DATABASE: + from_secret: db_database + CODEFIRST_CLIENTDRONE_ENV_MARIADB_USER: + from_secret: db_user + CODEFIRST_CLIENTDRONE_ENV_MARIADB_PASSWORD: + from_secret: db_password + + - name: web-API + image: plugins/docker + settings: + dockerfile: ./Dockerfile + context: ./ + registry: hub.codefirst.iut.uca.fr + repo: hub.codefirst.iut.uca.fr/vincent.astolfi/conseco + username: + from_secret: secret-registry-username + password: + from_secret: secret-registry-password + + + - name: deploy-web-container + image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest + environment: + IMAGENAME: hub.codefirst.iut.uca.fr/vincent.astolfi/conseco:latest + CONTAINERNAME: conseco + COMMAND: create + OVERWRITE: true + CODEFIRST_CLIENTDRONE_ENV_DB_SERVER: + from_secret: db_server + CODEFIRST_CLIENTDRONE_ENV_MARIADB_ROOT_PASSWORD: + from_secret: db_root_password + CODEFIRST_CLIENTDRONE_ENV_MARIADB_DATABASE: + from_secret: db_database + CODEFIRST_CLIENTDRONE_ENV_MARIADB_USER: + from_secret: db_user + CODEFIRST_CLIENTDRONE_ENV_MARIADB_PASSWORD: + from_secret: db_password + depends_on: [ web-API, deploy-container-mysql ] \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index a9118b4..c76abc5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,6 @@ -FROM aosapps/drone-sonar-plugin AS base -FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine - -COPY --from=base /bin/drone-sonar /bin/ -WORKDIR /bin - -RUN apk update && apk add openjdk11-jre nodejs && rm -rf /tmp/* /var/cache/apk/* - -RUN dotnet tool install --global dotnet-sonarscanner -RUN dotnet tool install --global dotnet-reportgenerator-globaltool - -ENV JAVA_HOME /usr/lib/jvm/default-jvm/ -ENV PATH ${PATH}:${JAVA_HOME}/bin -ENV PATH $PATH:/root/.dotnet/tools - -ENTRYPOINT /bin/drone-sonar - -RUN dotnet sonarscanner begin /k:"ConsEco" /d:sonar.host.url="https://codefirst.iut.uca.fr/sonar" /d:sonar.login="sqp_ffc02968e133d03daeb917e8c2e6f243a80d087a" -RUN dotnet build -RUN dotnet sonarscanner end /d:sonar.login="sqp_ffc02968e133d03daeb917e8c2e6f243a80d087a" \ No newline at end of file +FROM php:8.1-apache +RUN apt-get update && apt-get install -y mariadb-client +RUN docker-php-ext-install mysqli pdo pdo_mysql && docker-php-ext-enable pdo_mysql +COPY ./Sources/API /var/www/html/ +COPY ./Sources/Data /sql/ +RUN cd /sql/ diff --git a/Sources/API/.htaccess b/Sources/API/.htaccess new file mode 100644 index 0000000..e69de29 diff --git a/Sources/API/config/Autoload.php b/Sources/API/config/Autoload.php new file mode 100644 index 0000000..10eb20c --- /dev/null +++ b/Sources/API/config/Autoload.php @@ -0,0 +1,32 @@ +$file

"; + if(file_exists($file)){ + include $file; + } + } + } +} + +?> \ No newline at end of file diff --git a/Sources/API/config/Config.php b/Sources/API/config/Config.php new file mode 100644 index 0000000..5b648a6 --- /dev/null +++ b/Sources/API/config/Config.php @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/Sources/API/controller/.gitkeep b/Sources/API/controller/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Sources/API/controller/Controller.php b/Sources/API/controller/Controller.php new file mode 100644 index 0000000..81ef754 --- /dev/null +++ b/Sources/API/controller/Controller.php @@ -0,0 +1,177 @@ +executeQueryWithoutParameters($query); + + $query='INSERT INTO Devise VALUES("EUR","EURO"); + INSERT INTO Devise VALUES("USD","DOLLAR"); + INSERT INTO Devise VALUES("GBP","Livre Sterling"); + INSERT INTO Devise VALUES("JPY","YEN"); + INSERT INTO Devise VALUES("AUD","DOLLAR AUSTRALIEN"); + INSERT INTO Devise VALUES("NZD","DOLLAR NEO-ZELANDAIS"); + INSERT INTO Devise VALUES("ZAR","RANd"); + + + INSERT INTO Inscrit (nom,prenom,mail,mdp)VALUES("EVARD","LUCAS","lucasevard@gmail.com","test"); + INSERT INTO Inscrit (nom,prenom,mail,mdp)VALUES("MONCUL","STEPHANE","stef@gmail.com","teststef"); + INSERT INTO Inscrit (nom,prenom,mail,mdp)VALUES("MENFOUMETTOITOUTNU","RENAUD","renaudtoutnu@gmail.com","test000"); + INSERT INTO Inscrit (nom,prenom,mail,mdp)VALUES("YOUVOI","BENJAMIN","BENJAMIN@gmail.com","BENJAMIN"); + INSERT INTO Inscrit (nom,prenom,mail,mdp)VALUES("TUBEAU","RAOUL","raoullacouille@gmail.com","zizi"); + + INSERT INTO DeviseInscrit VALUES("EUR","1"); + INSERT INTO DeviseInscrit VALUES("JPY","2"); + INSERT INTO DeviseInscrit VALUES("USD","3"); + INSERT INTO DeviseInscrit VALUES("NZD","4"); + + + INSERT INtO Banque(nom,urlsite,urllogo) VALUES("BNP PARIBAS","mabanque","imagesitebnb.fr"); + INSERT INtO Banque(nom,urlsite,urllogo) VALUES("CREDIT AGRICOLE","credit-agricole.fr","imageca"); + INSERT INtO Banque(nom,urlsite,urllogo) VALUES("BANQUE POSTALE","labanquepostale.fr","imgbp"); + INSERT INtO Banque(nom,urlsite,urllogo) VALUES("CAISSE D EPARGNE","caisse-epargne.fr","imgcaissedepargne"); + + + INSERT INTO InscrBanque (nomBanque,idInscrit)VALUES("BNP PARIBAS","1"); + INSERT INTO InscrBanque (nomBanque,idInscrit)VALUES("CREDIT AGRICOLE","2"); + INSERT INTO InscrBanque (nomBanque,idInscrit)VALUES("BANQUE POSTALE","3"); + INSERT INTO InscrBanque (nomBanque,idInscrit)VALUES("CAISSE D EPARGNE","4"); + + + INSERT INTO Compte (nom,idInscritBanque)VALUES("LIVRET A","1"); + INSERT INTO Compte (nom,idInscritBanque)VALUES("LIVRET A","2"); + INSERT INTO Compte (nom,idInscritBanque)VALUES("LIVRET A","3"); + INSERT INTO Compte (nom,idInscritBanque)VALUES("LIVRET A","4"); + + + INSERT INTO Planification (nom,credit,compte,datep,datecrea,methodePayement) VALUES ("EDF","190","1",now(),now(),"CB"); + INSERT INTO Planification (nom,credit,compte,datep,datecrea,methodePayement) VALUES ("SPOTIFY","190","2",now(),now(),"Prélevement"); + INSERT INTO Planification (nom,credit,compte,datep,datecrea,methodePayement) VALUES ("NETFLIX","190","3",now(),now(),"Cheque"); + INSERT INTO Planification (nom,credit,compte,datep,datecrea,methodePayement) VALUES ("PLAYSTATION PLUS","190","4",now(),now(),"Espece");'; + + $con->ExecuteQueryWithoutParameters($query); + switch($url[0]){ + case "SELECT": + switch($url[1]){ + case "Inscrit": + $query = 'SELECT * FROM Inscrit'; + $con->executeQueryWithoutParameters($query); + $res = $con->getResults(); + print(json_encode($res)); + break; + } + break; + default: + echo "ERREUR"; + } + } +} + +?> \ No newline at end of file diff --git a/Sources/API/index.php b/Sources/API/index.php new file mode 100644 index 0000000..8ba788e --- /dev/null +++ b/Sources/API/index.php @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/Sources/API/modele/Connection.php b/Sources/API/modele/Connection.php new file mode 100644 index 0000000..9f3b119 --- /dev/null +++ b/Sources/API/modele/Connection.php @@ -0,0 +1,36 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +} + +/** * @param string $query + * @param array $parameters * + * @return bool Returns `true` on success, `false` otherwise +*/ + +public function executeQuery(string $query, array $parameters = []) : bool{ + $this->stmt = parent::prepare($query); + foreach ($parameters as $name => $value) { + $this->stmt->bindValue($name, $value[0], $value[1]); + } + + return $this->stmt->execute(); +} + +public function getResults() : array { + return $this->stmt->fetchall(); +} + +public function executeQueryWithoutParameters($query) : bool{ + $this->stmt = parent::prepare($query); + return $this->stmt->execute(); +} +} + +?> \ No newline at end of file diff --git a/Sources/API/modele/MdlInscrit.php b/Sources/API/modele/MdlInscrit.php new file mode 100644 index 0000000..ed71324 --- /dev/null +++ b/Sources/API/modele/MdlInscrit.php @@ -0,0 +1,14 @@ +selectAll(); + } +} + +?> \ No newline at end of file diff --git a/Sources/API/modele/gateways/InscritGateway.php b/Sources/API/modele/gateways/InscritGateway.php new file mode 100644 index 0000000..de3bfa4 --- /dev/null +++ b/Sources/API/modele/gateways/InscritGateway.php @@ -0,0 +1,17 @@ +con=$con; + } + + public function selectAll(){ + $query="SELECT * FROM Inscrit;"; + $this->con->executeQueryWithoutParameters($query); + return $this->con->getResults(); + } +} + +?> \ No newline at end of file