void testAllNonMatchingDialstrings() { FallbackRulesUrlMapping* urlmap; ResultSet registrations; UtlString actual; UtlString callTag = "UNK"; CPPUNIT_ASSERT( urlmap = new FallbackRulesUrlMapping() ); UtlString simpleXml; mFileTestContext->inputFilePath("fallbackrules.xml", simpleXml); CPPUNIT_ASSERT( urlmap->loadMappings(simpleXml.data() ) == OS_SUCCESS ); // use non-matching host name CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("boston"), registrations, callTag ) != OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 0 , registrations.getSize() ); registrations.destroyAll(); // use non-matching user name CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("boston"), registrations, callTag ) != OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 0 , registrations.getSize() ); registrations.destroyAll(); delete urlmap; }
void testExpireOldBindings() { Url uri; //UtlString contact; //UtlSList bindings; ResultSet results; int timeNow = (int)OsDateTime::getSecsSinceEpoch(); RegistrationDbTestContext testDbContext(TEST_DATA_DIR "/regdbdata", TEST_WORK_DIR "/regdbdata" ); testDbContext.inputFile("getUnexpiredContacts.xml"); RegistrationDB* regDb = RegistrationDB::getInstance(); uri.setUserId("900"); uri.setHostAddress("testdomain.example.com"); regDb->getUnexpiredContactsUser(uri, timeNow, results); int numResults = results.getSize(); CPPUNIT_ASSERT_EQUAL(2, numResults); results.destroyAll(); regDb->expireOldBindings(uri, "ID9", 900, timeNow, "seqOne", 7); regDb->getUnexpiredContactsUser(uri, timeNow, results); numResults = results.getSize(); CPPUNIT_ASSERT_EQUAL(1, numResults); }
void testAllNoDefaultPermutations() { FallbackRulesUrlMapping* urlmap; ResultSet registrations; UtlString actual; UtlString callTag = "UNK"; CPPUNIT_ASSERT( urlmap = new FallbackRulesUrlMapping() ); UtlString simpleXml; mFileTestContext->inputFilePath("fallbackrules.xml", simpleXml); CPPUNIT_ASSERT( urlmap->loadMappings(simpleXml.data() ) == OS_SUCCESS ); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("boston"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 2 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); getResult( registrations, 1, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("salem"), registrations, callTag ) != OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 0 , registrations.getSize() ); delete urlmap; }
void DialByNameDB::getContacts ( const UtlString& digitString, ResultSet& rResultSet ) const { // This should erase the contents of the existing resultset rResultSet.destroyAll(); if ( !digitString.isNull() && (m_pFastDB != NULL) ) { // Check the TableInfo table to see whether we need to reload // the Tables from the Credential/Permission tables SIPDBManager* pSIPDBManager = SIPDBManager::getInstance(); if ( pSIPDBManager->getDatabaseChangedFlag( "credential" ) || pSIPDBManager->getDatabaseChangedFlag( "permission" ) ) { // Reload this IMDB and rese the changed flags // in the credential and permission tables this->load(); } // Thread Local Storage m_pFastDB->attach(); // Search to see if we have a Credential Row dbCursor< DialByNameRow > cursor; dbQuery query; UtlString queryString = "np_digits like '" + digitString + "%'"; query = queryString; if ( cursor.select(query) > 0 ) { do { UtlHashMap record; UtlString* np_identityValue = new UtlString ( cursor->np_identity ); UtlString* np_contactValue = new UtlString ( cursor->np_contact ); UtlString* np_digitsValue = new UtlString ( cursor->np_digits ); // Memory Leak fixes, make shallow copies of static keys UtlString* np_identityKey = new UtlString( gNp_identityKey ); UtlString* np_contactKey = new UtlString( gNp_contactKey ); UtlString* np_digitsKey = new UtlString( gNp_digitsKey ); record.insertKeyAndValue ( np_identityKey, np_identityValue ); record.insertKeyAndValue ( np_contactKey, np_contactValue ); record.insertKeyAndValue ( np_digitsKey, np_digitsValue ); rResultSet.addValue(record); } while ( cursor.next() ); } // Commit the rows to memory - multiprocess workaround m_pFastDB->detach(0); } }
void testAllInternationalPermutations() { FallbackRulesUrlMapping* urlmap; ResultSet registrations; UtlString actual; UtlString callTag = "UNK"; CPPUNIT_ASSERT( urlmap = new FallbackRulesUrlMapping() ); UtlString simpleXml; mFileTestContext->inputFilePath("fallbackrules.xml", simpleXml); CPPUNIT_ASSERT( urlmap->loadMappings(simpleXml.data() ) == OS_SUCCESS ); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("Boston"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString(""), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("ogden"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); delete urlmap; }
void DialByNameDB::getAllRows(ResultSet& rResultSet) const { // Clear the results rResultSet.destroyAll(); // Check the TableInfo table to see whether we need to reload // the Tables from the Credential/Permission tables if ( m_pFastDB != NULL ) { SIPDBManager* pSIPDBManager = SIPDBManager::getInstance(); if ( pSIPDBManager->getDatabaseChangedFlag( "credential" ) || pSIPDBManager->getDatabaseChangedFlag( "permission" ) ) { // Reload this IMDB and reset the changed flags // in both the credential and permission tables this->load(); } // Thread Local Storage m_pFastDB->attach(); dbCursor< DialByNameRow > cursor; if ( cursor.select() > 0 ) { do { UtlHashMap record; UtlString* np_identityValue = new UtlString ( cursor->np_identity ); UtlString* np_contactValue = new UtlString ( cursor->np_contact ); UtlString* np_digitsValue = new UtlString ( cursor->np_digits ); // Memory Leak fixes, make shallow copies of static keys UtlString* np_identityKey = new UtlString( gNp_identityKey ); UtlString* np_contactKey = new UtlString( gNp_contactKey ); UtlString* np_digitsKey = new UtlString( gNp_digitsKey ); record.insertKeyAndValue ( np_identityKey, np_identityValue ); record.insertKeyAndValue ( np_contactKey, np_contactValue ); record.insertKeyAndValue ( np_digitsKey, np_digitsValue ); rResultSet.addValue(record); } while (cursor.next()); } // Commit rows to memory - multiprocess workaround m_pFastDB->detach(0); } }
void CredentialDB::getAllRows( ResultSet& rResultSet ) const { // Clear the out any previous records rResultSet.destroyAll(); if (m_pFastDB != NULL) { // must do this first to ensure process/tls integrity m_pFastDB->attach(); dbCursor< CredentialRow > cursor; if ( cursor.select() > 0 ) { do { UtlHashMap record; UtlString* uriValue = new UtlString ( cursor->uri ); UtlString* realmValue = new UtlString ( cursor->realm ); UtlString* useridValue = new UtlString ( cursor->userid ); UtlString* passtokenValue = new UtlString ( cursor->passtoken ); UtlString* pintokenValue = new UtlString ( cursor->pintoken ); UtlString* authtypeValue = new UtlString ( cursor->authtype ); // Memory Leak fixes, make shallow copies of static keys UtlString* uriKey = new UtlString( gUriKey ); UtlString* realmKey = new UtlString( gRealmKey ); UtlString* useridKey = new UtlString( gUseridKey ); UtlString* passtokenKey = new UtlString( gPasstokenKey ); UtlString* pintokenKey = new UtlString( gPintokenKey ); UtlString* authtypeKey = new UtlString( gAuthtypeKey ); record.insertKeyAndValue ( uriKey, uriValue ); record.insertKeyAndValue ( realmKey, realmValue ); record.insertKeyAndValue ( useridKey, useridValue ); record.insertKeyAndValue ( passtokenKey, passtokenValue ); record.insertKeyAndValue ( pintokenKey, pintokenValue ); record.insertKeyAndValue ( authtypeKey, authtypeValue ); rResultSet.addValue(record); } while (cursor.next()); } // commit rows and also ensure process/tls integrity m_pFastDB->detach(0); } }
void RegistrationDB::getAllRows ( ResultSet& rResultSet ) const { // Clear out any previous records rResultSet.destroyAll(); if ( m_pFastDB != NULL ) { SMART_DB_ACCESS; dbCursor< RegistrationRow > cursor; if ( cursor.select() > 0 ) { do { UtlHashMap record; UtlString* uriValue = new UtlString(cursor->uri); UtlString* callidValue = new UtlString(cursor->callid); UtlString* contactValue = new UtlString(cursor->contact); UtlInt* expiresValue = new UtlInt(cursor->expires); UtlInt* cseqValue = new UtlInt(cursor->cseq); UtlString* qvalueValue = new UtlString(cursor->qvalue); UtlString* primaryValue = new UtlString(cursor->primary); UtlLongLongInt* updateNumberValue = new UtlLongLongInt(cursor->update_number); // Memory Leak fixes, make shallow copies of static keys UtlString* uriKey = new UtlString(gUriKey); UtlString* callidKey = new UtlString(gCallidKey); UtlString* contactKey = new UtlString(gContactKey); UtlString* expiresKey = new UtlString(gExpiresKey); UtlString* cseqKey = new UtlString(gCseqKey); UtlString* qvalueKey = new UtlString(gQvalueKey); UtlString* primaryKey = new UtlString(gPrimaryKey); UtlString* updateNumberKey = new UtlString(gUpdateNumberKey); record.insertKeyAndValue(uriKey, uriValue); record.insertKeyAndValue(callidKey, callidValue); record.insertKeyAndValue(contactKey, contactValue); record.insertKeyAndValue(expiresKey, expiresValue); record.insertKeyAndValue(cseqKey, cseqValue); record.insertKeyAndValue(qvalueKey, qvalueValue); record.insertKeyAndValue(primaryKey, primaryValue); record.insertKeyAndValue(updateNumberKey, updateNumberValue); rResultSet.addValue(record); } while (cursor.next()); } } else { OsSysLog::add(FAC_DB, PRI_CRIT, "RegistrationDB::getAllRows failed - no DB"); } }
void PermissionDB::getIdentities ( const UtlString& permission, ResultSet& rResultSet ) const { // This should erase the contents of the existing resultset rResultSet.destroyAll(); if ( !permission.isNull() && (m_pFastDB != NULL) ) { // Thread Local Storage m_pFastDB->attach(); dbQuery query; // Primary Key is the uriPermission's identity query="permission=", permission; // Search to see if we have a Credential Row dbCursor< PermissionRow > cursor; if ( cursor.select(query) > 0 ) { do { UtlHashMap record; UtlString* identityValue = new UtlString ( cursor->identity ); UtlString* permissionValue = new UtlString ( cursor->permission ); // Memory Leak fixes, make shallow copies of static keys UtlString* identityKey = new UtlString( gIdentityKey ); UtlString* permissionKey = new UtlString( gPermissionKey ); record.insertKeyAndValue ( identityKey, identityValue ); record.insertKeyAndValue ( permissionKey, permissionValue ); rResultSet.addValue(record); } while ( cursor.next() ); } // Commit the rows to memory - multiprocess workaround m_pFastDB->detach(0); } }
void testRouteHeaderPermutations() { FallbackRulesUrlMapping* urlmap; ResultSet registrations; UtlString actual; CPPUNIT_ASSERT( urlmap = new FallbackRulesUrlMapping() ); UtlString simpleXml; mFileTestContext->inputFilePath("fallbackrules.xml", simpleXml); CPPUNIT_ASSERT( urlmap->loadMappings(simpleXml.data() ) == OS_SUCCESS ); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("ogden"), registrations ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("<sip:[email protected]?route=sbc.example.edu>",actual); registrations.destroyAll(); delete urlmap; }
void ExtensionDB::getAllRows(ResultSet& rResultSet) const { // Clear the out any previous records rResultSet.destroyAll(); if ( m_pFastDB != NULL ) { // must do this first to ensure process/tls integrity m_pFastDB->attach(); dbCursor< ExtensionRow > cursor; if ( cursor.select() > 0 ) { do { UtlHashMap record; UtlString* uriValue = new UtlString ( cursor->uri ); UtlString* extensionValue = new UtlString ( cursor->extension ); // Memory Leak fixes, make shallow copies of static keys UtlString* uriKey = new UtlString( gUriKey ); UtlString* extensionKey = new UtlString( gExtensionKey ); record.insertKeyAndValue ( uriKey, uriValue ); record.insertKeyAndValue ( extensionKey, extensionValue ); rResultSet.addValue(record); } while (cursor.next()); } // commit rows and also ensure process/tls integrity m_pFastDB->detach(0); } }
void UserForwardDB::getAllRows(ResultSet& rResultSet) const { // Clear the out any previous records rResultSet.destroyAll(); if (m_pFastDB != NULL) { // must do this first to ensure process/tls integrity m_pFastDB->attach(); dbCursor< UserForwardRow > cursor; if ( cursor.select() > 0 ) { do { UtlHashMap record; UtlString* identityValue = new UtlString ( cursor->identity ); UtlString* cfwdtimeValue = new UtlString ( cursor->cfwdtime ); // Memory Leak fixes, make shallow copies of static keys UtlString* identityKey = new UtlString( gIdentityKey ); UtlString* cfwdtimeKey = new UtlString( gCfwdtimeKey ); record.insertKeyAndValue ( identityKey, identityValue ); record.insertKeyAndValue ( cfwdtimeKey, cfwdtimeValue ); rResultSet.addValue(record); } while (cursor.next()); } // commit rows and also ensure process/tls integrity m_pFastDB->detach(0); } }
void UserLocationDB::getAllRows(ResultSet& rResultSet) const { // Clear the results rResultSet.destroyAll(); if ( m_pFastDB != NULL ) { // Thread Local Storage m_pFastDB->attach(); dbCursor< UserLocationRow > cursor; if ( cursor.select() > 0 ) { do { UtlHashMap record; UtlString* identityValue = new UtlString ( cursor->identity ); UtlString* locationValue = new UtlString ( cursor->location ); // Memory Leak fixes, make shallow copies of static keys UtlString* identityKey = new UtlString( gIdentityKey ); UtlString* locationKey = new UtlString( gLocationKey ); record.insertKeyAndValue ( identityKey, identityValue ); record.insertKeyAndValue ( locationKey, locationValue ); rResultSet.addValue(record); } while (cursor.next()); } // Commit rows to memory - multiprocess workaround m_pFastDB->detach(0); } }
void testAll800Permutations() { FallbackRulesUrlMapping* urlmap; ResultSet registrations; UtlString actual; UtlString callTag = "UNK"; CPPUNIT_ASSERT( urlmap = new FallbackRulesUrlMapping() ); UtlString simpleXml; mFileTestContext->inputFilePath("fallbackrules.xml", simpleXml); CPPUNIT_ASSERT( urlmap->loadMappings(simpleXml.data() ) == OS_SUCCESS ); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("boston"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("regina"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString(""), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("new-york"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("DC"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("Philly"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString(""), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("miami"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("orlando"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); delete urlmap; }
void testAuthRules() { AuthRulesUrlMapping* urlmap; ResultSet permissions; UtlString actual; CPPUNIT_ASSERT( urlmap = new AuthRulesUrlMapping() ); UtlString simpleXml; mFileTestContext->inputFilePath("authrules.xml", simpleXml); CPPUNIT_ASSERT( urlmap->loadMappings(simpleXml.data(), MS, VM, LH ) == OS_SUCCESS ); // the interface says getContactList returns an OsStatus, // but it is not set so don't test it urlmap->getPermissionRequired( Url("sip:[email protected]") , permissions ); CPPUNIT_ASSERT_EQUAL( 4 , permissions.getSize() ); getResult( permissions, 0, "permission", actual); ASSERT_STR_EQUAL("steal",actual); getResult( permissions, 1, "permission", actual); ASSERT_STR_EQUAL("lie",actual); getResult( permissions, 2, "permission", actual); ASSERT_STR_EQUAL("cheat",actual); getResult( permissions, 3, "permission", actual); ASSERT_STR_EQUAL("eat like a pig",actual); permissions.destroyAll(); urlmap->getPermissionRequired( Url("sip:THISUSER@THISDOMAIN") ,permissions ); CPPUNIT_ASSERT_EQUAL( 4 , permissions.getSize() ); getResult( permissions, 0, "permission", actual); ASSERT_STR_EQUAL("steal",actual); getResult( permissions, 1, "permission", actual); ASSERT_STR_EQUAL("lie",actual); getResult( permissions, 2, "permission", actual); ASSERT_STR_EQUAL("cheat",actual); getResult( permissions, 3, "permission", actual); ASSERT_STR_EQUAL("eat like a pig",actual); permissions.destroyAll(); urlmap->getPermissionRequired( Url("sip:[email protected]") , permissions ); CPPUNIT_ASSERT_EQUAL( 4 , permissions.getSize() ); getResult( permissions, 0, "permission", actual); ASSERT_STR_EQUAL("steal",actual); getResult( permissions, 1, "permission", actual); ASSERT_STR_EQUAL("lie",actual); getResult( permissions, 2, "permission", actual); ASSERT_STR_EQUAL("cheat",actual); getResult( permissions, 3, "permission", actual); ASSERT_STR_EQUAL("eat like a pig",actual); permissions.destroyAll(); urlmap->getPermissionRequired( Url("sip:THATUSER@THISDOMAIN") , permissions ); CPPUNIT_ASSERT_EQUAL( 4 , permissions.getSize() ); getResult( permissions, 0, "permission", actual); ASSERT_STR_EQUAL("steal",actual); getResult( permissions, 1, "permission", actual); ASSERT_STR_EQUAL("lie",actual); getResult( permissions, 2, "permission", actual); ASSERT_STR_EQUAL("cheat",actual); getResult( permissions, 3, "permission", actual); ASSERT_STR_EQUAL("eat like a pig",actual); permissions.destroyAll(); urlmap->getPermissionRequired( Url("sip:[email protected]") , permissions ); CPPUNIT_ASSERT_EQUAL( 0 , permissions.getSize() ); urlmap->getPermissionRequired( Url("sip:OTHERUSER@THISDOMAIN") , permissions ); CPPUNIT_ASSERT_EQUAL( 0 , permissions.getSize() ); urlmap->getPermissionRequired( Url("sip:[email protected]") , permissions ); CPPUNIT_ASSERT_EQUAL( 0 , permissions.getSize() ); urlmap->getPermissionRequired( Url("sip:THISUSER@OTHERDOMAIN") , permissions ); CPPUNIT_ASSERT_EQUAL( 0 , permissions.getSize() ); urlmap->getPermissionRequired( Url("sip:THISUSER@UserChgDOMAIN") , permissions ); CPPUNIT_ASSERT_EQUAL( 0 , permissions.getSize() ); urlmap->getPermissionRequired( Url("sip:THATUSER@UserChgDOMAIN") , permissions ); CPPUNIT_ASSERT_EQUAL( 0 , permissions.getSize() ); urlmap->getPermissionRequired( Url("sip:OTHERUSER@UserChgDOMAIN") , permissions ); CPPUNIT_ASSERT_EQUAL( 0 , permissions.getSize() ); urlmap->getPermissionRequired( Url("sip:THISUSER@HostChgDOMAIN") , permissions ); CPPUNIT_ASSERT_EQUAL( 0 , permissions.getSize() ); urlmap->getPermissionRequired( Url("sip:THATUSER@HostChgDOMAIN") , permissions ); CPPUNIT_ASSERT_EQUAL( 0 , permissions.getSize() ); // do the domain transformtion again and check that the transport is removed [XRR-114] urlmap->getPermissionRequired( Url("<sip:THATUSER@HostChgDOMAIN;transport=xyz>") , permissions ); CPPUNIT_ASSERT_EQUAL( 0, permissions.getSize() ); urlmap->getPermissionRequired( Url("sip:OTHERUSER@UserChgDOMAIN") , permissions ); CPPUNIT_ASSERT_EQUAL( 0 , permissions.getSize() ); // Check the hostPattern format='url' urlmap->getPermissionRequired( Url("sip:[email protected]:4242") , permissions ); CPPUNIT_ASSERT_EQUAL( 1 , permissions.getSize() ); getResult( permissions, 0, "permission", actual); ASSERT_STR_EQUAL( "NoAccess", actual ); permissions.destroyAll(); // Check the hostPattern format='DnsWildcard' urlmap->getPermissionRequired( Url("sip:[email protected]") , permissions ); CPPUNIT_ASSERT_EQUAL( 1 , permissions.getSize() ); getResult( permissions, 0, "permission", actual); ASSERT_STR_EQUAL( "NoAccess", actual ); permissions.destroyAll(); // Check the hostPattern format='IPv4subnet' urlmap->getPermissionRequired( Url("sip:[email protected]") , permissions ); CPPUNIT_ASSERT_EQUAL( 1 , permissions.getSize() ); getResult( permissions, 0, "permission", actual); ASSERT_STR_EQUAL( "NoAccess", actual ); permissions.destroyAll(); // Check the hostPattern format='IPv4subnet' (nomatch) urlmap->getPermissionRequired( Url("sip:[email protected]") , permissions ); CPPUNIT_ASSERT_EQUAL( 0 , permissions.getSize() ); delete urlmap; }
void RegistrationDB::getUnexpiredContacts ( const Url& uri, const int& timeNow, ResultSet& rResultSet) const { // Clear the results rResultSet.destroyAll(); UtlString identity; uri.getIdentity( identity ); if ( !identity.isNull() && ( m_pFastDB != NULL) ) { SMART_DB_ACCESS; dbCursor< RegistrationRow > cursor; dbQuery query; OsSysLog::add(FAC_SIP, PRI_DEBUG, "RegistrationDB::getUnexpiredContacts " "identity = '%s'", identity.data()); if (strncmp(identity.data(), GRUU_PREFIX, sizeof (GRUU_PREFIX) - 1) == 0) { // This is a GRUU, search for it in the gruu column. query="gruu=",identity," and expires>",timeNow; OsSysLog::add(FAC_DB, PRI_DEBUG, "RegistrationDB::getUnexpiredContacts recognized GRUU"); } else { // This is not a GRUU, search for it in the identity column. query="np_identity=",identity," and expires>",timeNow; } if ( cursor.select(query) > 0 ) { // Copy all the unexpired contacts into the result hash do { UtlHashMap record; UtlString* uriValue = new UtlString(cursor->uri); UtlString* callidValue = new UtlString(cursor->callid); UtlString* contactValue = new UtlString(cursor->contact); UtlInt* expiresValue = new UtlInt(cursor->expires); UtlInt* cseqValue = new UtlInt(cursor->cseq); UtlString* qvalueValue = new UtlString(cursor->qvalue); UtlString* primaryValue = new UtlString(cursor->primary); UtlLongLongInt* updateNumberValue = new UtlLongLongInt(cursor->update_number); UtlString* instanceIdValue = new UtlString(cursor->instance_id); UtlString* gruuValue = new UtlString(cursor->gruu); UtlString* pathValue = new UtlString(cursor->path); OsSysLog::add(FAC_DB, PRI_DEBUG, "RegistrationDB::getUnexpiredContacts Record found " "uri = '%s', contact = '%s', instance_id = '%s', " "gruu = '%s', path = '%s'", uriValue->data(), contactValue->data(), instanceIdValue->data(), gruuValue->data(), pathValue->data()); // Memory Leak fixes, make shallow copies of static keys UtlString* uriKey = new UtlString(gUriKey); UtlString* callidKey = new UtlString(gCallidKey); UtlString* contactKey = new UtlString(gContactKey); UtlString* expiresKey = new UtlString(gExpiresKey); UtlString* cseqKey = new UtlString(gCseqKey); UtlString* qvalueKey = new UtlString(gQvalueKey); UtlString* primaryKey = new UtlString(gPrimaryKey); UtlString* updateNumberKey = new UtlString(gUpdateNumberKey); UtlString* instanceIdKey = new UtlString(gInstanceIdKey); UtlString* gruuKey = new UtlString(gGruuKey); UtlString* pathKey = new UtlString(gPathKey); record.insertKeyAndValue(uriKey, uriValue); record.insertKeyAndValue(callidKey, callidValue); record.insertKeyAndValue(contactKey, contactValue); record.insertKeyAndValue(expiresKey, expiresValue); record.insertKeyAndValue(cseqKey, cseqValue); record.insertKeyAndValue(qvalueKey, qvalueValue); record.insertKeyAndValue(primaryKey, primaryValue); record.insertKeyAndValue(updateNumberKey, updateNumberValue); record.insertKeyAndValue(instanceIdKey, instanceIdValue); record.insertKeyAndValue(gruuKey, gruuValue); record.insertKeyAndValue(pathKey, pathValue); rResultSet.addValue(record); } while ( cursor.next() ); } } else { OsSysLog::add(FAC_DB, PRI_CRIT, "RegistrationDB::getUnexpiredContacts failed - no DB"); } }
void testAllLongDistancePermutations() { FallbackRulesUrlMapping* urlmap; ResultSet registrations; UtlString actual; UtlString callTag = "UNK"; CPPUNIT_ASSERT( urlmap = new FallbackRulesUrlMapping() ); UtlString simpleXml; mFileTestContext->inputFilePath("fallbackrules.xml", simpleXml); CPPUNIT_ASSERT( urlmap->loadMappings(simpleXml.data() ) == OS_SUCCESS ); // permutations for the 'boston' location CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("boston"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 2 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("<sip:[email protected]>;q=0.9",actual); getResult( registrations, 1, "contact", actual); ASSERT_STR_EQUAL("<sip:[email protected]>;q=0.8",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("boston"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 2 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("<sip:[email protected]>;q=0.9",actual); getResult( registrations, 1, "contact", actual); ASSERT_STR_EQUAL("<sip:[email protected]>;q=0.8",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("boston"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 2 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("<sip:[email protected]>;q=0.9",actual); getResult( registrations, 1, "contact", actual); ASSERT_STR_EQUAL("<sip:[email protected]>;q=0.8",actual); registrations.destroyAll(); // permutations for the 'seattle' location CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("seattle"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 2 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("<sip:[email protected]>;q=0.9",actual); getResult( registrations, 1, "contact", actual); ASSERT_STR_EQUAL("<sip:[email protected]>;q=0.7",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("seattle"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 2 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("<sip:[email protected]>;q=0.9",actual); getResult( registrations, 1, "contact", actual); ASSERT_STR_EQUAL("<sip:[email protected]>;q=0.7",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("seattle"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 2 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("<sip:[email protected]>;q=0.9",actual); getResult( registrations, 1, "contact", actual); ASSERT_STR_EQUAL("<sip:[email protected]>;q=0.7",actual); registrations.destroyAll(); // permutations for the other locations CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("walla-walla"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString(""), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("ogden"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); delete urlmap; }
void testAllEmergencyPermutations() { FallbackRulesUrlMapping* urlmap; ResultSet registrations; UtlString actual; UtlString callTag = "UNK"; CPPUNIT_ASSERT( urlmap = new FallbackRulesUrlMapping() ); UtlString simpleXml; mFileTestContext->inputFilePath("fallbackrules.xml", simpleXml); CPPUNIT_ASSERT( urlmap->loadMappings(simpleXml.data() ) == OS_SUCCESS ); // permutations for the 'boston' location CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("boston"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("boston"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("boston"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("boston"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("boston"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("boston"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("boston"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("boston"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("boston"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); // permutation for the 'seattle' location CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("seattle"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("seattle"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("seattle"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("seattle"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("seattle"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("seattle"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("seattle"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("seattle"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("seattle"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); // permutation for the default location CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("Kookamonga"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("Kookamonga"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("Kookamonga"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("Kookamonga"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("Kookamonga"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("Kookamonga"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("Kookamonga"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("Kookamonga"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString("Kookamonga"), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]") ,UtlString(""), registrations, callTag ) == OS_SUCCESS ); CPPUNIT_ASSERT_EQUAL( 1 , registrations.getSize() ); getResult( registrations, 0, "contact", actual); ASSERT_STR_EQUAL("sip:[email protected]",actual); registrations.destroyAll(); delete urlmap; }