sl@0: // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\secure\t_polsvr.cpp sl@0: // Overview: sl@0: // Policy Server Tests sl@0: // API Information: sl@0: // CPolicyServer sl@0: // Details: sl@0: // - Perform various policy server tests: sl@0: // Server1 has implementations of CustomSecurityCheckL and sl@0: // CustomFailureActionL This is the test for all the paths in a policy servers sl@0: // implementations -- not all connect paths though sl@0: // This test also ensures that every path through the binary search is sl@0: // covered. sl@0: // Policy2,3,4,5,6, are bad policies that should cause the server to panic sl@0: // in debug mode. In release, they'll just pass, however, if you later tried sl@0: // to use them, something would go horribly wrong sl@0: // Policies 7,8,9 check various types of connect policies. sl@0: // Server 1,2,3 are used here all with policy 8 because you can only test 1 sl@0: // type of connect policy per server. sl@0: // Sever2 does not have implementations of CustomSecurityCheckL and sl@0: // CustomFailureActionL. When these functions are called it should crash sl@0: // Server4 is used for checking what happens when the custom functions use sl@0: // another active object. This test encompasses leaving due to OOM, and sl@0: // cancellation. sl@0: // Platforms/Drives/Compatibility: sl@0: // All. sl@0: // Assumptions/Requirement/Pre-requisites: sl@0: // Failures and causes: sl@0: // Base Port information: sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: sl@0: LOCAL_D RTest test(_L("T_POLSVR")); sl@0: sl@0: _LIT(KPolSvr, "T_POLSVR"); sl@0: sl@0: #define Debug(x) RDebug::Print(_L(x)) sl@0: sl@0: const TUint32 KTestCapabilities =(1< flags(0); sl@0: TInt r = aMsg.Read(0, flags); sl@0: test(r == KErrNone); sl@0: (*(TUint32*)(flags.Ptr())) |= aMask; sl@0: flags.SetLength(4); sl@0: r = aMsg.Write(0, flags); sl@0: test(r == KErrNone); sl@0: } sl@0: sl@0: void SetFlags(TDes8& aDes, TUint aValue) sl@0: { sl@0: (*(TUint32*)(aDes.Ptr())) = aValue; sl@0: } sl@0: sl@0: TUint FlagsValue(const TDes8& aDes) sl@0: { sl@0: return (*(TUint32*)(aDes.Ptr())); sl@0: } sl@0: sl@0: enum TTestProcessFunctions sl@0: { sl@0: ETestProcessPolicyServer, sl@0: }; sl@0: sl@0: enum TTestServerIndex sl@0: { sl@0: ETestServer1=0, sl@0: ETestServer2, sl@0: ETestServer3, sl@0: ETestServer4, sl@0: }; sl@0: sl@0: enum TServerPolicyIndex sl@0: { sl@0: EPolicy1=0, sl@0: EPolicy2, sl@0: EPolicy3, sl@0: EPolicy4, sl@0: EPolicy5, sl@0: EPolicy6, sl@0: EPolicy7, sl@0: EPolicy8, sl@0: EPolicy9, sl@0: EPolicy10, sl@0: EPolicy11, sl@0: EPolicy12, sl@0: }; sl@0: sl@0: // sl@0: // EPolicy1 sl@0: // sl@0: sl@0: const TUint gServerPolicy1RangeCount = 12; sl@0: const TInt gServerPolicy1Ranges[gServerPolicy1RangeCount] = { sl@0: 0, //ENotSupported sl@0: 1, //ECustomCheck sl@0: 6, //EAlwaysPass sl@0: 7, //ENotSupported sl@0: 8, //->0 sl@0: 9, //->1 sl@0: 10, //->2 sl@0: 11, //->3 sl@0: 12, //->3 sl@0: 13, //ENotSupported sl@0: 100, //EAlwaysPass -> Shutdown sl@0: 101, //ENotSupported sl@0: }; sl@0: sl@0: const TUint8 gServerPolicy1ElementsIndex[] = { sl@0: CPolicyServer::ENotSupported, sl@0: CPolicyServer::ECustomCheck, sl@0: CPolicyServer::EAlwaysPass, sl@0: CPolicyServer::ENotSupported, sl@0: 0, //RequireNetworkControl or EFail sl@0: 1, //RequireNetworkControl or EQueryUser sl@0: 2, //RequireDiskAdmin or EFail sl@0: 3, //RequireDiskAdmin or EQueryUser sl@0: 3, //RequireDiskAdmin or EQueryUser sl@0: CPolicyServer::ENotSupported, sl@0: CPolicyServer::EAlwaysPass, sl@0: CPolicyServer::ENotSupported, sl@0: }; sl@0: sl@0: const CPolicyServer::TPolicyElement gServerPolicy1Elements[] = sl@0: { sl@0: {_INIT_SECURITY_POLICY_C1(ECapabilityNetworkControl),CPolicyServer::EFailClient}, sl@0: {_INIT_SECURITY_POLICY_C1(ECapabilityNetworkControl),KQueryUser}, sl@0: {_INIT_SECURITY_POLICY_C1(ECapabilityDiskAdmin),CPolicyServer::EFailClient}, sl@0: {_INIT_SECURITY_POLICY_C1(ECapabilityDiskAdmin),KQueryUser}, sl@0: }; sl@0: sl@0: const CPolicyServer::TPolicy gServerPolicy1 = sl@0: { sl@0: CPolicyServer::EAlwaysPass,gServerPolicy1RangeCount, sl@0: gServerPolicy1Ranges, sl@0: gServerPolicy1ElementsIndex, sl@0: gServerPolicy1Elements, sl@0: }; sl@0: sl@0: // sl@0: //EPolicy2 sl@0: // sl@0: sl@0: const TUint gServerPolicy2RangeCount = 1; sl@0: //Invalid Policy -- doesn't start with 0 sl@0: const TInt gServerPolicy2Ranges[gServerPolicy2RangeCount] = { sl@0: 1, //KErrNotSupported sl@0: }; sl@0: sl@0: const TUint8 gServerPolicy2ElementsIndex[] = { sl@0: CPolicyServer::ENotSupported, sl@0: }; sl@0: sl@0: const CPolicyServer::TPolicyElement gServerPolicy2Elements[] = sl@0: { sl@0: {_INIT_SECURITY_POLICY_FAIL,CPolicyServer::EFailClient}, sl@0: }; sl@0: sl@0: const CPolicyServer::TPolicy gServerPolicy2 = sl@0: { sl@0: 0,gServerPolicy2RangeCount, sl@0: gServerPolicy2Ranges, sl@0: gServerPolicy2ElementsIndex, sl@0: gServerPolicy2Elements sl@0: }; sl@0: sl@0: // sl@0: //EPolicy3 sl@0: // sl@0: sl@0: const TUint gServerPolicy3RangeCount = 12; sl@0: //Invalid Policy -- range values not increasing sl@0: const TInt gServerPolicy3Ranges[gServerPolicy3RangeCount] = { sl@0: 0, //ECustomCheck sl@0: 6, //EAlwaysPass sl@0: 7, //ENotSupported sl@0: 8, //->0 sl@0: 9, //->1 sl@0: 10, //->2 sl@0: 11, //->3 sl@0: 12, //->3 sl@0: 13, //ENotSupported sl@0: 100, //EAlwaysPass -> Shutdown sl@0: 101, //ENotSupported sl@0: 99, //EAlwaysPass sl@0: }; sl@0: sl@0: const TUint8 gServerPolicy3ElementsIndex[] = { sl@0: CPolicyServer::ECustomCheck, sl@0: CPolicyServer::EAlwaysPass, sl@0: CPolicyServer::ENotSupported, sl@0: 0, //RequireNetworkControl or EFail sl@0: 1, //RequireNetworkControl or EQueryUser sl@0: 2, //RequireDiskAdmin or EFail sl@0: 3, //RequireDiskAdmin or EQueryUser sl@0: 3, //RequireDiskAdmin or EQueryUser sl@0: CPolicyServer::ENotSupported, sl@0: CPolicyServer::EAlwaysPass, sl@0: CPolicyServer::ENotSupported, sl@0: CPolicyServer::EAlwaysPass, sl@0: }; sl@0: sl@0: const CPolicyServer::TPolicyElement gServerPolicy3Elements[] = sl@0: { sl@0: {_INIT_SECURITY_POLICY_C1(ECapabilityNetworkControl),CPolicyServer::EFailClient}, sl@0: {_INIT_SECURITY_POLICY_C1(ECapabilityNetworkControl),KQueryUser}, sl@0: {_INIT_SECURITY_POLICY_C1(ECapabilityDiskAdmin),CPolicyServer::EFailClient}, sl@0: {_INIT_SECURITY_POLICY_C1(ECapabilityDiskAdmin),KQueryUser}, sl@0: }; sl@0: sl@0: const CPolicyServer::TPolicy gServerPolicy3 = sl@0: { sl@0: 0,gServerPolicy3RangeCount, sl@0: gServerPolicy3Ranges, sl@0: gServerPolicy3ElementsIndex, sl@0: gServerPolicy3Elements sl@0: }; sl@0: sl@0: // sl@0: //EPolicy4 sl@0: // sl@0: sl@0: const TUint gServerPolicy4RangeCount = 1; sl@0: //Invalid Policy -- Elements Index has invalid values sl@0: const TInt gServerPolicy4Ranges[gServerPolicy4RangeCount] = { sl@0: 0, //Invalid value sl@0: }; sl@0: sl@0: const TUint8 gServerPolicy4ElementsIndex[] = { sl@0: CPolicyServer::ESpecialCaseHardLimit, sl@0: }; sl@0: sl@0: const CPolicyServer::TPolicyElement gServerPolicy4Elements[] = sl@0: { sl@0: {_INIT_SECURITY_POLICY_FAIL,CPolicyServer::EFailClient}, sl@0: }; sl@0: sl@0: const CPolicyServer::TPolicy gServerPolicy4 = sl@0: { sl@0: 0,gServerPolicy4RangeCount, sl@0: gServerPolicy4Ranges, sl@0: gServerPolicy4ElementsIndex, sl@0: gServerPolicy4Elements sl@0: }; sl@0: sl@0: // sl@0: //EPolicy5 sl@0: // sl@0: sl@0: const TUint gServerPolicy5RangeCount = 1; sl@0: //Invalid Policy -- Elements Index has invalid values sl@0: const TInt gServerPolicy5Ranges[gServerPolicy5RangeCount] = { sl@0: 0, //uses Invalid value sl@0: }; sl@0: sl@0: const TUint8 gServerPolicy5ElementsIndex[] = { sl@0: //Uses invalid value sl@0: CPolicyServer::ESpecialCaseLimit, sl@0: }; sl@0: sl@0: const CPolicyServer::TPolicyElement gServerPolicy5Elements[] = sl@0: { sl@0: {_INIT_SECURITY_POLICY_FAIL,CPolicyServer::EFailClient}, sl@0: }; sl@0: sl@0: const CPolicyServer::TPolicy gServerPolicy5 = sl@0: { sl@0: 0,gServerPolicy5RangeCount, sl@0: gServerPolicy5Ranges, sl@0: gServerPolicy5ElementsIndex, sl@0: gServerPolicy5Elements sl@0: }; sl@0: sl@0: // sl@0: //EPolicy6 sl@0: // sl@0: sl@0: const TUint gServerPolicy6RangeCount = 1; sl@0: //Invalid Policy -- Elements Index has invalid values sl@0: const TInt gServerPolicy6Ranges[gServerPolicy6RangeCount] = { sl@0: 0, sl@0: }; sl@0: sl@0: const TUint8 gServerPolicy6ElementsIndex[] = { sl@0: CPolicyServer::ENotSupported, sl@0: }; sl@0: sl@0: const CPolicyServer::TPolicyElement gServerPolicy6Elements[] = sl@0: { sl@0: {_INIT_SECURITY_POLICY_FAIL,CPolicyServer::EFailClient}, sl@0: }; sl@0: sl@0: const CPolicyServer::TPolicy gServerPolicy6 = sl@0: { sl@0: //Uses invalid value for iOnConnect sl@0: CPolicyServer::ESpecialCaseHardLimit,gServerPolicy6RangeCount, sl@0: gServerPolicy6Ranges, sl@0: gServerPolicy6ElementsIndex, sl@0: gServerPolicy6Elements sl@0: }; sl@0: sl@0: // sl@0: //EPolicy7 sl@0: // sl@0: // Connect not supported sl@0: const TUint gServerPolicy7RangeCount = 1; sl@0: const TInt gServerPolicy7Ranges[gServerPolicy7RangeCount] = { sl@0: 0, sl@0: }; sl@0: sl@0: const TUint8 gServerPolicy7ElementsIndex[] = { sl@0: 0 sl@0: }; sl@0: sl@0: const CPolicyServer::TPolicyElement gServerPolicy7Elements[] = sl@0: { sl@0: {_INIT_SECURITY_POLICY_FAIL,CPolicyServer::EFailClient}, sl@0: }; sl@0: sl@0: const CPolicyServer::TPolicy gServerPolicy7 = sl@0: { sl@0: CPolicyServer::ENotSupported,gServerPolicy7RangeCount, sl@0: gServerPolicy7Ranges, sl@0: gServerPolicy7ElementsIndex, sl@0: gServerPolicy7Elements sl@0: }; sl@0: sl@0: // sl@0: //EPolicy8 sl@0: // sl@0: // Connect Custom Check sl@0: const TUint gServerPolicy8RangeCount = 1; sl@0: const TInt gServerPolicy8Ranges[gServerPolicy8RangeCount] = { sl@0: 0, sl@0: }; sl@0: sl@0: const TUint8 gServerPolicy8ElementsIndex[] = { sl@0: 0 sl@0: }; sl@0: sl@0: const CPolicyServer::TPolicyElement gServerPolicy8Elements[] = sl@0: { sl@0: {_INIT_SECURITY_POLICY_FAIL,CPolicyServer::EPanicClient}, sl@0: }; sl@0: sl@0: const CPolicyServer::TPolicy gServerPolicy8 = sl@0: { sl@0: CPolicyServer::ECustomCheck,gServerPolicy8RangeCount, sl@0: gServerPolicy8Ranges, sl@0: gServerPolicy8ElementsIndex, sl@0: gServerPolicy8Elements sl@0: }; sl@0: sl@0: // sl@0: //EPolicy9 sl@0: // sl@0: // Connect has a static policy but it fails. sl@0: const TUint gServerPolicy9RangeCount = 1; sl@0: const TInt gServerPolicy9Ranges[gServerPolicy9RangeCount] = { sl@0: 0, sl@0: }; sl@0: sl@0: const TUint8 gServerPolicy9ElementsIndex[] = { sl@0: 0 sl@0: }; sl@0: sl@0: const CPolicyServer::TPolicyElement gServerPolicy9Elements[] = sl@0: { sl@0: {_INIT_SECURITY_POLICY_FAIL,CPolicyServer::EFailClient}, sl@0: }; sl@0: sl@0: const CPolicyServer::TPolicy gServerPolicy9 = sl@0: { sl@0: 0,gServerPolicy9RangeCount, sl@0: gServerPolicy9Ranges, sl@0: gServerPolicy9ElementsIndex, sl@0: gServerPolicy9Elements sl@0: }; sl@0: sl@0: // sl@0: // EPolicy10 sl@0: // sl@0: sl@0: const TUint gServerPolicy10RangeCount = 13; sl@0: const TInt gServerPolicy10Ranges[gServerPolicy10RangeCount] = { sl@0: 0, //ECustomCheck sl@0: 5, //EAlwaysPass sl@0: 6, //ENotSupported sl@0: 8, //->0 sl@0: 9, //->3 sl@0: 10, //->2 sl@0: 11, //->1 sl@0: 12, //ENotSupported sl@0: 55, //->3 sl@0: 58, //ENotSupported sl@0: 100, //EAlwaysPass -> Shutdown sl@0: 101, //ENotSupported sl@0: KMaxTInt, //EAlways Pass sl@0: }; sl@0: sl@0: const TUint8 gServerPolicy10ElementsIndex[] = { sl@0: CPolicyServer::ECustomCheck, sl@0: CPolicyServer::EAlwaysPass, sl@0: CPolicyServer::ENotSupported, sl@0: 0, //RequireNetworkControl or EFail sl@0: 3, //RequireDiskAdmin or EQueryUser sl@0: 2, //RequireDiskAdmin or EFail sl@0: 1, //RequireNetworkControl or EQueryUser sl@0: CPolicyServer::ENotSupported, sl@0: 3, sl@0: CPolicyServer::ENotSupported, sl@0: CPolicyServer::EAlwaysPass, sl@0: CPolicyServer::ENotSupported, sl@0: CPolicyServer::EAlwaysPass, sl@0: }; sl@0: sl@0: const CPolicyServer::TPolicyElement gServerPolicy10Elements[] = sl@0: { sl@0: {_INIT_SECURITY_POLICY_C1(ECapabilityNetworkControl),CPolicyServer::EFailClient}, sl@0: {_INIT_SECURITY_POLICY_C1(ECapabilityNetworkControl),KQueryUser}, sl@0: {_INIT_SECURITY_POLICY_C1(ECapabilityDiskAdmin),CPolicyServer::EFailClient}, sl@0: {_INIT_SECURITY_POLICY_C1(ECapabilityDiskAdmin),KQueryUser}, sl@0: }; sl@0: sl@0: const CPolicyServer::TPolicy gServerPolicy10 = sl@0: { sl@0: CPolicyServer::EAlwaysPass,gServerPolicy10RangeCount, sl@0: gServerPolicy10Ranges, sl@0: gServerPolicy10ElementsIndex, sl@0: gServerPolicy10Elements, sl@0: }; sl@0: sl@0: sl@0: //A list of all the global policies sl@0: const CPolicyServer::TPolicy* gPolicyIndex[] = { sl@0: &gServerPolicy1, sl@0: &gServerPolicy2, sl@0: &gServerPolicy3, sl@0: &gServerPolicy4, sl@0: &gServerPolicy5, sl@0: &gServerPolicy6, sl@0: &gServerPolicy7, sl@0: &gServerPolicy8, sl@0: &gServerPolicy9, sl@0: &gServerPolicy10, sl@0: }; sl@0: sl@0: sl@0: #include "testprocess.h" sl@0: sl@0: TInt StartServer(const CPolicyServer::TPolicy& aPolicy, TUint aServerIndex); sl@0: sl@0: TInt DoTestProcess(TInt aTestNum,TInt aArg1,TInt aArg2) sl@0: { sl@0: switch(aTestNum) sl@0: { sl@0: sl@0: case ETestProcessPolicyServer: sl@0: { sl@0: __ASSERT_ALWAYS(aArg1 >= 0 && aArg1 < (TInt)sizeof(gPolicyIndex)>>2, User::Panic(KPolSvr, KErrArgument)); sl@0: const CPolicyServer::TPolicy& policy = *(gPolicyIndex[aArg1]); sl@0: __ASSERT_ALWAYS(aArg2 >= 0, User::Panic(KPolSvr, KErrArgument)); sl@0: TInt r; sl@0: r=StartServer(policy, TUint(aArg2)); sl@0: if(r==KErrAlreadyExists) sl@0: { sl@0: User::After(2*1000*1000); sl@0: r=StartServer(policy, TUint(aArg2)); sl@0: } sl@0: return r; sl@0: } sl@0: sl@0: default: sl@0: User::Panic(_L("T_POLSVR"),1); sl@0: } sl@0: sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: // sl@0: // RTestThread sl@0: // sl@0: sl@0: class RTestThread : public RThread sl@0: { sl@0: public: sl@0: void Create(TThreadFunction aFunction,TAny* aArg=0); sl@0: }; sl@0: sl@0: void RTestThread::Create(TThreadFunction aFunction,TAny* aArg) sl@0: { sl@0: TInt r=RThread::Create(_L(""),aFunction,KDefaultStackSize,KDefaultStackSize,KDefaultStackSize,aArg); sl@0: test(r==KErrNone); sl@0: } sl@0: sl@0: // sl@0: // CTestSession1 sl@0: // sl@0: sl@0: class CTestSession1 : public CSession2 sl@0: { sl@0: public: sl@0: enum {EShutdown=100}; sl@0: public: sl@0: CTestSession1(); sl@0: virtual void ServiceL(const RMessage2& aMsg); sl@0: public: sl@0: }; sl@0: sl@0: CTestSession1::CTestSession1() sl@0: : CSession2() sl@0: {} sl@0: sl@0: sl@0: void CTestSession1::ServiceL(const RMessage2& aMsg) sl@0: { sl@0: OrInFlags(aMsg, KServiceLMask); sl@0: TInt fn = aMsg.Function(); sl@0: switch(fn) sl@0: { sl@0: case 2: sl@0: case 4: sl@0: case 5: sl@0: case 6: sl@0: case 8: sl@0: case 9: sl@0: case 12: sl@0: case KMaxTInt: sl@0: aMsg.Complete(KErrNone); sl@0: break; sl@0: sl@0: case CTestSession1::EShutdown: sl@0: CActiveScheduler::Stop(); sl@0: aMsg.Complete(KErrNone); sl@0: break; sl@0: default: sl@0: //If we get here we have an unhandled condition in the test code. sl@0: //The test code is specifically setup to try and catch all branches sl@0: //through the policy server. If you get, there is some problem in sl@0: //the setup. sl@0: test(0); sl@0: break; sl@0: } sl@0: } sl@0: sl@0: // sl@0: // CTestPolicyServer1 sl@0: // sl@0: sl@0: class CTestPolicyServer1 : public CPolicyServer sl@0: { sl@0: public: sl@0: CTestPolicyServer1(TInt aPriority, const TPolicy& aPolicy); sl@0: virtual CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMsg) const; sl@0: virtual TCustomResult CustomSecurityCheckL(const RMessage2& aMsg, TInt& aAction, TSecurityInfo& aMissing); sl@0: virtual TCustomResult CustomFailureActionL(const RMessage2& aMsg, TInt aAction, const TSecurityInfo& aMissing); sl@0: }; sl@0: sl@0: CTestPolicyServer1::CTestPolicyServer1(TInt aPriority, const TPolicy& aPolicy) sl@0: : CPolicyServer(aPriority, aPolicy) sl@0: { sl@0: } sl@0: sl@0: CSession2* CTestPolicyServer1::NewSessionL(const TVersion& /*aVersion*/,const RMessage2& /*aMsg*/) const sl@0: { sl@0: return new (ELeave) CTestSession1(); sl@0: } sl@0: sl@0: CPolicyServer::TCustomResult CTestPolicyServer1::CustomSecurityCheckL(const RMessage2& aMsg, TInt& aAction, TSecurityInfo& aMissing) sl@0: { sl@0: TInt fn = aMsg.Function(); sl@0: if(fn >= 0) sl@0: { sl@0: //Connect messages don't use this debugging system sl@0: OrInFlags(aMsg, KCustomCheckMask); sl@0: } sl@0: if(fn == -1) //Connect sl@0: { sl@0: return EPass; sl@0: } sl@0: else if(fn == 1) sl@0: { sl@0: aMissing.iCaps.AddCapability(ECapabilityCommDD); sl@0: return EFail; sl@0: } sl@0: else if(fn == 2) sl@0: { sl@0: return EPass; sl@0: } sl@0: else if(fn == 3) sl@0: { sl@0: aMissing.iCaps.AddCapability(ECapabilityCommDD); sl@0: aAction = KQueryUser; sl@0: return EFail; sl@0: } sl@0: else if(fn == 4) sl@0: { sl@0: aMissing.iCaps.AddCapability(ECapabilityCommDD); sl@0: aAction = KQueryUser; sl@0: return EFail; sl@0: } sl@0: else if(fn == 5) sl@0: { sl@0: //Since we are returning ETrue here, setting the action shouldn't affect sl@0: //anything. This should result in the same as 2. sl@0: aAction = KQueryUser; sl@0: return EPass; sl@0: } sl@0: //If we get here we have an unhandled condition in the test code. The test sl@0: //code is specifically setup to try and catch all branches through the sl@0: //policy server. If you get, there is some problem in the setup. sl@0: test(0); sl@0: return EFail; sl@0: } sl@0: sl@0: CPolicyServer::TCustomResult CTestPolicyServer1::CustomFailureActionL(const RMessage2& aMsg, TInt aAction, const TSecurityInfo& aMissing) sl@0: { sl@0: (void)aMissing; sl@0: (void)aMsg; sl@0: (void)aAction; sl@0: TInt fn = aMsg.Function(); sl@0: if(fn >= 0) sl@0: { sl@0: //Connect messages don't use this debugging system sl@0: OrInFlags(aMsg, KCustomActionMask); sl@0: } sl@0: switch(fn) sl@0: { sl@0: case 3: sl@0: return EFail; sl@0: case 4: sl@0: return EPass; sl@0: case 11: sl@0: return EFail; sl@0: case 12: sl@0: return EPass; sl@0: default: sl@0: break; sl@0: } sl@0: sl@0: //If we get here we have an unhandled condition in the test code. The test sl@0: //code is specifically setup to try and catch all branches through the sl@0: //policy server. If you get, there is some problem in the setup. sl@0: test(0); sl@0: return EFail; sl@0: } sl@0: sl@0: // sl@0: // CTestPolicyServer2 sl@0: // sl@0: sl@0: class CTestPolicyServer2 : public CPolicyServer sl@0: { sl@0: public: sl@0: CTestPolicyServer2(TInt aPriority, const TPolicy& aPolicy); sl@0: virtual CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMsg) const; sl@0: //virtual TBool CustomSecurityCheckL(const RMessage2& aMsg, TInt& aAction); sl@0: //virtual TBool CustomFailureActionL(const TSecurityPolicy* aPolicy, const RMessage2& aMsg, TInt aAction); sl@0: }; sl@0: sl@0: // sl@0: // CTestSession2 sl@0: // sl@0: sl@0: class CTestSession2 : public CSession2 sl@0: { sl@0: public: sl@0: enum {EShutdown=100}; sl@0: public: sl@0: CTestSession2(); sl@0: virtual void ServiceL(const RMessage2& aMsg); sl@0: public: sl@0: }; sl@0: sl@0: CTestSession2::CTestSession2() sl@0: : CSession2() sl@0: { sl@0: } sl@0: sl@0: void CTestSession2::ServiceL(const RMessage2& aMsg) sl@0: { sl@0: TInt fn = aMsg.Function(); sl@0: switch(fn) sl@0: { sl@0: case CTestSession2::EShutdown: sl@0: CActiveScheduler::Stop(); sl@0: aMsg.Complete(KErrNone); sl@0: break; sl@0: default: sl@0: //If we get here we have an unhandled condition in the test code. sl@0: //The test code is specifically setup to try and catch all branches sl@0: //through the policy server. If you get, there is some problem in sl@0: //the setup. sl@0: test(0); sl@0: break; sl@0: } sl@0: } sl@0: sl@0: CTestPolicyServer2::CTestPolicyServer2(TInt aPriority, const TPolicy& aPolicy) sl@0: : CPolicyServer(aPriority, aPolicy) sl@0: { sl@0: } sl@0: sl@0: CSession2* CTestPolicyServer2::NewSessionL(const TVersion& /*aVersion*/,const RMessage2& /*aMsg*/) const sl@0: { sl@0: return new (ELeave) CTestSession2(); sl@0: } sl@0: sl@0: // sl@0: // CTestPolicyServer3 sl@0: // sl@0: sl@0: class CTestPolicyServer3 : public CPolicyServer sl@0: { sl@0: public: sl@0: CTestPolicyServer3(TInt aPriority, const TPolicy& aPolicy); sl@0: virtual CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMsg) const; sl@0: virtual TCustomResult CustomSecurityCheckL(const RMessage2& aMsg, TInt& aAction, TSecurityInfo&); sl@0: virtual TCustomResult CustomFailureActionL(const RMessage2& aMsg, TInt aAction, const TSecurityInfo& aMissing); sl@0: }; sl@0: sl@0: CPolicyServer::TCustomResult CTestPolicyServer3::CustomSecurityCheckL(const RMessage2& aMsg, TInt& aAction, TSecurityInfo& aMissing) sl@0: { sl@0: (void)aAction; sl@0: (void)aMsg; sl@0: (void)aMissing; sl@0: //If we get here we have an unhandled condition in the test code. The test sl@0: //code is specifically setup to try and catch all branches through the sl@0: //policy server. If you get, there is some problem in the setup. sl@0: test(0); sl@0: return EFail; sl@0: } sl@0: sl@0: CPolicyServer::TCustomResult CTestPolicyServer3::CustomFailureActionL(const RMessage2& aMsg, TInt aAction, const TSecurityInfo& aMissing) sl@0: { sl@0: (void)aMissing; sl@0: (void)aMsg; sl@0: (void)aAction; sl@0: TInt fn = aMsg.Function(); sl@0: switch(fn) sl@0: { sl@0: case -1: sl@0: return EPass; sl@0: default: sl@0: break; sl@0: } sl@0: sl@0: //If we get here we have an unhandled condition in the test code. The test sl@0: //code is specifically setup to try and catch all branches through the sl@0: //policy server. If you get, there is some problem in the setup. sl@0: test(0); sl@0: return EFail; sl@0: } sl@0: sl@0: // sl@0: // CTestSession3 sl@0: // sl@0: sl@0: class CTestSession3 : public CSession2 sl@0: { sl@0: public: sl@0: enum {EShutdown=100}; sl@0: public: sl@0: CTestSession3(); sl@0: virtual void ServiceL(const RMessage2& aMsg); sl@0: public: sl@0: }; sl@0: sl@0: CTestSession3::CTestSession3() sl@0: : CSession2() sl@0: { sl@0: } sl@0: sl@0: void CTestSession3::ServiceL(const RMessage2& aMsg) sl@0: { sl@0: TInt fn = aMsg.Function(); sl@0: switch(fn) sl@0: { sl@0: case CTestSession3::EShutdown: sl@0: CActiveScheduler::Stop(); sl@0: aMsg.Complete(KErrNone); sl@0: break; sl@0: default: sl@0: //If we get here we have an unhandled condition in the test code. sl@0: //The test code is specifically setup to try and catch all branches sl@0: //through the policy server. If you get, there is some problem in sl@0: //the setup. sl@0: test(0); sl@0: break; sl@0: } sl@0: } sl@0: sl@0: CTestPolicyServer3::CTestPolicyServer3(TInt aPriority, const TPolicy& aPolicy) sl@0: : CPolicyServer(aPriority, aPolicy) sl@0: { sl@0: } sl@0: sl@0: CSession2* CTestPolicyServer3::NewSessionL(const TVersion& /*aVersion*/,const RMessage2& /*aMsg*/) const sl@0: { sl@0: return new (ELeave) CTestSession3(); sl@0: } sl@0: sl@0: _LIT(KCustomActive, "CCustomActive"); sl@0: // sl@0: // CCustomActive sl@0: // sl@0: sl@0: class CCustomActive : public CActive sl@0: { sl@0: public: sl@0: static CCustomActive* NewL(CPolicyServer& aServer); sl@0: void RunL(); sl@0: TInt RunError(TInt aError); sl@0: void DoCancel(); sl@0: void CustomSecurityCheckL(const RMessage2& aMsg, TInt aAction); sl@0: void CustomFailureActionL(const RMessage2& aMsg, TInt aAction); sl@0: protected: sl@0: void HandleSecurityCheckResultL(); sl@0: void HandleFailureActionResultL(); sl@0: void ConstructL(); sl@0: private: sl@0: CCustomActive(CPolicyServer& aServer); sl@0: RTimer iTimer; sl@0: CPolicyServer& iServer; sl@0: const RMessage2* iMsg; sl@0: enum TState { sl@0: ECustomSecurityCheck, sl@0: EFailureAction, sl@0: }; sl@0: TState iState; sl@0: TInt iAction; sl@0: TSecurityInfo iMissing; sl@0: }; sl@0: sl@0: CCustomActive::CCustomActive(CPolicyServer& aServer) sl@0: : CActive(0), iServer(aServer), iMsg(0), iState(ECustomSecurityCheck) sl@0: { sl@0: CActiveScheduler::Add(this); sl@0: } sl@0: sl@0: CCustomActive* CCustomActive::NewL(CPolicyServer& aServer) sl@0: { sl@0: CCustomActive* self = new(ELeave)CCustomActive(aServer); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: void CCustomActive::ConstructL() sl@0: { sl@0: User::LeaveIfError(iTimer.CreateLocal()); sl@0: memset(&iMissing, 0, sizeof(TSecurityInfo)); sl@0: } sl@0: sl@0: void CCustomActive::HandleSecurityCheckResultL() sl@0: { sl@0: TInt fn = iMsg->Function(); sl@0: switch(fn) sl@0: { sl@0: case 0: sl@0: iStatus = KErrGeneral; sl@0: break; sl@0: case 1: //pass sl@0: case 4: sl@0: break; sl@0: case 2: sl@0: case 3: sl@0: iStatus = KErrGeneral; sl@0: iAction = KQueryUser; sl@0: break; sl@0: default: sl@0: test(0); sl@0: } sl@0: if(iStatus == KErrNone) sl@0: { sl@0: iServer.ProcessL(*iMsg); sl@0: iMsg=0; sl@0: } sl@0: else sl@0: { sl@0: const RMessage2* ptr = iMsg; sl@0: iMsg=0; sl@0: iServer.CheckFailedL(*ptr, iAction, iMissing); sl@0: } sl@0: } sl@0: sl@0: void CCustomActive::HandleFailureActionResultL() sl@0: { sl@0: TInt fn = iMsg->Function(); sl@0: switch(fn) sl@0: { sl@0: case 2: sl@0: iStatus = KErrGeneral; sl@0: break; sl@0: case 3: //pass sl@0: case 9: sl@0: case 57: //passes through so ServiceL can leave with NoMem sl@0: break; sl@0: case 56: sl@0: User::Leave(KErrNoMemory); sl@0: break; sl@0: sl@0: default: sl@0: test(0); sl@0: } sl@0: if(iStatus == KErrNone) sl@0: iServer.ProcessL(*iMsg); sl@0: else sl@0: iMsg->Complete(KErrPermissionDenied); sl@0: iMsg=0; sl@0: } sl@0: sl@0: void CCustomActive::RunL() sl@0: { sl@0: OrInFlags(*iMsg, KActiveRunLMask); sl@0: sl@0: switch(iState) sl@0: { sl@0: case ECustomSecurityCheck: sl@0: HandleSecurityCheckResultL(); sl@0: break; sl@0: case EFailureAction: sl@0: HandleFailureActionResultL(); sl@0: break; sl@0: default: sl@0: //Invalid state sl@0: User::Panic(KCustomActive, 11); sl@0: break; sl@0: } sl@0: } sl@0: sl@0: TInt CCustomActive::RunError(TInt aError) sl@0: { sl@0: OrInFlags(*iMsg, KActiveRunErrorMask); sl@0: if(iMsg) sl@0: { sl@0: iServer.ProcessError(*iMsg, aError); sl@0: iMsg = 0; sl@0: iAction = CPolicyServer::EFailClient; sl@0: return KErrNone; sl@0: } sl@0: else sl@0: return aError; sl@0: } sl@0: sl@0: void CCustomActive::DoCancel() sl@0: { sl@0: OrInFlags(*iMsg, KActiveDoCancelMask); sl@0: iTimer.Cancel(); sl@0: if(iMsg) sl@0: { sl@0: iMsg->Complete(KErrCancel); sl@0: } sl@0: iMsg = 0; sl@0: iAction = CPolicyServer::EFailClient; sl@0: } sl@0: sl@0: void CCustomActive::CustomSecurityCheckL(const RMessage2& aMsg, TInt aAction) sl@0: { sl@0: __ASSERT_ALWAYS(!IsActive(), User::Panic(KCustomActive, 1)); sl@0: __ASSERT_ALWAYS(iMsg == 0, User::Panic(KCustomActive, 2)); sl@0: sl@0: OrInFlags(aMsg, KActiveCheckMask); sl@0: sl@0: iTimer.After(iStatus, 100000); sl@0: SetActive(); sl@0: iMsg = &aMsg; sl@0: iState = ECustomSecurityCheck; sl@0: iAction = aAction; sl@0: } sl@0: sl@0: void CCustomActive::CustomFailureActionL(const RMessage2& aMsg, TInt aAction) sl@0: { sl@0: __ASSERT_ALWAYS(!IsActive(), User::Panic(KCustomActive, 3)); sl@0: __ASSERT_ALWAYS(iMsg == 0, User::Panic(KCustomActive, 4)); sl@0: sl@0: OrInFlags(aMsg, KActiveActionMask); sl@0: sl@0: iTimer.After(iStatus, 50000); sl@0: SetActive(); sl@0: iMsg = &aMsg; sl@0: iState = EFailureAction; sl@0: iAction = aAction; sl@0: sl@0: if(aMsg.Function() == 55) sl@0: { sl@0: Cancel(); sl@0: } sl@0: } sl@0: sl@0: // sl@0: // CTestPolicyServer4 sl@0: // sl@0: sl@0: class CTestPolicyServer4 : public CPolicyServer sl@0: { sl@0: public: sl@0: static CTestPolicyServer4* NewL(TInt aPriority, const TPolicy& aPolicy); sl@0: CTestPolicyServer4(TInt aPriority, const TPolicy& aPolicy); sl@0: virtual CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMsg) const; sl@0: virtual TCustomResult CustomSecurityCheckL(const RMessage2& aMsg, TInt& aAction, TSecurityInfo& aMissing); sl@0: virtual TCustomResult CustomFailureActionL(const RMessage2& aMsg, TInt aAction, const TSecurityInfo& aMissing); sl@0: CCustomActive* iActiveCheck; sl@0: protected: sl@0: void ConstructL(); sl@0: }; sl@0: sl@0: CTestPolicyServer4* CTestPolicyServer4::NewL(TInt aPriority, const TPolicy& aPolicy) sl@0: { sl@0: CTestPolicyServer4* self = new(ELeave)CTestPolicyServer4(aPriority, aPolicy); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: void CTestPolicyServer4::ConstructL() sl@0: { sl@0: iActiveCheck = CCustomActive::NewL(*this); sl@0: } sl@0: sl@0: CPolicyServer::TCustomResult CTestPolicyServer4::CustomSecurityCheckL(const RMessage2& aMsg, TInt& aAction, TSecurityInfo& aMissing) sl@0: { sl@0: (void)aMissing; sl@0: OrInFlags(aMsg, KCustomCheckMask); sl@0: iActiveCheck->CustomSecurityCheckL(aMsg, aAction); sl@0: return EAsync; sl@0: } sl@0: sl@0: CPolicyServer::TCustomResult CTestPolicyServer4::CustomFailureActionL(const RMessage2& aMsg, TInt aAction, const TSecurityInfo& aMissing) sl@0: { sl@0: (void)aMissing; sl@0: OrInFlags(aMsg, KCustomActionMask); sl@0: iActiveCheck->CustomFailureActionL(aMsg, aAction); sl@0: return EAsync; sl@0: } sl@0: sl@0: // sl@0: // CTestSession4 sl@0: // sl@0: sl@0: class CTestSession4 : public CSession2 sl@0: { sl@0: public: sl@0: enum {EShutdown=100}; sl@0: public: sl@0: CTestSession4(); sl@0: virtual void ServiceL(const RMessage2& aMsg); sl@0: virtual void ServiceError(const RMessage2& aMsg, TInt aError); sl@0: public: sl@0: }; sl@0: sl@0: CTestSession4::CTestSession4() sl@0: : CSession2() sl@0: { sl@0: } sl@0: sl@0: void CTestSession4::ServiceL(const RMessage2& aMsg) sl@0: { sl@0: TInt fn = aMsg.Function(); sl@0: OrInFlags(aMsg, KServiceLMask); sl@0: switch(fn) sl@0: { sl@0: case 1: sl@0: case 3: sl@0: case 4: sl@0: case 5: sl@0: case 8: sl@0: case 9: sl@0: case 11: sl@0: aMsg.Complete(KErrNone); sl@0: break; sl@0: case 57: sl@0: User::Leave(KErrNoMemory); sl@0: break; sl@0: case CTestSession4::EShutdown: sl@0: CActiveScheduler::Stop(); sl@0: aMsg.Complete(KErrNone); sl@0: break; sl@0: case KMaxTInt: sl@0: //KMaxTInt would otherwise interfere with the OrInFlags value, so sl@0: //we return our location this way instead. sl@0: aMsg.Complete(KMaxTInt); sl@0: break; sl@0: default: sl@0: //If we get here we have an unhandled condition in the test code. sl@0: //The test code is specifically setup to try and catch all branches sl@0: //through the policy server. If you get, there is some problem in sl@0: //the setup. sl@0: test(0); sl@0: break; sl@0: } sl@0: } sl@0: sl@0: void CTestSession4::ServiceError(const RMessage2& aMsg, TInt aError) sl@0: { sl@0: OrInFlags(aMsg, KServiceErrorMask); sl@0: if(!aMsg.IsNull()) sl@0: aMsg.Complete(aError); sl@0: } sl@0: sl@0: CTestPolicyServer4::CTestPolicyServer4(TInt aPriority, const TPolicy& aPolicy) sl@0: : CPolicyServer(aPriority, aPolicy) sl@0: { sl@0: } sl@0: sl@0: CSession2* CTestPolicyServer4::NewSessionL(const TVersion& /*aVersion*/,const RMessage2& /*aMsg*/) const sl@0: { sl@0: return new (ELeave) CTestSession4(); sl@0: } sl@0: sl@0: sl@0: // sl@0: // CTestActiveScheduler sl@0: // sl@0: sl@0: class CTestActiveScheduler : public CActiveScheduler sl@0: { sl@0: public: sl@0: virtual void Error(TInt anError) const; sl@0: }; sl@0: sl@0: void CTestActiveScheduler::Error(TInt anError) const sl@0: { sl@0: User::Panic(_L("TestServer Error"),anError); sl@0: } sl@0: sl@0: sl@0: sl@0: // sl@0: // Server thread sl@0: // sl@0: sl@0: _LIT(KServerName,"T_POLSVR-server"); sl@0: const TInt KServerRendezvous = KRequestPending+1; sl@0: sl@0: void DoStartServer(const CPolicyServer::TPolicy& aPolicy, TUint aServerIndex) sl@0: { sl@0: CTestActiveScheduler* activeScheduler = new (ELeave) CTestActiveScheduler; sl@0: CActiveScheduler::Install(activeScheduler); sl@0: CleanupStack::PushL(activeScheduler); sl@0: sl@0: CPolicyServer* server = 0; sl@0: switch(aServerIndex) sl@0: { sl@0: case 0: sl@0: server = new (ELeave) CTestPolicyServer1(0,aPolicy); sl@0: break; sl@0: case 1: sl@0: server = new (ELeave) CTestPolicyServer2(0,aPolicy); sl@0: break; sl@0: case 2: sl@0: server = new (ELeave) CTestPolicyServer3(0,aPolicy); sl@0: break; sl@0: case 3: sl@0: server = CTestPolicyServer4::NewL(0,aPolicy); sl@0: break; sl@0: default: sl@0: User::Panic(KPolSvr, KErrArgument); sl@0: } sl@0: CleanupStack::PushL(server); sl@0: sl@0: User::LeaveIfError(server->Start(KServerName)); sl@0: sl@0: RProcess::Rendezvous(KServerRendezvous); sl@0: sl@0: CActiveScheduler::Start(); sl@0: sl@0: CleanupStack::PopAndDestroy(2); sl@0: } sl@0: sl@0: TInt StartServer(const CPolicyServer::TPolicy& aPolicy, TUint aServerIndex) sl@0: { sl@0: CTrapCleanup* cleanupStack = CTrapCleanup::New(); sl@0: if(!cleanupStack) sl@0: return KErrNoMemory; sl@0: TRAPD(leaveError,DoStartServer(aPolicy,aServerIndex)) sl@0: delete cleanupStack; sl@0: return leaveError; sl@0: } sl@0: sl@0: sl@0: sl@0: // sl@0: // RTestSession sl@0: // sl@0: sl@0: class RTestSession : public RSessionBase sl@0: { sl@0: public: sl@0: inline TInt Connect() sl@0: { return CreateSession(KServerName,TVersion());} sl@0: // inline TInt Send(TInt aFunction) sl@0: // { return RSessionBase::SendReceive(aFunction); } sl@0: inline TInt Send(TInt aFunction,const TIpcArgs& aArgs) sl@0: { return RSessionBase::SendReceive(aFunction,aArgs); } sl@0: inline void Send(TInt aFunction,TRequestStatus& aStatus) sl@0: { RSessionBase::SendReceive(aFunction,aStatus); } sl@0: inline void Send(TInt aFunction,const TIpcArgs& aArgs,TRequestStatus& aStatus) sl@0: { RSessionBase::SendReceive(aFunction,aArgs,aStatus); } sl@0: }; sl@0: sl@0: sl@0: sl@0: RTestSession Session; sl@0: sl@0: #include sl@0: sl@0: void TestServer1WithPolicy1() sl@0: { sl@0: RTestProcess server; sl@0: TRequestStatus rendezvous; sl@0: server.Create(~KTestCapabilities,ETestProcessPolicyServer,EPolicy1,ETestServer1); sl@0: server.Rendezvous(rendezvous); sl@0: server.Resume(); sl@0: User::WaitForRequest(rendezvous); sl@0: test(rendezvous==KServerRendezvous); sl@0: sl@0: test.Next(_L("Server 1, Policy 1")); sl@0: TInt r = Session.Connect(); sl@0: test(r==KErrNone); sl@0: sl@0: TBuf8<4> flags(4); sl@0: sl@0: //case 0: Not Supported, returned from policy server level. sl@0: SetFlags(flags, 0); sl@0: r = Session.Send(0, TIpcArgs(&flags)); sl@0: test(r==KErrNotSupported); sl@0: test(FlagsValue(flags) == (0)); sl@0: sl@0: //case 1: Custom Check, fails with KErrPermissionDenied sl@0: SetFlags(flags, 1); sl@0: r = Session.Send(1, TIpcArgs(&flags)); sl@0: test(r==KErrPermissionDenied); sl@0: test(FlagsValue(flags) == (1 | KCustomCheckMask) ); sl@0: sl@0: //case 2: Custom Check passes. sl@0: SetFlags(flags, 2); sl@0: r = Session.Send(2, TIpcArgs(&flags)); sl@0: test(r==KErrNone); sl@0: test(FlagsValue(flags) == (2 | KCustomCheckMask | KServiceLMask) ); sl@0: sl@0: //case 3: Custom Check fails but action set to EQueryUser, query sl@0: //subsequently fails sl@0: SetFlags(flags, 3); sl@0: r = Session.Send(3, TIpcArgs(&flags)); sl@0: test(r==KErrPermissionDenied); sl@0: test(FlagsValue(flags) == (3 | KCustomCheckMask | KCustomActionMask )); sl@0: sl@0: //case 4: Custom Check fails but action set to EQueryUser, query sl@0: //subsequently passes sl@0: SetFlags(flags, 4); sl@0: r = Session.Send(4, TIpcArgs(&flags)); sl@0: test(r==KErrNone); sl@0: test(FlagsValue(flags) == (4 | KCustomCheckMask | KCustomActionMask | KServiceLMask )); sl@0: sl@0: //case 5: Custom Check passes and action is set. Action set shouldn't make sl@0: //a difference. Should be same result as case 2. sl@0: SetFlags(flags, 5); sl@0: r = Session.Send(5, TIpcArgs(&flags)); sl@0: test(r==KErrNone); sl@0: test(FlagsValue(flags) == (5 | KCustomCheckMask | KServiceLMask )); sl@0: sl@0: //case 6: Always passes at the policy server level. sl@0: SetFlags(flags, 6); sl@0: r = Session.Send(6, TIpcArgs(&flags)); sl@0: test(r==KErrNone); sl@0: test(FlagsValue(flags) == (6 | KServiceLMask) ); sl@0: sl@0: //case 7: Not Supported, returned from policy server level. sl@0: SetFlags(flags, 7); sl@0: r = Session.Send(7, TIpcArgs(&flags)); sl@0: test(r==KErrNotSupported); sl@0: test(FlagsValue(flags) == (7)); sl@0: sl@0: //case 8: Requires NetworkControl, which we have, so it passes. sl@0: SetFlags(flags, 8); sl@0: r = Session.Send(8, TIpcArgs(&flags)); sl@0: test(r==KErrNone); sl@0: test(FlagsValue(flags) == (8 | KServiceLMask)); sl@0: sl@0: //case 9: Requires NetworkControl -> pass. Thrown in a EQueryUser to see sl@0: //if it causes any problems -> it shouldn't. Should be same as case 8. sl@0: SetFlags(flags, 9); sl@0: r = Session.Send(9, TIpcArgs(&flags)); sl@0: test(r==KErrNone); sl@0: test(FlagsValue(flags) == (9 | KServiceLMask)); sl@0: sl@0: //case 10: Requires DiskAdmin which we don't have. sl@0: SetFlags(flags, 10); sl@0: r = Session.Send(10, TIpcArgs(&flags)); sl@0: test(r==KErrPermissionDenied); sl@0: test(FlagsValue(flags) == (10)); sl@0: sl@0: //case 11: Requires DiskAdmin, which we don't have. EQueryUser is set, and sl@0: //it fails. sl@0: SetFlags(flags, 11); sl@0: r = Session.Send(11, TIpcArgs(&flags)); sl@0: test(r==KErrPermissionDenied); sl@0: test(FlagsValue(flags) == (11 | KCustomActionMask)); sl@0: sl@0: //case 12: Requires DiskAdmin, which we don't have. EQueryUser is set, and sl@0: //it passes. sl@0: SetFlags(flags, 12); sl@0: r = Session.Send(12, TIpcArgs(&flags)); sl@0: test(r==KErrNone); sl@0: test(FlagsValue(flags) == (12 | KCustomActionMask | KServiceLMask)); sl@0: sl@0: //case 13: Not Supported, returned from policy server level. sl@0: SetFlags(flags, 13); sl@0: r = Session.Send(13, TIpcArgs(&flags)); sl@0: test(r==KErrNotSupported); sl@0: test(FlagsValue(flags) == (13)); sl@0: sl@0: //case 14: Not Supported, returned from policy server level. sl@0: SetFlags(flags, 14); sl@0: r = Session.Send(14, TIpcArgs(&flags)); sl@0: test(r==KErrNotSupported); sl@0: test(FlagsValue(flags) == (14)); sl@0: sl@0: //case 55: Not Supported, returned from policy server level. sl@0: SetFlags(flags, 55); sl@0: r = Session.Send(55, TIpcArgs(&flags)); sl@0: test(r==KErrNotSupported); sl@0: test(FlagsValue(flags) == (55)); sl@0: sl@0: //case 86: Not Supported, returned from policy server level. sl@0: SetFlags(flags, 86); sl@0: r = Session.Send(86, TIpcArgs(&flags)); sl@0: test(r==KErrNotSupported); sl@0: test(FlagsValue(flags) == (86)); sl@0: sl@0: //case 99: Not Supported, returned from policy server level. sl@0: SetFlags(flags, 99); sl@0: r = Session.Send(99, TIpcArgs(&flags)); sl@0: test(r==KErrNotSupported); sl@0: test(FlagsValue(flags) == (99)); sl@0: sl@0: //case 101: Not Supported, returned from policy server level. sl@0: SetFlags(flags, 101); sl@0: r = Session.Send(101, TIpcArgs(&flags)); sl@0: test(r==KErrNotSupported); sl@0: test(FlagsValue(flags) == (101)); sl@0: sl@0: //case 1000191: Not Supported, returned from policy server level. sl@0: SetFlags(flags, 1000191); sl@0: r = Session.Send(1000191, TIpcArgs(&flags)); sl@0: test(r==KErrNotSupported); sl@0: test(FlagsValue(flags) == (1000191)); sl@0: sl@0: //case 1000848: Not Supported, returned from policy server level. sl@0: SetFlags(flags, 1000848); sl@0: r = Session.Send(1000848, TIpcArgs(&flags)); sl@0: test(r==KErrNotSupported); sl@0: test(FlagsValue(flags) == (1000848)); sl@0: sl@0: //case KMaxTInt-1: Not Supported, returned from policy server level. sl@0: SetFlags(flags, KMaxTInt-1); sl@0: r = Session.Send(KMaxTInt-1, TIpcArgs(&flags)); sl@0: test(r==KErrNotSupported); sl@0: test(FlagsValue(flags) == (KMaxTInt-1)); sl@0: sl@0: //case KMaxTInt: Not Supported, returned from policy server level. sl@0: SetFlags(flags, KMaxTInt); sl@0: r = Session.Send(KMaxTInt, TIpcArgs(&flags)); sl@0: test(r==KErrNotSupported); sl@0: test(FlagsValue(flags) == (TUint)(KMaxTInt)); sl@0: sl@0: r = Session.Send(CTestSession1::EShutdown, TIpcArgs(&flags)); sl@0: test.Printf(_L("r = %d\n"),r); sl@0: test(r==KErrNone); sl@0: sl@0: Session.Close(); sl@0: CLOSE_AND_WAIT(server); sl@0: } sl@0: sl@0: #include sl@0: sl@0: void TestServer1WithPolicy2() sl@0: { sl@0: test.Next(_L("Server 1, Policy 2")); sl@0: RTestProcess server; sl@0: TRequestStatus rendezvous; sl@0: server.Create(~KTestCapabilities,ETestProcessPolicyServer,EPolicy2,ETestServer1); sl@0: server.Rendezvous(rendezvous); sl@0: server.Resume(); sl@0: User::WaitForRequest(rendezvous); sl@0: #ifdef _DEBUG sl@0: //Debug mode does a policy integrity check sl@0: test(rendezvous==EPolSvr1stRangeNotZero); sl@0: #else sl@0: test(rendezvous==KServerRendezvous); sl@0: server.Terminate(0); sl@0: #endif sl@0: CLOSE_AND_WAIT(server); sl@0: } sl@0: sl@0: void TestServer1WithPolicy3() sl@0: { sl@0: test.Next(_L("Server 1, Policy 3")); sl@0: RTestProcess server; sl@0: TRequestStatus rendezvous; sl@0: server.Create(~KTestCapabilities,ETestProcessPolicyServer,EPolicy3,ETestServer1); sl@0: server.Rendezvous(rendezvous); sl@0: server.Resume(); sl@0: User::WaitForRequest(rendezvous); sl@0: #ifdef _DEBUG sl@0: //Debug mode does a policy integrity check sl@0: test(rendezvous==EPolSvrRangesNotIncreasing); sl@0: #else sl@0: test(rendezvous==KServerRendezvous); sl@0: server.Terminate(0); sl@0: #endif sl@0: CLOSE_AND_WAIT(server); sl@0: } sl@0: sl@0: void TestServer1WithPolicy4() sl@0: { sl@0: test.Next(_L("Server 1, Policy 4")); sl@0: RTestProcess server; sl@0: TRequestStatus rendezvous; sl@0: server.Create(~KTestCapabilities,ETestProcessPolicyServer,EPolicy4,ETestServer1); sl@0: server.Rendezvous(rendezvous); sl@0: server.Resume(); sl@0: User::WaitForRequest(rendezvous); sl@0: #ifdef _DEBUG sl@0: //Debug mode does a policy integrity check sl@0: test(rendezvous==EPolSvrElementsIndexValueInvalid); sl@0: #else sl@0: test(rendezvous==KServerRendezvous); sl@0: server.Terminate(0); sl@0: #endif sl@0: CLOSE_AND_WAIT(server); sl@0: } sl@0: sl@0: void TestServer1WithPolicy5() sl@0: { sl@0: test.Next(_L("Server 1, Policy 5")); sl@0: RTestProcess server; sl@0: TRequestStatus rendezvous; sl@0: server.Create(~KTestCapabilities,ETestProcessPolicyServer,EPolicy5,ETestServer1); sl@0: server.Rendezvous(rendezvous); sl@0: server.Resume(); sl@0: User::WaitForRequest(rendezvous); sl@0: #ifdef _DEBUG sl@0: //Debug mode does a policy integrity check sl@0: test(rendezvous==EPolSvrElementsIndexValueInvalid); sl@0: #else sl@0: test(rendezvous==KServerRendezvous); sl@0: server.Terminate(0); sl@0: #endif sl@0: CLOSE_AND_WAIT(server); sl@0: } sl@0: sl@0: void TestServer1WithPolicy6() sl@0: { sl@0: test.Next(_L("Server 1, Policy 6")); sl@0: RTestProcess server; sl@0: TRequestStatus rendezvous; sl@0: server.Create(~KTestCapabilities,ETestProcessPolicyServer,EPolicy6,ETestServer1); sl@0: server.Rendezvous(rendezvous); sl@0: server.Resume(); sl@0: User::WaitForRequest(rendezvous); sl@0: #ifdef _DEBUG sl@0: //Debug mode does a policy integrity check sl@0: test(rendezvous==EPolSvrIOnConnectValueInvalid); sl@0: #else sl@0: test(rendezvous==KServerRendezvous); sl@0: server.Terminate(0); sl@0: #endif sl@0: CLOSE_AND_WAIT(server); sl@0: } sl@0: sl@0: void TestServer1WithPolicy7() sl@0: { sl@0: test.Next(_L("Server 1, Policy 7")); sl@0: RTestProcess server; sl@0: TRequestStatus rendezvous; sl@0: server.Create(~KTestCapabilities,ETestProcessPolicyServer,EPolicy7,ETestServer1); sl@0: server.Rendezvous(rendezvous); sl@0: server.Resume(); sl@0: User::WaitForRequest(rendezvous); sl@0: test(rendezvous==KServerRendezvous); sl@0: sl@0: TInt r = Session.Connect(); sl@0: test(r==KErrNotSupported); sl@0: sl@0: //We can do this because we have power management sl@0: server.Terminate(KErrGeneral); sl@0: CLOSE_AND_WAIT(server); sl@0: } sl@0: sl@0: void TestServer1WithPolicy8() sl@0: { sl@0: test.Next(_L("Server 1, Policy 8")); sl@0: RTestProcess server; sl@0: TRequestStatus rendezvous; sl@0: server.Create(~KTestCapabilities,ETestProcessPolicyServer,EPolicy8,ETestServer1); sl@0: server.Rendezvous(rendezvous); sl@0: server.Resume(); sl@0: User::WaitForRequest(rendezvous); sl@0: test(rendezvous==KServerRendezvous); sl@0: sl@0: //This will be calling through CustomSecurityCheckL (server1 will return sl@0: //pass), but there is no easy way to determine that it has followed the sl@0: //correct path. sl@0: TInt r = Session.Connect(); sl@0: test(r==KErrNone); sl@0: sl@0: server.Terminate(KErrGeneral); sl@0: Session.Close(); sl@0: CLOSE_AND_WAIT(server); sl@0: } sl@0: sl@0: void TestServer2WithPolicy8() sl@0: { sl@0: test.Next(_L("Server 2, Policy 8")); sl@0: RTestProcess server; sl@0: TRequestStatus rendezvous; sl@0: TRequestStatus logon; sl@0: server.Create(~KTestCapabilities,ETestProcessPolicyServer,EPolicy8,ETestServer2); sl@0: server.Rendezvous(rendezvous); sl@0: server.Logon(logon); sl@0: server.Resume(); sl@0: User::WaitForRequest(rendezvous); sl@0: test(rendezvous==KServerRendezvous); sl@0: sl@0: TInt r = Session.Connect(); sl@0: test(r==KErrServerTerminated); sl@0: sl@0: //This is a simple way of testing that CustomSecurityCheckL is called for a sl@0: //connect custom check. Server2 doesn't have an implementation of CustomSecurityCheckL sl@0: User::WaitForRequest(logon); sl@0: test(logon == EPolSvrCallingBaseImplementation); sl@0: sl@0: Session.Close(); sl@0: CLOSE_AND_WAIT(server); sl@0: } sl@0: sl@0: void TestServer3WithPolicy8() sl@0: { sl@0: test.Next(_L("Server 3, Policy 8")); sl@0: RTestProcess server; sl@0: TRequestStatus rendezvous; sl@0: server.Create(~KTestCapabilities,ETestProcessPolicyServer,EPolicy8,ETestServer1); sl@0: server.Rendezvous(rendezvous); sl@0: server.Resume(); sl@0: User::WaitForRequest(rendezvous); sl@0: test(rendezvous==KServerRendezvous); sl@0: sl@0: //This will be calling through CustomSecurityCheckL sl@0: //(server3::CustomSecurityCheckL will fail this, but set the action to sl@0: //EQueryUser, which will call CustomFailureActionL which should will in sl@0: //this case pass) but there is no easy way to determine that it has sl@0: //followed the correct path. sl@0: TInt r = Session.Connect(); sl@0: test(r==KErrNone); sl@0: sl@0: //This policy doesn't have any IPC's that work. Only way to shutdown sl@0: //server is to kill it. sl@0: server.Terminate(KErrGeneral); sl@0: Session.Close(); sl@0: CLOSE_AND_WAIT(server); sl@0: } sl@0: sl@0: sl@0: void TestServer1WithPolicy9() sl@0: { sl@0: test.Next(_L("Server 1, Policy 9")); sl@0: RTestProcess server; sl@0: TRequestStatus rendezvous; sl@0: server.Create(~KTestCapabilities,ETestProcessPolicyServer,EPolicy9,ETestServer1); sl@0: server.Rendezvous(rendezvous); sl@0: server.Resume(); sl@0: User::WaitForRequest(rendezvous); sl@0: test(rendezvous==KServerRendezvous); sl@0: sl@0: TInt r = Session.Connect(); sl@0: test(r==KErrPermissionDenied); sl@0: sl@0: //We can do this because we have power management sl@0: server.Terminate(KErrGeneral); sl@0: CLOSE_AND_WAIT(server); sl@0: } sl@0: sl@0: void TestServer2WithPolicy1() sl@0: { sl@0: test.Next(_L("Server 2, Policy 1")); sl@0: RTestProcess server; sl@0: TRequestStatus rendezvous; sl@0: server.Create(~KTestCapabilities,ETestProcessPolicyServer,EPolicy1,ETestServer2); sl@0: server.Rendezvous(rendezvous); sl@0: server.Resume(); sl@0: User::WaitForRequest(rendezvous); sl@0: test(rendezvous==KServerRendezvous); sl@0: sl@0: TInt r = Session.Connect(); sl@0: test(r==KErrNone); sl@0: sl@0: TBuf8<4> flags(4); sl@0: r = Session.Send(CTestSession2::EShutdown, TIpcArgs(&flags)); sl@0: test(r == KErrNone); sl@0: Session.Close(); sl@0: CLOSE_AND_WAIT(server); sl@0: } sl@0: sl@0: void TestServer4WithPolicy10() sl@0: { sl@0: test.Next(_L("Server 4, Policy 10")); sl@0: RTestProcess server; sl@0: TRequestStatus rendezvous; sl@0: server.Create(~KTestCapabilities,ETestProcessPolicyServer,EPolicy10,ETestServer4); sl@0: server.Rendezvous(rendezvous); sl@0: server.Resume(); sl@0: User::WaitForRequest(rendezvous); sl@0: test(rendezvous==KServerRendezvous); sl@0: sl@0: TInt r = Session.Connect(); sl@0: test(r==KErrNone); sl@0: sl@0: TBuf8<4> flags(4); sl@0: sl@0: //case 0: Custom Check, fails with KErrPermissionDenied sl@0: SetFlags(flags, 0); sl@0: r = Session.Send(0, TIpcArgs(&flags)); sl@0: test(r==KErrPermissionDenied); sl@0: test(FlagsValue(flags) == (0 | KCustomCheckMask | KActiveCheckMask | KActiveRunLMask) ); sl@0: sl@0: //case 1: Custom Check passes. sl@0: SetFlags(flags, 1); sl@0: r = Session.Send(1, TIpcArgs(&flags)); sl@0: test(r==KErrNone); sl@0: test(FlagsValue(flags) == (1 | KCustomCheckMask | KActiveCheckMask | KActiveRunLMask | KServiceLMask) ); sl@0: sl@0: //case 2: Custom Check fails but action set to EQueryUser, query sl@0: //subsequently fails sl@0: SetFlags(flags, 2); sl@0: r = Session.Send(2, TIpcArgs(&flags)); sl@0: test(r==KErrPermissionDenied); sl@0: test(FlagsValue(flags) == (2 | KCustomCheckMask | KActiveCheckMask | KActiveRunLMask | KCustomActionMask | KActiveActionMask )); sl@0: sl@0: //case 3: Custom Check fails but action set to EQueryUser, query sl@0: //subsequently passes sl@0: SetFlags(flags, 3); sl@0: r = Session.Send(3, TIpcArgs(&flags)); sl@0: test(r==KErrNone); sl@0: test(FlagsValue(flags) == (3 | KCustomCheckMask | KActiveCheckMask | KActiveRunLMask | KCustomActionMask | KActiveActionMask | KServiceLMask )); sl@0: sl@0: //case 4: Custom Check passes and action is set. Action set shouldn't make sl@0: //a difference. Should be same result as case 1. sl@0: SetFlags(flags, 4); sl@0: r = Session.Send(4, TIpcArgs(&flags)); sl@0: test(r==KErrNone); sl@0: test(FlagsValue(flags) == (4 | KCustomCheckMask | KActiveCheckMask | KActiveRunLMask | KServiceLMask) ); sl@0: sl@0: //case 5: Always passes at the policy server level. sl@0: SetFlags(flags, 5); sl@0: r = Session.Send(5, TIpcArgs(&flags)); sl@0: test(r==KErrNone); sl@0: test(FlagsValue(flags) == (5 | KServiceLMask) ); sl@0: sl@0: //case 6: Not Supported, returned from policy server level. sl@0: SetFlags(flags, 6); sl@0: r = Session.Send(6, TIpcArgs(&flags)); sl@0: test(r==KErrNotSupported); sl@0: test(FlagsValue(flags) == (6)); sl@0: sl@0: //case 7: Not Supported, returned from policy server level. sl@0: SetFlags(flags, 7); sl@0: r = Session.Send(7, TIpcArgs(&flags)); sl@0: test(r==KErrNotSupported); sl@0: test(FlagsValue(flags) == (7)); sl@0: sl@0: //case 8: Requires NetworkControl, which we have, so it passes. sl@0: SetFlags(flags, 8); sl@0: r = Session.Send(8, TIpcArgs(&flags)); sl@0: test(r==KErrNone); sl@0: test(FlagsValue(flags) == (8 | KServiceLMask)); sl@0: sl@0: //case 9: Requires DiskAdmin, which we don't have. EQueryUser is set, and sl@0: //it passes. sl@0: SetFlags(flags, 9); sl@0: r = Session.Send(9, TIpcArgs(&flags)); sl@0: test(r==KErrNone); sl@0: test(FlagsValue(flags) == (9 | KCustomActionMask | KActiveActionMask | KActiveRunLMask | KServiceLMask)); sl@0: sl@0: //case 10: Requires DiskAdmin which we don't have. sl@0: SetFlags(flags, 10); sl@0: r = Session.Send(10, TIpcArgs(&flags)); sl@0: test(r==KErrPermissionDenied); sl@0: test(FlagsValue(flags) == (10)); sl@0: sl@0: //case 11: Requires NetworkControl -> pass. Thrown in a EQueryUser to see sl@0: //if it causes any problems -> it shouldn't. Should be same as case 8. sl@0: SetFlags(flags, 11); sl@0: r = Session.Send(11, TIpcArgs(&flags)); sl@0: test(r==KErrNone); sl@0: test(FlagsValue(flags) == (11 | KServiceLMask)); sl@0: sl@0: //case 12: Not Supported, returned from policy server level. sl@0: SetFlags(flags, 12); sl@0: r = Session.Send(12, TIpcArgs(&flags)); sl@0: test(r==KErrNotSupported); sl@0: test(FlagsValue(flags) == (12)); sl@0: sl@0: //case 13: Not Supported, returned from policy server level. sl@0: SetFlags(flags, 13); sl@0: r = Session.Send(13, TIpcArgs(&flags)); sl@0: test(r==KErrNotSupported); sl@0: test(FlagsValue(flags) == (13)); sl@0: sl@0: //case 54: Not Supported, returned from policy server level. sl@0: SetFlags(flags, 54); sl@0: r = Session.Send(54, TIpcArgs(&flags)); sl@0: test(r==KErrNotSupported); sl@0: test(FlagsValue(flags) == (54)); sl@0: sl@0: //case 55: Requires DiskAdmin -> Fail. But then we query user, and then we sl@0: //cancel that. sl@0: SetFlags(flags, 55); sl@0: r = Session.Send(55, TIpcArgs(&flags)); sl@0: test(r==KErrCancel); sl@0: test(FlagsValue(flags) == (55 | KCustomActionMask | KActiveActionMask | KActiveDoCancelMask)); sl@0: sl@0: //case 56: Requires DiskAdmin -> Fail. But then we query user which leaves. sl@0: SetFlags(flags, 56); sl@0: r = Session.Send(56, TIpcArgs(&flags)); sl@0: test(r==KErrNoMemory); sl@0: test(FlagsValue(flags) == (56 | KCustomActionMask | KActiveActionMask | KActiveRunLMask | KActiveRunErrorMask)); sl@0: sl@0: //case 57: Requires DiskAdmin -> Fail. But then we query user which passes sl@0: //and then we leave in the ServiceL sl@0: SetFlags(flags, 57); sl@0: r = Session.Send(57, TIpcArgs(&flags)); sl@0: test(r==KErrNoMemory); sl@0: test(FlagsValue(flags) == (57 | KCustomActionMask | KActiveActionMask | KActiveRunLMask | KServiceLMask | KActiveRunErrorMask | KServiceErrorMask )); sl@0: sl@0: //case 58: Not Supported, returned from policy server level. sl@0: SetFlags(flags, 58); sl@0: r = Session.Send(58, TIpcArgs(&flags)); sl@0: test(r==KErrNotSupported); sl@0: test(FlagsValue(flags) == (58)); sl@0: sl@0: //case 86: Not Supported, returned from policy server level. sl@0: SetFlags(flags, 86); sl@0: r = Session.Send(86, TIpcArgs(&flags)); sl@0: test(r==KErrNotSupported); sl@0: test(FlagsValue(flags) == (86)); sl@0: sl@0: //case 99: Not Supported, returned from policy server level. sl@0: SetFlags(flags, 99); sl@0: r = Session.Send(99, TIpcArgs(&flags)); sl@0: test(r==KErrNotSupported); sl@0: test(FlagsValue(flags) == (99)); sl@0: sl@0: //case 101: Not Supported, returned from policy server level. sl@0: SetFlags(flags, 101); sl@0: r = Session.Send(101, TIpcArgs(&flags)); sl@0: test(r==KErrNotSupported); sl@0: test(FlagsValue(flags) == (101)); sl@0: sl@0: //case 5000: Not Supported, returned from policy server level. sl@0: SetFlags(flags, 5000); sl@0: r = Session.Send(5000, TIpcArgs(&flags)); sl@0: test(r==KErrNotSupported); sl@0: test(FlagsValue(flags) == (5000)); sl@0: sl@0: //case KMaxTInt-1: Not Supported, returned from policy server level. sl@0: SetFlags(flags, KMaxTInt-1); sl@0: r = Session.Send(KMaxTInt-1, TIpcArgs(&flags)); sl@0: test(r==KErrNotSupported); sl@0: test(FlagsValue(flags) == (KMaxTInt-1)); sl@0: sl@0: //case KMaxTInt: Always pass from policy framework sl@0: //This also tests another exit condition from the binary search sl@0: SetFlags(flags, 0); sl@0: r = Session.Send(KMaxTInt, TIpcArgs(&flags)); sl@0: //Instead of KErrNone we return KMaxTInt as we can't fit the KMaxTInt in sl@0: //the flags without overwriting stuff sl@0: test(r==KMaxTInt); sl@0: test(FlagsValue(flags) == (0 | KServiceLMask )); sl@0: sl@0: r = Session.Send(CTestSession2::EShutdown, TIpcArgs(&flags)); sl@0: test(r == KErrNone); sl@0: Session.Close(); sl@0: CLOSE_AND_WAIT(server); sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: TBuf16<512> cmd; sl@0: User::CommandLine(cmd); sl@0: if(cmd.Length() && TChar(cmd[0]).IsDigit()) sl@0: { sl@0: TInt function = -1; sl@0: TInt arg1 = -1; sl@0: TInt arg2 = -1; sl@0: TLex lex(cmd); sl@0: sl@0: lex.Val(function); sl@0: lex.SkipSpace(); sl@0: lex.Val(arg1); sl@0: lex.SkipSpace(); sl@0: lex.Val(arg2); sl@0: return DoTestProcess(function,arg1,arg2); sl@0: } sl@0: sl@0: test.Title(); sl@0: sl@0: if(!PlatSec::ConfigSetting(PlatSec::EPlatSecEnforcement)) sl@0: { sl@0: test.Start(_L("TESTS NOT RUN - EPlatSecEnforcement is OFF")); sl@0: test.End(); sl@0: return 0; sl@0: } sl@0: sl@0: test.Start(_L("Policy Server Tests")); sl@0: sl@0: /* Server1 has implementations of CustomSecurityCheckL and sl@0: CustomFailureActionL This is the test for all the paths in a policy servers sl@0: implementations -- not all connect paths though sl@0: This test also ensures that every path through the binary search is sl@0: covered. */ sl@0: TestServer1WithPolicy1(); sl@0: sl@0: /* Policy2,3,4,5,6, are bad policies that should cause the server to panic sl@0: in debug mode. In release, they'll just pass, however, if you later tried sl@0: to use them, something would go horribly wrong */ sl@0: TestServer1WithPolicy2(); sl@0: TestServer1WithPolicy3(); sl@0: TestServer1WithPolicy4(); sl@0: TestServer1WithPolicy5(); sl@0: TestServer1WithPolicy6(); sl@0: sl@0: /* Policies 7,8,9 check various types of connect policies. */ sl@0: TestServer1WithPolicy7(); sl@0: // Server 1,2,3 are used here all with policy 8 because you can only test 1 sl@0: // type of connect policy per server. sl@0: TestServer1WithPolicy8(); sl@0: TestServer2WithPolicy8(); sl@0: TestServer3WithPolicy8(); sl@0: TestServer1WithPolicy9(); sl@0: sl@0: /* Sever2 does not have implementations of CustomSecurityCheckL and sl@0: CustomFailureActionL. When these functions are called it should crash */ sl@0: TestServer2WithPolicy1(); sl@0: sl@0: /* Server4 is used for checking what happens when the custom functions use sl@0: another active object. This test encompasses leaving due to OOM, and sl@0: cancellation. */ sl@0: TestServer4WithPolicy10(); sl@0: sl@0: test.End(); sl@0: return(0); sl@0: } sl@0: