示例#1
0
/**
@SYMTestCaseID SYSLIB-DBMS-CT-0008
@SYMTestCaseDesc Database tests. Some of the calls must fail because the caller has no enough rights
                 for the requested operation.
@SYMTestPriority High
@SYMTestActions  RDbNamedDatabase::Open()/RDbNamedDatabase::DatabaseNamesL()/RDbNamedDatabase::Create().
@SYMTestExpectedResults The test must not fail.
@SYMREQ REQ2429
                 DBMS shall provide an API to apply security policies to database tables.
*/
static void DbTestL()
	{
	TBuf<32> format;

	TDBSCUtils::DeleteDatabase(TheDbs, KSecureDbUid, KDbName);
	TheTest.Printf(_L("Create database\n"));
	//The test must pass, because the test app has "SCHEMA" capability
	format.Copy(KSecure);
	format.Append(KSecureDbUid.Name());
	TInt err = TheDb.Create(TheDbs, KDbName, format);
	TEST2(err, KErrNone);

	//The test must pass, because "DatabaseNamesL" is a DBMS operation available for everyone.
	TheTest.Printf(_L("Database list\n"));
	CDbDatabaseNames* dbNames = TheDbs.DatabaseNamesL(EDriveC, KSecureDbUid);
	TEST(dbNames->Count() > 0);
	TBool casePreserved = EFalse;
	for(TInt i=0;i<dbNames->Count();++i)
		{
		const TDesC& dbName = (*dbNames)[i];
		RDebug::Print(_L("--Database: %S\n"), &dbName);
		TBuf<128> dbName2;
		dbName2.Append(TChar('A' + EDriveC));
		dbName2.Append(TChar(':'));
		dbName2.Append(dbName);
		if(dbName2 == KDbName())
			{
			casePreserved = ETrue;
			}
		}
	//if casePreserved is non-zero that means the DBMS server does not change the database names to
	//upper or lower case - that's what we want to check
	TEST(casePreserved);
	delete dbNames;

	TheDb.Close();

	TheTest.Printf(_L("An attempt to create database - existing, but protected UID\n"));
	//The test must fail, because the test app does not have capabilities to satisfy
	//KProtSecureDbUid "SCHEMA" policy.
	format.Copy(KSecure);
	format.Append(KProtSecureDbUid.Name());
	err = TheDb.Create(TheDbs, KDbName, format);
	TEST2(err, KErrPermissionDenied);

	//The test must pass, because the test app has "SCHEMA" capability (it must have capabilities,
	//satisfying at least one of the UID's R/W/S policies)
	TheTest.Printf(_L("Open database\n"));
	format.Copy(KSecure);
	format.Append(KSecureDbUid.Name());
	err = TheDb.Open(TheDbs, KDbName, format);
	TEST2(err, KErrNone);
	}
示例#2
0
TInt E32Main()
    {
	__UHEAP_MARK;
	CTrapCleanup* tc = CTrapCleanup::New();
	TEST(tc != NULL);

	TInt err = TheDbs.Connect();
	TEST2(err, KErrNone);

	TBuf<32> format;
	TheTest.Printf(_L("Open database\n"));
	format.Copy(KSecure);
	format.Append(KSecureDbUid.Name());
	err = TheDb.Open(TheDbs, KDbName, format);
	TEST2(err, KErrNone);

	TRAP(err, DoTestL());
	TEST2(err, KErrNone);

	TheView.Close();
	TheTbl.Close();
	TheDb.Close();
	TheDbs.Close();

	TheTest.End();
	TheTest.Close();

	delete tc;

	__UHEAP_MARKEND;
	User::Heap().Check();
	return KErrNone;
    }
