Commit d14aed5520c0263923b929feb28fd7f6e88dea28

Authored by Eric Menezes Noronha
1 parent a09bd2ce
Exists in master

usuario e senha do login com getter/setter, sendo setados no constructor do test

Showing 2 changed files with 30 additions and 15 deletions   Show diff stats
cacic-teste/testcacic.cpp
@@ -25,6 +25,8 @@ void CTestCacic::initTestCase() @@ -25,6 +25,8 @@ void CTestCacic::initTestCase()
25 "2.8.1.7", 25 "2.8.1.7",
26 "2.8.1.6"); 26 "2.8.1.6");
27 OCacicComm.setUrlSsl("https://10.1.0.137/cacic/web/app_dev.php"); 27 OCacicComm.setUrlSsl("https://10.1.0.137/cacic/web/app_dev.php");
  28 + OCacicComm.setUsuario("cacic");
  29 + OCacicComm.setPassword("cacic123");
28 this->testPath = QDir::currentPath() + "/teste"; 30 this->testPath = QDir::currentPath() + "/teste";
29 this->testIniPath = testPath + "/teste.ini"; 31 this->testIniPath = testPath + "/teste.ini";
30 QVariantMap json; 32 QVariantMap json;
@@ -106,12 +108,7 @@ void CTestCacic::testPegarUsu(){ @@ -106,12 +108,7 @@ void CTestCacic::testPegarUsu(){
106 } 108 }
107 109
108 void CTestCacic::testLogin(){ 110 void CTestCacic::testLogin(){
109 -  
110 - QVariantMap login;  
111 - login["user"] = "eric";  
112 - login["password"] = "612ef9b1";  
113 - OCacicComm.setUrlSsl("https://10.1.0.137/cacic/web/app_dev.php");  
114 - QJsonObject json = OCacicComm.comm("/ws/neo/login", QJsonObject::fromVariantMap(login), true); 111 + QJsonObject json = OCacicComm.login();
115 QJsonValue sessionvalue = OCacic.jsonValueFromJsonString(json["reply"].toString(), "session"); 112 QJsonValue sessionvalue = OCacic.jsonValueFromJsonString(json["reply"].toString(), "session");
116 // qDebug() << sessionvalue.toString(); 113 // qDebug() << sessionvalue.toString();
117 QVERIFY(!sessionvalue.isNull()); 114 QVERIFY(!sessionvalue.isNull());
src/cacic_comm.h
@@ -20,8 +20,8 @@ private: @@ -20,8 +20,8 @@ private:
20 QString urlGerente; 20 QString urlGerente;
21 QString urlSsl; 21 QString urlSsl;
22 // FIXME: Get from configuration 22 // FIXME: Get from configuration
23 - QString usuario = "user";  
24 - QString password = "123456"; 23 + QString usuario;
  24 + QString password;
25 std::string session; 25 std::string session;
26 26
27 public: 27 public:
@@ -148,14 +148,12 @@ public: @@ -148,14 +148,12 @@ public:
148 148
149 QJsonObject login() { 149 QJsonObject login() {
150 // Cria dados de login 150 // Cria dados de login
151 - QVariantMap loginMap;  
152 - loginMap["user"] = this->usuario;  
153 - loginMap["password"] = this->password;  
154 - QJsonObject loginJson = QJsonObject::fromVariantMap(loginMap);  
155 - 151 + QVariantMap login;
  152 + login["user"] = this->usuario;
  153 + login["password"] = this->password;
  154 +// QJsonValue sessionvalue = OCacic.jsonValueFromJsonString(json["reply"].toString(), "session");
156 // Cria conexão e retorna Json da sessão 155 // Cria conexão e retorna Json da sessão
157 - QJsonObject retorno = this->comm("/ws/get/test", loginJson);  
158 - 156 + QJsonObject retorno = this->comm("/ws/neo/login", QJsonObject::fromVariantMap(login), true);
159 return retorno; 157 return retorno;
160 158
161 } 159 }
@@ -168,6 +166,26 @@ public: @@ -168,6 +166,26 @@ public:
168 return this->urlSsl; 166 return this->urlSsl;
169 } 167 }
170 168
  169 + QString getPassword()
  170 + {
  171 + return password;
  172 + }
  173 +
  174 + void setPassword(QString value)
  175 + {
  176 + password = value;
  177 + }
  178 + QString getUsuario()
  179 + {
  180 + return usuario;
  181 + }
  182 +
  183 + void setUsuario(QString value)
  184 + {
  185 + usuario = value;
  186 + }
  187 +
  188 +
171 signals: 189 signals:
172 void finished(QNetworkReply* reply); 190 void finished(QNetworkReply* reply);
173 191