debut tests
This commit is contained in:
parent
0057717820
commit
80187bd89a
34
src/EncryptionModule.cpp
Normal file
34
src/EncryptionModule.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
// deployer EncryptionModule implementation
|
||||
// Copyright (C) 2024 Jean-Cloud
|
||||
// GNU General Public License v3
|
||||
|
||||
#include "EncryptionModule.h"
|
||||
using namespace std;
|
||||
|
||||
//constructor
|
||||
EncryptionModule::EncryptionModule(){
|
||||
name="Let's Encrypt";
|
||||
}
|
||||
|
||||
//destructor inline
|
||||
|
||||
//public methods
|
||||
int EncryptionModule::Prepare ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int EncryptionModule::Deploy (string serviceUsername)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int EncryptionModule::Remove(string serviceUsername)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int EncryptionModule::Clean ()
|
||||
{
|
||||
return 0;
|
||||
}
|
20
src/EncryptionModule.h
Normal file
20
src/EncryptionModule.h
Normal file
@ -0,0 +1,20 @@
|
||||
// deployer EncryptionModule header
|
||||
// Copyright (C) 2024 Jean-Cloud
|
||||
// GNU General Public License v3
|
||||
|
||||
#if !defined(ENCRYPTIONMODULE_H)
|
||||
#define ENCRYPTIONMODULE_H
|
||||
|
||||
#include "Module.h"
|
||||
|
||||
class EncryptionModule : public Module
|
||||
{
|
||||
public:
|
||||
EncryptionModule();
|
||||
~EncryptionModule(){} //inline
|
||||
int Prepare ();
|
||||
int Deploy (string serviceUsername);
|
||||
int Remove(string serviceUsername);
|
||||
int Clean ();
|
||||
};
|
||||
#endif
|
34
src/NginxModule.cpp
Normal file
34
src/NginxModule.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
// deployer NginxModule implementation
|
||||
// Copyright (C) 2024 Jean-Cloud
|
||||
// GNU General Public License v3
|
||||
|
||||
#include "NginxModule.h"
|
||||
using namespace std;
|
||||
|
||||
//constructor
|
||||
NginxModule::NginxModule(){
|
||||
name="Let's Encrypt";
|
||||
}
|
||||
|
||||
//destructor inline
|
||||
|
||||
//public methods
|
||||
int NginxModule::Prepare ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int NginxModule::Deploy (string serviceUsername)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int NginxModule::Remove(string serviceUsername)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int NginxModule::Clean ()
|
||||
{
|
||||
return 0;
|
||||
}
|
23
src/NginxModule.h
Normal file
23
src/NginxModule.h
Normal file
@ -0,0 +1,23 @@
|
||||
// deployer NginxModule header
|
||||
// Copyright (C) 2024 Jean-Cloud
|
||||
// GNU General Public License v3
|
||||
|
||||
#if !defined(NGINXMODULE_H)
|
||||
#define NGINXMODULE_H
|
||||
|
||||
#include "Module.h"
|
||||
|
||||
class NginxModule : public Module
|
||||
{
|
||||
public:
|
||||
NginxModule();//inline
|
||||
~NginxModule(){} //inline
|
||||
int Prepare ();
|
||||
int Deploy (string serviceUsername);
|
||||
int Remove(string serviceUsername);
|
||||
int Clean ();
|
||||
private:
|
||||
int removeContainersCreatedByDockerCompose();
|
||||
int removeContainersWithServiceName (string serviceUsename);
|
||||
};
|
||||
#endif
|
34
src/WireguardModule.cpp
Normal file
34
src/WireguardModule.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
// deployer WireguardModule implementation
|
||||
// Copyright (C) 2024 Jean-Cloud
|
||||
// GNU General Public License v3
|
||||
|
||||
#include "WireguardModule.h"
|
||||
using namespace std;
|
||||
|
||||
//constructor
|
||||
WireguardModule::WireguardModule(){
|
||||
name="Let's Encrypt";
|
||||
}
|
||||
|
||||
//destructor inline
|
||||
|
||||
//public methods
|
||||
int WireguardModule::Prepare ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WireguardModule::Deploy (string serviceUsername)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WireguardModule::Remove(string serviceUsername)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WireguardModule::Clean ()
|
||||
{
|
||||
return 0;
|
||||
}
|
20
src/WireguardModule.h
Normal file
20
src/WireguardModule.h
Normal file
@ -0,0 +1,20 @@
|
||||
// deployer WireguardModule header
|
||||
// Copyright (C) 2024 Jean-Cloud
|
||||
// GNU General Public License v3
|
||||
|
||||
#if !defined(WIREGUARDMODULE_H)
|
||||
#define WIREGUARDMODULE_H
|
||||
|
||||
#include "Module.h"
|
||||
|
||||
class WireguardModule : public Module
|
||||
{
|
||||
public:
|
||||
WireguardModule();
|
||||
~WireguardModule(){} //inline
|
||||
int Prepare ();
|
||||
int Deploy (string serviceUsername);
|
||||
int Remove(string serviceUsername);
|
||||
int Clean ();
|
||||
};
|
||||
#endif
|
77
test/IntegrationTests/main.cpp
Normal file
77
test/IntegrationTests/main.cpp
Normal file
@ -0,0 +1,77 @@
|
||||
// deployer IntegrationTests main
|
||||
// Copyright (C) 2024 Jean-Cloud
|
||||
// GNU General Public License v3
|
||||
|
||||
#include <iostream>
|
||||
#include "BashManager.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void Help()
|
||||
{
|
||||
cout << "blabla" << endl;
|
||||
}
|
||||
|
||||
//tests
|
||||
void environmentTest()
|
||||
{
|
||||
cout << "Test of the environment setup." << endl;
|
||||
}
|
||||
|
||||
void bashTest()
|
||||
{
|
||||
cout << "Test of BashModule" << endl;
|
||||
}
|
||||
|
||||
void dockerTest()
|
||||
{
|
||||
cout << "Test of DockerModule" << endl;
|
||||
}
|
||||
|
||||
void nginxTest()
|
||||
{
|
||||
cout << "Test of Nginx module" << endl;
|
||||
}
|
||||
|
||||
void wireguardTest()
|
||||
{
|
||||
cout << "Test of WireguardModule" << endl;
|
||||
}
|
||||
|
||||
void encryptionTest()
|
||||
{
|
||||
cout << "Test of EncryptionModule" << endl;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if(argc!=2){
|
||||
cerr << "Invalid number of arguments." << endl;
|
||||
} else{
|
||||
BashManager::Execute("./deployer deploy all");
|
||||
string action=argv[1];
|
||||
if (action=="environment"){
|
||||
environmentTest();
|
||||
} else if (action=="bash"){
|
||||
bashTest();
|
||||
} else if (action=="docker"){
|
||||
dockerTest();
|
||||
} else if (action=="nginx"){
|
||||
nginxTest();
|
||||
} else if (action=="wireguard"){
|
||||
wireguardTest();
|
||||
} else if (action=="encryption"){
|
||||
encryptionTest();
|
||||
} else if (action=="all"){
|
||||
environmentTest();
|
||||
bashTest();
|
||||
dockerTest();
|
||||
nginxTest();
|
||||
wireguardTest();
|
||||
encryptionTest();
|
||||
} else {
|
||||
cerr << "Unknown argument." << endl;
|
||||
Help();
|
||||
}
|
||||
}
|
||||
}
|
38
test/IntegrationTests/src/BashManager.cpp
Normal file
38
test/IntegrationTests/src/BashManager.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
// deployer BashManager implementation
|
||||
// Copyright (C) 2024 Jean-Cloud
|
||||
// GNU General Public License v3
|
||||
|
||||
#include <iostream>
|
||||
#include "BashManager.h"
|
||||
|
||||
int BashManager::Execute(string command)
|
||||
{
|
||||
FILE * p = popen(command.c_str(),"r");
|
||||
if( p == NULL)
|
||||
{
|
||||
cerr << "Error executing " << command << endl;
|
||||
return -1;
|
||||
}
|
||||
pclose(p);
|
||||
return 0;
|
||||
}
|
||||
|
||||
string BashManager::ExecuteAndReadResult(string command)
|
||||
{
|
||||
string result="";
|
||||
char lineBuffer [4095]={0}; //4095 is the maximum length of a shell line
|
||||
FILE * p = popen(command.c_str(),"r");
|
||||
if( p == nullptr)
|
||||
{
|
||||
cerr << "Error executing "<< command << endl;
|
||||
}
|
||||
while(fgets(lineBuffer,sizeof(lineBuffer),p)){
|
||||
result += lineBuffer;
|
||||
//removing newline character
|
||||
if (!result.empty() && result[result.length()-1] == '\n') {
|
||||
result.erase(result.length()-1);
|
||||
}
|
||||
}
|
||||
pclose(p);
|
||||
return result;
|
||||
}
|
19
test/IntegrationTests/src/BashManager.h
Normal file
19
test/IntegrationTests/src/BashManager.h
Normal file
@ -0,0 +1,19 @@
|
||||
// deployer BashManager header
|
||||
// Copyright (C) 2024 Jean-Cloud
|
||||
// GNU General Public License v3
|
||||
|
||||
#if !defined(BASHMANAGER_H)
|
||||
#define BASHMANAGER_H
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
class BashManager
|
||||
{
|
||||
public:
|
||||
static string ExecuteAndReadResult(string command);
|
||||
static int Execute(string command);
|
||||
};
|
||||
|
||||
#endif
|
24
test/IntegrationTests/src/Makefile
Normal file
24
test/IntegrationTests/src/Makefile
Normal file
@ -0,0 +1,24 @@
|
||||
ECHO = @echo
|
||||
CP=@cp
|
||||
GCC = g++
|
||||
RM = @rm -f
|
||||
CCFLAGS = -c -O3 -g -std=c++20 -pedantic -Wall
|
||||
SRC = $(wildcard *.cpp)
|
||||
BIN = ../bin
|
||||
EXE = integrationTests
|
||||
OBJECTS = $(patsubst %.cpp,$(BIN)/%.o,$(SRC))
|
||||
LIBRARIES =
|
||||
|
||||
$(EXE) : $(OBJECTS)
|
||||
$(ECHO) "-Linking $(EXE)-"
|
||||
$(GCC) -o $@ $^ $(LIBRARIES)
|
||||
$(CP) $(EXE) ../../../testenv
|
||||
|
||||
$(BIN)/%.o:%.cpp
|
||||
$(ECHO) "-Compilation $<- "
|
||||
$(GCC) $(CCFLAGS) -o $@ $<
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(ECHO) "-Cleaning-"
|
||||
$(RM) $(OBJECTS) $(EXE)
|
BIN
test/IntegrationTests/src/integrationTests
Executable file
BIN
test/IntegrationTests/src/integrationTests
Executable file
Binary file not shown.
77
test/IntegrationTests/src/main.cpp
Normal file
77
test/IntegrationTests/src/main.cpp
Normal file
@ -0,0 +1,77 @@
|
||||
// deployer IntegrationTests main
|
||||
// Copyright (C) 2024 Jean-Cloud
|
||||
// GNU General Public License v3
|
||||
|
||||
#include <iostream>
|
||||
#include "BashManager.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void Help()
|
||||
{
|
||||
cout << "blabla" << endl;
|
||||
}
|
||||
|
||||
//tests
|
||||
void environmentTest()
|
||||
{
|
||||
cout << "Test of the environment setup." << endl;
|
||||
}
|
||||
|
||||
void bashTest()
|
||||
{
|
||||
cout << "Test of BashModule" << endl;
|
||||
}
|
||||
|
||||
void dockerTest()
|
||||
{
|
||||
cout << "Test of DockerModule" << endl;
|
||||
}
|
||||
|
||||
void nginxTest()
|
||||
{
|
||||
cout << "Test of Nginx module" << endl;
|
||||
}
|
||||
|
||||
void wireguardTest()
|
||||
{
|
||||
cout << "Test of WireguardModule" << endl;
|
||||
}
|
||||
|
||||
void encryptionTest()
|
||||
{
|
||||
cout << "Test of EncryptionModule" << endl;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if(argc!=2){
|
||||
cerr << "Invalid number of arguments." << endl;
|
||||
} else{
|
||||
BashManager::Execute("./deployer deploy all");
|
||||
string action=argv[1];
|
||||
if (action=="environment"){
|
||||
environmentTest();
|
||||
} else if (action=="bash"){
|
||||
bashTest();
|
||||
} else if (action=="docker"){
|
||||
dockerTest();
|
||||
} else if (action=="nginx"){
|
||||
nginxTest();
|
||||
} else if (action=="wireguard"){
|
||||
wireguardTest();
|
||||
} else if (action=="encryption"){
|
||||
encryptionTest();
|
||||
} else if (action=="all"){
|
||||
environmentTest();
|
||||
bashTest();
|
||||
dockerTest();
|
||||
nginxTest();
|
||||
wireguardTest();
|
||||
encryptionTest();
|
||||
} else {
|
||||
cerr << "Unknown argument." << endl;
|
||||
Help();
|
||||
}
|
||||
}
|
||||
}
|
BIN
test/IntegrationTests/testenv
Executable file
BIN
test/IntegrationTests/testenv
Executable file
Binary file not shown.
BIN
testenv/integrationTests
Executable file
BIN
testenv/integrationTests
Executable file
Binary file not shown.
Loading…
Reference in New Issue
Block a user