Commit ce781e2b8c3e7e8bad0b859b8963a4ffd1e501c4

Authored by Eric Menezes Noronha
2 parents 838ed1ba 618b7fb6
Exists in master

Merge branch 'master' of https://github.com/lightbase/cacic-agente

Conflicts:
	cacic-teste/testcacic.cpp
	cacic-teste/testcacic.h
cacic-teste/cacic-teste.pro
... ... @@ -21,7 +21,8 @@ SOURCES += \
21 21 testcacic.cpp \
22 22 ../src/ccacic.cpp \
23 23 ../src/cacic_computer.cpp \
24   - ../src/operatingsystem.cpp
  24 + ../src/operatingsystem.cpp \
  25 + ../gercols/gercols.cpp
25 26  
26 27  
27 28 HEADERS += \
... ... @@ -30,7 +31,8 @@ HEADERS += \
30 31 ../src/cacic_computer.h \
31 32 ../src/cacic_comm.h \
32 33 ../src/console.h \
33   - ../src/operatingsystem.h
  34 + ../src/operatingsystem.h \
  35 + ../gercols/gercols.cpp
34 36  
35 37 INCLUDEPATH += ../src \
36 38 ../src/crypto++/include/
... ...
cacic-teste/testcacic.cpp
... ... @@ -86,6 +86,14 @@ void CTestCacic::testInterfaceDeRede(){
86 86 QVERIFY2(!OCacicComp.getNetworkInterface().empty(), "Nenhuma interface de rede encontrada.");
87 87 }
88 88  
  89 +void CTestCacic::testcoletaIdOs(){
  90 + // instancia um OperatingSystem que invoca coletaIdOs() no construtor
  91 + OperatingSystem OS;
  92 +
  93 +// QVERIFY(OS.getIdOs() == OperatingSystem::LINUX_ARCH);
  94 + QVERIFY(OS.getIdOs() != -1);
  95 +}
  96 +
89 97 void CTestCacic::testpegarOS(){
90 98 //basta que seja um retorno válido, não precisa validar todos.
91 99 QVERIFY(OCacicComp.getOs().getIdOs() != -1 );
... ... @@ -198,7 +206,31 @@ void CTestCacic::testStartService()
198 206 QVERIFY(ok);
199 207 }
200 208  
  209 +void CTestCacic::testReadConfig()
  210 +{
  211 +
  212 + // Inicializa um arquivo de configuração stub
  213 + // que seria parecido com o recebido do Gerente
  214 + QJsonObject configJson;
  215 + QJsonObject configHardware;
  216 + QJsonObject configSoftware;
  217 +
  218 + configHardware["network_interface"] = QJsonValue::fromVariant(QString(""));
  219 + configSoftware["operating_system"] = QJsonValue::fromVariant(QString(""));
  220 +
  221 + configJson["hardware"] = configHardware;
  222 + configJson["software"] = configSoftware;
  223 +
  224 + OCacic.setJsonToFile(configJson,"configRequest.json");
  225 +
  226 + // Leitura do arquivo de configuração
  227 + OGercols.readConfig();
  228 +
  229 + QVERIFY(OGercols.getConfigJson() == configJson);
  230 +}
  231 +
201 232 void CTestCacic::cleanupTestCase()
202 233 {
  234 + OCacic.deleteFile("configRequest.json");
203 235 OCacic.deleteFile("teste.json");
204 236 }
... ...
cacic-teste/testcacic.h
... ... @@ -5,6 +5,7 @@
5 5 #include <ccacic.h>
6 6 #include <cacic_computer.h>
7 7 #include <console.h>
  8 +#include <operatingsystem.h>
8 9 #include <QtTest/QtTest>
9 10 #include <QDebug>
10 11 #include <QList>
... ... @@ -14,6 +15,7 @@
14 15 #include <QtNetwork/QtNetwork>
15 16 #include <QJsonObject>
16 17 #include "../install-cacic/installcacic.h"
  18 +#include "../gercols/gercols.h"
17 19  
18 20 class CTestCacic : public QObject
19 21 {
... ... @@ -25,6 +27,7 @@ private:
25 27 CacicComm OCacicComm;
26 28 CCacic OCacic;
27 29 CACIC_Computer OCacicComp;
  30 + Gercols OGercols;
28 31 QString testPath;
29 32 QString testIniPath;
30 33 QJsonObject session;
... ... @@ -47,6 +50,7 @@ private slots:
47 50 void testConsole();
48 51 void testPegarUsu();
49 52 void testJsonValueFromJsonString();
  53 + void testcoletaIdOs();
50 54 void testpegarOS();
51 55 void testLogin();
52 56 void testSslConnection();
... ... @@ -58,6 +62,7 @@ private slots:
58 62 void testJsonToFile();
59 63 void testJsonFromFile();
60 64 void testStartService();
  65 + void testReadConfig();
61 66 void cleanupTestCase();
62 67 };
63 68  
... ...
gercols/gercols.cpp 0 → 100644
... ... @@ -0,0 +1,15 @@
  1 +#include "gercols.h"
  2 +
  3 +Gercols::Gercols()
  4 +{
  5 +}
  6 +
  7 +void Gercols::readConfig()
  8 +{
  9 +
  10 +}
  11 +
  12 +QJsonObject Gercols::getConfigJson()
  13 +{
  14 + return QJsonObject();
  15 +}
... ...
gercols/gercols.h 0 → 100644
... ... @@ -0,0 +1,15 @@
  1 +#ifndef GERCOLS_H
  2 +#define GERCOLS_H
  3 +
  4 +#include <QJsonObject>
  5 +
  6 +class Gercols
  7 +{
  8 +public:
  9 + Gercols();
  10 +
  11 + void readConfig();
  12 + QJsonObject getConfigJson();
  13 +};
  14 +
  15 +#endif // GERCOLS_H
... ...
gercols/gercols.pro
... ... @@ -23,13 +23,17 @@ TEMPLATE = app
23 23 SOURCES += \
24 24 main.cpp \
25 25 ../src/ccacic.cpp \
26   - ../src/cacic_computer.cpp
  26 + ../src/cacic_computer.cpp \
  27 + ../src/operatingsystem.cpp \
  28 + ./gercols.cpp
27 29  
28 30  
29 31 HEADERS += \
30 32 ../src/ccacic.h \
31 33 ../src/cacic_computer.h \
32   - ../src/cacic_comm.h
  34 + ../src/operatingsystem.h \
  35 + ../src/console.h \
  36 + ./gercols.h
33 37  
34 38 INCLUDEPATH += ../src \
35 39 ../src/crypto++/include/
... ...