예제 #1
0
void veroRestApiTest() {
    // rest authenticate
    bool ret = restAuthenticate(KServerAddr, KPort, KUserName, KPassword);
    if (!ret) {
        report();
    }

    // rest projects
	std::map<string, string> projectMap;
	restListProjects(KServerAddr, KPort, KUserName, KPassword, projectMap);

	for (std::map<string, string>::iterator i = projectMap.begin(); i != projectMap.end(); i++) {
		cout << "Project = " << (*i).first << endl;
	}

    // rest meta
    std::unique_ptr<MetadataResponse> metaResponse = restGetMeta(KServerAddr, KPort, KUserName, KPassword, KDefaultProject);

	// rest query
	{
		std::unique_ptr<SQLResponse> y = restQuery(L"select Year", KServerAddr, KPort,
			KUserName, KPassword, KDefaultProject);

		if ((int)y->results.size() != 1) {
			report();
		}
	}
}
예제 #2
0
void restAPITest() {
    {
        bool ret = restAuthenticate ( KServerAddr, KPort, KUserName, KPassword );
        
        if ( !ret )
        { report(); }
    }
    {
        std::vector<string> holder;
        restListProjects ( KServerAddr, KPort, KUserName, KPassword, holder );
        
        if ( holder.size() == 0 )
        { report(); }
    }
    {
        std::unique_ptr<MetadataResponse> ret = restGetMeta ( KServerAddr, KPort, KUserName, KPassword, KDefaultProject );
    }
}
예제 #3
0
RETCODE   TryAuthenticate ( pODBCConn pgConn ) {
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "Start authenticating.." ) );
    
    try {
        bool authenticated = restAuthenticate ( pgConn->Server, pgConn->ServerPort, pgConn->UserName, pgConn->Password );
        
        if ( !authenticated )
        { throw exception ( "Username/Password incorrect." ); }
    }
    
    catch ( const exception& e ) {
        __ODBCLOG ( _ODBCLogMsg ( LogLevel_ERROR, "The REST request failed to authenticate." ) );
        __ODBCLOG ( _ODBCLogMsg ( LogLevel_ERROR, e.what() ) );
        _SQLPutDiagRow ( SQL_HANDLE_DBC, pgConn, "SQLDriverConnect", "HY000", 1045, "Access denied. (using password: NO)" );
        return SQL_ERROR;
    }
    
    __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "End authenticating" ) );
    return SQL_SUCCESS;
}