// -----------------------------------------------------------------------------
// GetClientIapsL
// -----------------------------------------------------------------------------
//
void CHssIapHandler::GetClientIapsL( const TUid aUId, RArray<TUint>& aIapIdArray )
    {
    DEBUG("CHssIapSettingsHandler::GetClientsIapsL");
    TBuf<32> buffer;                    // Temporary buffer for found UID from destination.
    TUint32 iapId = 0;                  // IAP Identifiier.
    TBuf<KIapNameLength> uidClient;     // UID of the client.
    
    uidClient.Copy( aUId.Name() );
    ModifyClientUid( uidClient );

    RArray<TUint32> destArray = RArray<TUint32>( 10 );  // KCmArrayGranularity instead of 10
    CleanupClosePushL( destArray );

    RCmManager cmManager;
    cmManager.OpenL();
    CleanupClosePushL( cmManager );    

    cmManager.AllDestinationsL( destArray );

    for (TInt i = 0; i < destArray.Count(); i++)
        {
        RCmDestination dest = cmManager.DestinationL( destArray[i] );
        CleanupClosePushL( dest );

        for (TInt j = 0; j < dest.ConnectionMethodCount(); j++)
            {
            TInt bearerType = dest.ConnectionMethodL(j).
                GetIntAttributeL( CMManager::ECmBearerType );

            if (bearerType == KUidWlanBearerType)
                {
                HBufC* uid = dest.ConnectionMethodL(j).
                        GetStringAttributeL( EWlanServiceExtensionTableName );
                CleanupStack::PushL( uid );

                // Copy found uid to temporary buffer
                buffer.Copy( *uid );    

                // If uids match, store corresponding IapId to aIapIdArray.    
                if (buffer.Compare( uidClient ) == 0)
                    {
                    iapId = dest.ConnectionMethodL(j).GetIntAttributeL( ECmIapId );
                    aIapIdArray.AppendL( iapId );
                    DEBUG("CHssIapSettingsHandler::GetClientsIapsL: UIDs matched");
                    DEBUG1("CHssIapSettingsHandler::Found IapId: %d", iapId);
                    }
                else
                    {
                    DEBUG("CHssIapSettingsHandler::GetClientsIapsL: NO match");
                    }
                CleanupStack::PopAndDestroy( uid );
                }
            }
        CleanupStack::PopAndDestroy( &dest );
        }

    CleanupStack::PopAndDestroy( &cmManager );
    CleanupStack::PopAndDestroy( &destArray );
    }
示例#4
0
LOCAL_C void testUid()
//
// Test UIDs
//
{

    test.Start(_L("All functions"));
    test(g1==g11);
    test(g2==g22);
    test(g1!=g2);
    TName a1Name = g1.Name();
    TName a11Name = g11.Name();
    TName a2Name = g2.Name();
    TName a22Name = g22.Name();
    test.Printf(_L("%S %S\n"),&a1Name,&a11Name);
    test.Printf(_L("%S %S\n"),&a2Name,&a22Name);
    test.End();
}
示例#5
0
EXPORT_C void TRequestContext::AddSubjectAttributeL( const TDesC8& aAttributeId, const TUid& aSecureId)
{
	TBuf8<20> secureIdString;
	
	//create UID string
	secureIdString.Append( KSecureIdString);
	secureIdString.Append( aSecureId.Name());
	secureIdString.UpperCase();
	
	//and UID string to request.....
	AddSubjectAttributeL( aAttributeId, secureIdString, PolicyEngineXACML::KStringDataType);
}
// ---------------------------------------------------------------------------
// 2nd phase constructor
// ---------------------------------------------------------------------------
//
void CCenRepDatabaseUtil::ConstructL( TUid aUid )
    {
    if( iColIncrement - 1 + iColMask != KMaxTUint )
        {
        User::Leave( KErrArgument );
        }
        
    iRepository = CRepository::NewL( aUid );

    // Create semaphore name from repository uid
    TUidName uidName = aUid.Name();
    TInt err = iSemaphore.OpenGlobal( uidName );
    if ( err != KErrNone )
        {
        User::LeaveIfError( iSemaphore.CreateGlobal( uidName, 1 ) );
        }
    
    }
// -----------------------------------------------------------------------------
// CSisxUIStartupFile::ConstructL
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CSisxUIStartupFile::ConstructL( const TUid& aUid )
    {
    User::LeaveIfError( iFileSession.Connect() );

    TUidName uidStr = aUid.Name();
    TFileName tmp;
    
    iFileSession.PrivatePath( tmp );    
    tmp.Insert( 0, TParsePtrC( PathInfo::PhoneMemoryRootPath() ).Drive() );
    tmp.Append( KImportDir );      
    tmp.AppendFormat( KNewFileFormat, &uidStr ); 
    iNewFile = tmp.AllocL();
    tmp.Zero();
        
    iFileSession.PrivatePath( tmp );
    tmp.Insert( 0, TParsePtrC( PathInfo::PhoneMemoryRootPath() ).Drive() );
    tmp.Append( KPrivateFileDir );    
    iFileSession.MkDir( tmp );    
    tmp.AppendFormat( KPrivateFileFormat, &uidStr );
    iPrivateFile = tmp.AllocL();
    }
// ---------------------------------------------------------
// ProcessRegister
// ---------------------------------------------------------
//
void CHotSpotSession::ProcessRegisterL( const RMessage2& aMessage )
    {
    DEBUG("CHotSpotSession::ProcessRegisterL");
    
    iAllowNotifications = EFalse;
    TBufC< KIapNameLength > iapName;
    TPckgBuf< TIapName > iapPckg;
    TUid clientUid;
    TPckgBuf< TClientUid > uidPckg;
    TPckgBuf<TInt> iapPackage( iIapId );
    
    // Read message
    aMessage.ReadL( 0, uidPckg );
    clientUid = uidPckg().ClientUid();
    aMessage.ReadL( 1, iapPckg );
    iapName = iapPckg().IapName();
    
    TBuf<KIapNameLength> bufUid;
    bufUid.Copy( clientUid.Name() );
    ModifyClientUid( bufUid );
        
    TUint32 iapId( 0 );
    
    TInt ret( KErrNone );
    TRAP( ret, iIapSettingsHandler->CreateClientIapL( iapName, iapId, bufUid ));
    DEBUG1( "CHotSpotSession::EHssRegister iapId: %d", iapId );
    DEBUG1( "CHotSpotSession::EHssRegister ret: %d", ret );
    if ( KErrNone == ret )
        {
        iServer.SetClientIapL( iapId, bufUid );
        aMessage.Complete( iapId );
        }

    else 
        {
        // Error, we are returning 0 to client
        // and no IAP is created
        aMessage.Complete( KErrNone );
        }
    }
示例#9
0
/**
@SYMTestCaseID          PDS-SQL-UT-4224
@SYMTestCaseDesc        CSqlServer::GetBackUpListL() functional test
@SYMTestPriority        High
@SYMTestActions         Calls CSqlServer::GetBackUpListL() and tests the output, when the drive is read-only,
                        when there is a sub-directory which name is matching the search pattern.
@SYMTestExpectedResults Test must not fail
*/  
void GetBackupListFunctionalTest()
	{
    CSqlServer* server = NULL;
    TRAPD(err, server = CreateSqlServerL());
    TEST2(err, KErrNone);
    //Case 1: database with specified uid bellow do exist (on drive C). There will be one subdirectory matching the search pattern. 
    const TDriveNumber KTestDrvNum1 = EDriveC;
    const TUid KDbUid = {0x98765432};
	TDriveUnit testDrive(KTestDrvNum1);
	TDriveName testDriveName = testDrive.Name();
	testDriveName.LowerCase(); 
	//One test directory will be created, which name will be matching the search pattern.
	//The directory name should not be included in the list with the file names.
    TFileName testFileName;
    err = server->Fs().PrivatePath(testFileName);
    TEST2(err, KErrNone);
    testFileName.Append(KDbUid.Name());
    _LIT(KTestPath, "t_startup\\");
    testFileName.Append(KTestPath);
    testFileName.Append(_L("t_startup.db"));
    TParse parse;
    err = parse.Set(testFileName, &testDriveName, 0);
    TEST2(err, KErrNone);
    err = server->Fs().MkDirAll(parse.FullName());
    TEST(err == KErrNone || err == KErrAlreadyExists);
    //
    RArray<HBufC*> files;
    TRAP(err, server->GetBackUpListL(KDbUid, KTestDrvNum1, files));
    TEST2(err, KErrNone);
    TInt fileCnt = files.Count();
    for(TInt i=0;i<fileCnt;++i)
    	{
		TPtrC fname = files[i]->Des();
		TheTest.Printf(_L("Db: %S\r\n"), &fname);
		TEST(fname.FindF(KTestPath) < 0);
		//The name should include the full path + the drive
		err = parse.Set(fname, 0, 0);
		TEST2(err, KErrNone);
		TEST(parse.DrivePresent());
		TEST(parse.PathPresent());
		TDriveName driveName(parse.Drive());
		driveName.LowerCase(); 
		delete files[i];
		TEST(driveName == testDriveName);		
    	}
    files.Close();
    //Case 2: drive Z:. No files should be returned.
    const TDriveNumber KTestDrvNum2 = EDriveZ;
    TRAP(err, server->GetBackUpListL(KDbUid, KTestDrvNum2, files));
    TEST2(err, KErrNone);
    fileCnt = files.Count();
    TEST2(fileCnt, 0);
    //Case 3: drive A:. The drive does not exist. No files should be returned.
    const TDriveNumber KTestDrvNum3 = EDriveA;
    TRAP(err, server->GetBackUpListL(KDbUid, KTestDrvNum3, files));
	TheTest.Printf(_L("Drive %d, err=%d\r\n"), KTestDrvNum3, err);
    fileCnt = files.Count();
    TEST2(fileCnt, 0);
    //
    delete server;
	}