ReactOS 0.4.16-dev-1946-g52006dd
CWebService.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Automatic Testing Utility
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Class implementing the interface to the "testman" Web Service
5 * COPYRIGHT: Copyright 2009-2020 Colin Finck (colin@reactos.org)
6 */
7
8#include "precomp.h"
9
10static const CHAR szHostname[] = "reactos.org";
11static const INTERNET_PORT ServerPort = 8443;
12static const CHAR szServerFile[] = "testman/webservice/";
13
18{
19 /* Zero-initialize variables */
20 m_TestID = NULL;
21}
22
27{
28 if(m_TestID)
29 delete m_TestID;
30}
31
38void
39CWebService::Finish(const char* TestType)
40{
42 string Data;
44
45 if (!m_TestID)
46 EXCEPTION("CWebService::Finish was called, but not a single result had been submitted!\n");
47
48 Data = "action=finish";
49 Data += Configuration.GetAuthenticationRequestString();
50 Data += "&testtype=";
51 Data += TestType;
52 Data += "&testid=";
53 Data += m_TestID;
54
56
57 if (strcmp(Response, "OK"))
58 {
59 ss << "When finishing the test run, the server responded:" << endl << Response << endl;
61 }
62}
63
70void
71CWebService::GetTestID(const char* TestType)
72{
73 string Data;
74
75 Data = "action=gettestid";
76 Data += Configuration.GetAuthenticationRequestString();
77 Data += Configuration.GetSystemInfoRequestString();
78 Data += "&testtype=";
79 Data += TestType;
80
81 if(!Configuration.GetComment().empty())
82 {
83 Data += "&comment=";
84 Data += Configuration.GetComment();
85 }
86
88
89 /* Verify that this is really a number */
90 if(!IsNumber(m_TestID))
91 {
93
94 ss << "Expected Test ID, but received:" << endl << m_TestID << endl;
96 }
97}
98
112PCHAR
113CWebService::GetSuiteID(const char* TestType, CTestInfo* TestInfo)
114{
115 auto_array_ptr<char> SuiteID;
116 string Data;
117
118 Data = "action=getsuiteid";
119 Data += Configuration.GetAuthenticationRequestString();
120 Data += "&testtype=";
121 Data += TestType;
122 Data += "&module=";
123 Data += TestInfo->Module;
124 Data += "&test=";
125 Data += TestInfo->Test;
126
128
129 /* Verify that this is really a number */
130 if(!IsNumber(SuiteID))
131 {
133
134 ss << "Expected Suite ID, but received:" << endl << SuiteID << endl;
136 }
137
138 return SuiteID.release();
139}
140
150void
151CWebService::Submit(const char* TestType, CTestInfo* TestInfo)
152{
154 auto_array_ptr<char> SuiteID;
155 string Data;
157
158 if(!m_TestID)
159 GetTestID(TestType);
160
161 SuiteID.reset(GetSuiteID(TestType, TestInfo));
162
163 Data = "action=submit";
164 Data += Configuration.GetAuthenticationRequestString();
165 Data += "&testtype=";
166 Data += TestType;
167 Data += "&testid=";
168 Data += m_TestID;
169 Data += "&suiteid=";
170 Data += SuiteID;
171 Data += "&log=";
172 Data += EscapeString(TestInfo->Log);
173
175
176 if (strcmp(Response, "OK"))
177 {
178 ss << "When submitting the result, the server responded:" << endl << Response << endl;
180 }
181}
static const CHAR szServerFile[]
Definition: CWebService.cpp:12
static const CHAR szHostname[]
Definition: CWebService.cpp:10
static const INTERNET_PORT ServerPort
Definition: CWebService.cpp:11
basic_ostream< _CharT, _Traits > &_STLP_CALL endl(basic_ostream< _CharT, _Traits > &__os)
Definition: _ostream.h:357
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
string Log
Definition: CTestInfo.h:14
string Module
Definition: CTestInfo.h:12
string Test
Definition: CTestInfo.h:13
void GetTestID(const char *TestType)
Definition: CWebService.cpp:71
void Finish(const char *TestType)
Definition: CWebService.cpp:39
virtual ~CWebService()
Definition: CWebService.cpp:26
void Submit(const char *TestType, CTestInfo *TestInfo)
PCHAR GetSuiteID(const char *TestType, CTestInfo *TestInfo)
PCHAR m_TestID
Definition: CWebService.h:11
virtual PCHAR DoRequest(const char *Hostname, INTERNET_PORT Port, const char *ServerFile, const string &InputData)=0
Type * release()
void reset(Type *Ptr=0)
#define NULL
Definition: types.h:112
#define ss
Definition: i386-dis.c:441
#define SSEXCEPTION
Definition: precomp.h:60
#define EXCEPTION(Message)
Definition: precomp.h:58
bool IsNumber(const char *Input)
Definition: tools.cpp:74
string EscapeString(const char *Input)
Definition: tools.cpp:24
Definition: ncftp.h:89
char * PCHAR
Definition: typedefs.h:51
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_INTERRUPT_CONFIG Configuration
Definition: wdfinterrupt.h:374
WORD INTERNET_PORT
Definition: winhttp.h:38
char CHAR
Definition: xmlstorage.h:175