os/kernelhwsrv/kerneltest/e32test/secure/t_polsvr.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// e32test\secure\t_polsvr.cpp
sl@0
    15
// Overview:
sl@0
    16
// Policy Server Tests
sl@0
    17
// API Information:
sl@0
    18
// CPolicyServer
sl@0
    19
// Details:
sl@0
    20
// - Perform various policy server tests:
sl@0
    21
// Server1 has implementations of CustomSecurityCheckL and
sl@0
    22
// CustomFailureActionL This is the test for all the paths in a policy servers
sl@0
    23
// implementations -- not all connect paths though
sl@0
    24
// This test also ensures that every path through the binary search is
sl@0
    25
// covered.
sl@0
    26
// Policy2,3,4,5,6, are bad policies that should cause the server to panic
sl@0
    27
// in debug mode.  In release, they'll just pass, however, if you later tried
sl@0
    28
// to use them, something would go horribly wrong
sl@0
    29
// Policies 7,8,9 check various types of connect policies.
sl@0
    30
// Server 1,2,3 are used here all with policy 8 because you can only test 1
sl@0
    31
// type of connect policy per server.
sl@0
    32
// Sever2 does not have implementations of CustomSecurityCheckL and
sl@0
    33
// CustomFailureActionL. When these functions are called it should crash
sl@0
    34
// Server4 is used for checking what happens when the custom functions use
sl@0
    35
// another active object.  This test encompasses leaving due to OOM, and
sl@0
    36
// cancellation.
sl@0
    37
// Platforms/Drives/Compatibility:
sl@0
    38
// All.
sl@0
    39
// Assumptions/Requirement/Pre-requisites:
sl@0
    40
// Failures and causes:
sl@0
    41
// Base Port information:
sl@0
    42
// 
sl@0
    43
//
sl@0
    44
sl@0
    45
#include <e32test.h>
sl@0
    46
#include <e32debug.h>
sl@0
    47
sl@0
    48
LOCAL_D RTest test(_L("T_POLSVR"));
sl@0
    49
sl@0
    50
_LIT(KPolSvr, "T_POLSVR");
sl@0
    51
sl@0
    52
#define Debug(x) RDebug::Print(_L(x))
sl@0
    53
sl@0
    54
const TUint32 KTestCapabilities =(1<<ECapabilityTCB)
sl@0
    55
								|(1<<ECapabilityPowerMgmt)
sl@0
    56
								|(1<<ECapabilityReadDeviceData)
sl@0
    57
								|(1<<ECapabilityDRM)
sl@0
    58
								|(1<<ECapabilityProtServ)
sl@0
    59
								|(1<<ECapabilityNetworkControl)
sl@0
    60
								|(1<<ECapabilitySwEvent)
sl@0
    61
								|(1<<ECapabilityLocalServices)
sl@0
    62
								|(1<<ECapabilityWriteUserData);
sl@0
    63
sl@0
    64
const TInt KCustomCheckMask		= 0x01000000;
sl@0
    65
const TInt KCustomActionMask	= 0x02000000;
sl@0
    66
const TInt KServiceLMask		= 0x04000000;
sl@0
    67
const TInt KActiveCheckMask 	= 0x08000000;
sl@0
    68
const TInt KActiveActionMask	= 0x00100000;
sl@0
    69
const TInt KActiveRunLMask  	= 0x00200000;
sl@0
    70
const TInt KActiveRunErrorMask	= 0x00400000;
sl@0
    71
const TInt KActiveDoCancelMask	= 0x00800000;
sl@0
    72
const TInt KServiceErrorMask	= 0x00010000;
sl@0
    73
sl@0
    74
//Ideally this constant should go in your derived server.  However, I couldn't
sl@0
    75
//be bothered to put the same constant in every one of the derived servers in
sl@0
    76
//this test code
sl@0
    77
const TInt KQueryUser = -1;
sl@0
    78
sl@0
    79
void OrInFlags(const RMessage2& aMsg, TUint aMask)
sl@0
    80
	{
sl@0
    81
	TBuf8<4> flags(0);
sl@0
    82
	TInt r = aMsg.Read(0, flags);
sl@0
    83
	test(r == KErrNone);
sl@0
    84
	(*(TUint32*)(flags.Ptr())) |= aMask;
sl@0
    85
	flags.SetLength(4);
sl@0
    86
	r = aMsg.Write(0, flags);
sl@0
    87
	test(r == KErrNone);
sl@0
    88
	}
sl@0
    89
sl@0
    90
void SetFlags(TDes8& aDes, TUint aValue)
sl@0
    91
	{
sl@0
    92
	(*(TUint32*)(aDes.Ptr())) = aValue;
sl@0
    93
	}
sl@0
    94
sl@0
    95
TUint FlagsValue(const TDes8& aDes)
sl@0
    96
	{
sl@0
    97
	return (*(TUint32*)(aDes.Ptr()));
sl@0
    98
	}
sl@0
    99
sl@0
   100
enum TTestProcessFunctions
sl@0
   101
	{
sl@0
   102
	ETestProcessPolicyServer,
sl@0
   103
	};
sl@0
   104
sl@0
   105
enum TTestServerIndex
sl@0
   106
	{
sl@0
   107
	ETestServer1=0,
sl@0
   108
	ETestServer2,
sl@0
   109
	ETestServer3,
sl@0
   110
	ETestServer4,
sl@0
   111
	};
sl@0
   112
sl@0
   113
enum TServerPolicyIndex
sl@0
   114
	{
sl@0
   115
	EPolicy1=0,
sl@0
   116
	EPolicy2,
sl@0
   117
	EPolicy3,
sl@0
   118
	EPolicy4,
sl@0
   119
	EPolicy5,
sl@0
   120
	EPolicy6,
sl@0
   121
	EPolicy7,
sl@0
   122
	EPolicy8,
sl@0
   123
	EPolicy9,
sl@0
   124
	EPolicy10,
sl@0
   125
	EPolicy11,
sl@0
   126
	EPolicy12,
sl@0
   127
	};
sl@0
   128
sl@0
   129
//
sl@0
   130
// EPolicy1
sl@0
   131
//
sl@0
   132
sl@0
   133
const TUint gServerPolicy1RangeCount = 12;
sl@0
   134
const TInt gServerPolicy1Ranges[gServerPolicy1RangeCount] = { 
sl@0
   135
	0, //ENotSupported
sl@0
   136
	1, //ECustomCheck
sl@0
   137
	6, //EAlwaysPass
sl@0
   138
	7, //ENotSupported
sl@0
   139
	8, //->0
sl@0
   140
	9, //->1
sl@0
   141
	10, //->2
sl@0
   142
	11, //->3
sl@0
   143
	12, //->3
sl@0
   144
	13, //ENotSupported
sl@0
   145
	100, //EAlwaysPass -> Shutdown
sl@0
   146
	101, //ENotSupported
sl@0
   147
	};
sl@0
   148
sl@0
   149
const TUint8 gServerPolicy1ElementsIndex[] = { 
sl@0
   150
	CPolicyServer::ENotSupported,
sl@0
   151
	CPolicyServer::ECustomCheck, 
sl@0
   152
	CPolicyServer::EAlwaysPass, 
sl@0
   153
	CPolicyServer::ENotSupported,
sl@0
   154
	0, //RequireNetworkControl or EFail
sl@0
   155
	1, //RequireNetworkControl or EQueryUser
sl@0
   156
	2, //RequireDiskAdmin or EFail
sl@0
   157
	3, //RequireDiskAdmin or EQueryUser
sl@0
   158
	3, //RequireDiskAdmin or EQueryUser
sl@0
   159
	CPolicyServer::ENotSupported,
sl@0
   160
	CPolicyServer::EAlwaysPass, 
sl@0
   161
	CPolicyServer::ENotSupported,
sl@0
   162
	};
sl@0
   163
sl@0
   164
const CPolicyServer::TPolicyElement gServerPolicy1Elements[] =
sl@0
   165
	{
sl@0
   166
	{_INIT_SECURITY_POLICY_C1(ECapabilityNetworkControl),CPolicyServer::EFailClient},
sl@0
   167
	{_INIT_SECURITY_POLICY_C1(ECapabilityNetworkControl),KQueryUser},
sl@0
   168
	{_INIT_SECURITY_POLICY_C1(ECapabilityDiskAdmin),CPolicyServer::EFailClient},
sl@0
   169
	{_INIT_SECURITY_POLICY_C1(ECapabilityDiskAdmin),KQueryUser},
sl@0
   170
	};
sl@0
   171
sl@0
   172
const CPolicyServer::TPolicy gServerPolicy1 = 
sl@0
   173
	{
sl@0
   174
	CPolicyServer::EAlwaysPass,gServerPolicy1RangeCount,
sl@0
   175
	gServerPolicy1Ranges,
sl@0
   176
	gServerPolicy1ElementsIndex,
sl@0
   177
	gServerPolicy1Elements,
sl@0
   178
	};
sl@0
   179
sl@0
   180
//
sl@0
   181
//EPolicy2
sl@0
   182
//
sl@0
   183
sl@0
   184
const TUint gServerPolicy2RangeCount = 1;
sl@0
   185
//Invalid Policy -- doesn't start with 0
sl@0
   186
const TInt gServerPolicy2Ranges[gServerPolicy2RangeCount] = { 
sl@0
   187
	1, //KErrNotSupported
sl@0
   188
	};
sl@0
   189
sl@0
   190
const TUint8 gServerPolicy2ElementsIndex[] = { 
sl@0
   191
	CPolicyServer::ENotSupported,
sl@0
   192
	};
sl@0
   193
sl@0
   194
const CPolicyServer::TPolicyElement gServerPolicy2Elements[] =
sl@0
   195
	{
sl@0
   196
	{_INIT_SECURITY_POLICY_FAIL,CPolicyServer::EFailClient},
sl@0
   197
	};
sl@0
   198
sl@0
   199
const CPolicyServer::TPolicy gServerPolicy2 = 
sl@0
   200
	{
sl@0
   201
	0,gServerPolicy2RangeCount,
sl@0
   202
	gServerPolicy2Ranges,
sl@0
   203
	gServerPolicy2ElementsIndex,
sl@0
   204
	gServerPolicy2Elements
sl@0
   205
	};
sl@0
   206
sl@0
   207
//
sl@0
   208
//EPolicy3
sl@0
   209
//
sl@0
   210
sl@0
   211
const TUint gServerPolicy3RangeCount = 12;
sl@0
   212
//Invalid Policy -- range values not increasing
sl@0
   213
const TInt gServerPolicy3Ranges[gServerPolicy3RangeCount] = { 
sl@0
   214
	0, //ECustomCheck
sl@0
   215
	6, //EAlwaysPass
sl@0
   216
	7, //ENotSupported
sl@0
   217
	8, //->0
sl@0
   218
	9, //->1
sl@0
   219
	10, //->2
sl@0
   220
	11, //->3
sl@0
   221
	12, //->3
sl@0
   222
	13, //ENotSupported
sl@0
   223
	100, //EAlwaysPass -> Shutdown
sl@0
   224
	101, //ENotSupported
sl@0
   225
	99, //EAlwaysPass
sl@0
   226
	};
sl@0
   227
sl@0
   228
const TUint8 gServerPolicy3ElementsIndex[] = { 
sl@0
   229
	CPolicyServer::ECustomCheck, 
sl@0
   230
	CPolicyServer::EAlwaysPass, 
sl@0
   231
	CPolicyServer::ENotSupported,
sl@0
   232
	0, //RequireNetworkControl or EFail
sl@0
   233
	1, //RequireNetworkControl or EQueryUser
sl@0
   234
	2, //RequireDiskAdmin or EFail
sl@0
   235
	3, //RequireDiskAdmin or EQueryUser
sl@0
   236
	3, //RequireDiskAdmin or EQueryUser
sl@0
   237
	CPolicyServer::ENotSupported,
sl@0
   238
	CPolicyServer::EAlwaysPass, 
sl@0
   239
	CPolicyServer::ENotSupported,
sl@0
   240
	CPolicyServer::EAlwaysPass, 
sl@0
   241
	};
sl@0
   242
sl@0
   243
const CPolicyServer::TPolicyElement gServerPolicy3Elements[] =
sl@0
   244
	{
sl@0
   245
	{_INIT_SECURITY_POLICY_C1(ECapabilityNetworkControl),CPolicyServer::EFailClient},
sl@0
   246
	{_INIT_SECURITY_POLICY_C1(ECapabilityNetworkControl),KQueryUser},
sl@0
   247
	{_INIT_SECURITY_POLICY_C1(ECapabilityDiskAdmin),CPolicyServer::EFailClient},
sl@0
   248
	{_INIT_SECURITY_POLICY_C1(ECapabilityDiskAdmin),KQueryUser},
sl@0
   249
	};
sl@0
   250
sl@0
   251
const CPolicyServer::TPolicy gServerPolicy3 = 
sl@0
   252
	{
sl@0
   253
	0,gServerPolicy3RangeCount,
sl@0
   254
	gServerPolicy3Ranges,
sl@0
   255
	gServerPolicy3ElementsIndex,
sl@0
   256
	gServerPolicy3Elements
sl@0
   257
	};
sl@0
   258
sl@0
   259
//
sl@0
   260
//EPolicy4
sl@0
   261
//
sl@0
   262
sl@0
   263
const TUint gServerPolicy4RangeCount = 1;
sl@0
   264
//Invalid Policy -- Elements Index has invalid values
sl@0
   265
const TInt gServerPolicy4Ranges[gServerPolicy4RangeCount] = { 
sl@0
   266
	0, //Invalid value
sl@0
   267
	};
sl@0
   268
sl@0
   269
const TUint8 gServerPolicy4ElementsIndex[] = { 
sl@0
   270
	CPolicyServer::ESpecialCaseHardLimit,
sl@0
   271
	};
sl@0
   272
sl@0
   273
const CPolicyServer::TPolicyElement gServerPolicy4Elements[] =
sl@0
   274
	{
sl@0
   275
	{_INIT_SECURITY_POLICY_FAIL,CPolicyServer::EFailClient},
sl@0
   276
	};
sl@0
   277
sl@0
   278
const CPolicyServer::TPolicy gServerPolicy4 = 
sl@0
   279
	{
sl@0
   280
	0,gServerPolicy4RangeCount,
sl@0
   281
	gServerPolicy4Ranges,
sl@0
   282
	gServerPolicy4ElementsIndex,
sl@0
   283
	gServerPolicy4Elements
sl@0
   284
	};
sl@0
   285
sl@0
   286
//
sl@0
   287
//EPolicy5
sl@0
   288
//
sl@0
   289
sl@0
   290
const TUint gServerPolicy5RangeCount = 1;
sl@0
   291
//Invalid Policy -- Elements Index has invalid values
sl@0
   292
const TInt gServerPolicy5Ranges[gServerPolicy5RangeCount] = { 
sl@0
   293
	0, //uses Invalid value
sl@0
   294
	};
sl@0
   295
sl@0
   296
const TUint8 gServerPolicy5ElementsIndex[] = { 
sl@0
   297
	//Uses invalid value 
sl@0
   298
	CPolicyServer::ESpecialCaseLimit,
sl@0
   299
	};
sl@0
   300
sl@0
   301
const CPolicyServer::TPolicyElement gServerPolicy5Elements[] =
sl@0
   302
	{
sl@0
   303
	{_INIT_SECURITY_POLICY_FAIL,CPolicyServer::EFailClient},
sl@0
   304
	};
sl@0
   305
sl@0
   306
const CPolicyServer::TPolicy gServerPolicy5 = 
sl@0
   307
	{
sl@0
   308
	0,gServerPolicy5RangeCount,
sl@0
   309
	gServerPolicy5Ranges,
sl@0
   310
	gServerPolicy5ElementsIndex,
sl@0
   311
	gServerPolicy5Elements
sl@0
   312
	};
sl@0
   313
sl@0
   314
//
sl@0
   315
//EPolicy6
sl@0
   316
//
sl@0
   317
sl@0
   318
const TUint gServerPolicy6RangeCount = 1;
sl@0
   319
//Invalid Policy -- Elements Index has invalid values
sl@0
   320
const TInt gServerPolicy6Ranges[gServerPolicy6RangeCount] = { 
sl@0
   321
	0,
sl@0
   322
	};
sl@0
   323
sl@0
   324
const TUint8 gServerPolicy6ElementsIndex[] = { 
sl@0
   325
	CPolicyServer::ENotSupported,
sl@0
   326
	};
sl@0
   327
sl@0
   328
const CPolicyServer::TPolicyElement gServerPolicy6Elements[] =
sl@0
   329
	{
sl@0
   330
	{_INIT_SECURITY_POLICY_FAIL,CPolicyServer::EFailClient},
sl@0
   331
	};
sl@0
   332
sl@0
   333
const CPolicyServer::TPolicy gServerPolicy6 = 
sl@0
   334
	{
sl@0
   335
	//Uses invalid value for iOnConnect
sl@0
   336
	CPolicyServer::ESpecialCaseHardLimit,gServerPolicy6RangeCount,
sl@0
   337
	gServerPolicy6Ranges,
sl@0
   338
	gServerPolicy6ElementsIndex,
sl@0
   339
	gServerPolicy6Elements
sl@0
   340
	};
sl@0
   341
sl@0
   342
//
sl@0
   343
//EPolicy7
sl@0
   344
//
sl@0
   345
// Connect not supported
sl@0
   346
const TUint gServerPolicy7RangeCount = 1;
sl@0
   347
const TInt gServerPolicy7Ranges[gServerPolicy7RangeCount] = { 
sl@0
   348
	0,
sl@0
   349
	};
sl@0
   350
sl@0
   351
const TUint8 gServerPolicy7ElementsIndex[] = { 
sl@0
   352
	0
sl@0
   353
	};
sl@0
   354
sl@0
   355
const CPolicyServer::TPolicyElement gServerPolicy7Elements[] =
sl@0
   356
	{
sl@0
   357
	{_INIT_SECURITY_POLICY_FAIL,CPolicyServer::EFailClient},
sl@0
   358
	};
sl@0
   359
sl@0
   360
const CPolicyServer::TPolicy gServerPolicy7 = 
sl@0
   361
	{
sl@0
   362
	CPolicyServer::ENotSupported,gServerPolicy7RangeCount,
sl@0
   363
	gServerPolicy7Ranges,
sl@0
   364
	gServerPolicy7ElementsIndex,
sl@0
   365
	gServerPolicy7Elements
sl@0
   366
	};
sl@0
   367
sl@0
   368
//
sl@0
   369
//EPolicy8
sl@0
   370
//
sl@0
   371
// Connect Custom Check
sl@0
   372
const TUint gServerPolicy8RangeCount = 1;
sl@0
   373
const TInt gServerPolicy8Ranges[gServerPolicy8RangeCount] = { 
sl@0
   374
	0,
sl@0
   375
	};
sl@0
   376
sl@0
   377
const TUint8 gServerPolicy8ElementsIndex[] = { 
sl@0
   378
	0
sl@0
   379
	};
sl@0
   380
sl@0
   381
const CPolicyServer::TPolicyElement gServerPolicy8Elements[] =
sl@0
   382
	{
sl@0
   383
	{_INIT_SECURITY_POLICY_FAIL,CPolicyServer::EPanicClient},
sl@0
   384
	};
sl@0
   385
sl@0
   386
const CPolicyServer::TPolicy gServerPolicy8 = 
sl@0
   387
	{
sl@0
   388
	CPolicyServer::ECustomCheck,gServerPolicy8RangeCount,
sl@0
   389
	gServerPolicy8Ranges,
sl@0
   390
	gServerPolicy8ElementsIndex,
sl@0
   391
	gServerPolicy8Elements
sl@0
   392
	};
sl@0
   393
sl@0
   394
//
sl@0
   395
//EPolicy9
sl@0
   396
//
sl@0
   397
// Connect has a static policy but it fails.
sl@0
   398
const TUint gServerPolicy9RangeCount = 1;
sl@0
   399
const TInt gServerPolicy9Ranges[gServerPolicy9RangeCount] = { 
sl@0
   400
	0,
sl@0
   401
	};
sl@0
   402
sl@0
   403
const TUint8 gServerPolicy9ElementsIndex[] = { 
sl@0
   404
	0
sl@0
   405
	};
sl@0
   406
sl@0
   407
const CPolicyServer::TPolicyElement gServerPolicy9Elements[] =
sl@0
   408
	{
sl@0
   409
	{_INIT_SECURITY_POLICY_FAIL,CPolicyServer::EFailClient},
sl@0
   410
	};
sl@0
   411
sl@0
   412
const CPolicyServer::TPolicy gServerPolicy9 = 
sl@0
   413
	{
sl@0
   414
	0,gServerPolicy9RangeCount,
sl@0
   415
	gServerPolicy9Ranges,
sl@0
   416
	gServerPolicy9ElementsIndex,
sl@0
   417
	gServerPolicy9Elements
sl@0
   418
	};
sl@0
   419
sl@0
   420
//
sl@0
   421
// EPolicy10
sl@0
   422
//
sl@0
   423
sl@0
   424
const TUint gServerPolicy10RangeCount = 13;
sl@0
   425
const TInt gServerPolicy10Ranges[gServerPolicy10RangeCount] = { 
sl@0
   426
	0, //ECustomCheck
sl@0
   427
	5, //EAlwaysPass
sl@0
   428
	6, //ENotSupported
sl@0
   429
	8, //->0
sl@0
   430
	9, //->3
sl@0
   431
	10, //->2
sl@0
   432
	11, //->1
sl@0
   433
	12, //ENotSupported
sl@0
   434
	55, //->3
sl@0
   435
	58, //ENotSupported
sl@0
   436
	100, //EAlwaysPass -> Shutdown
sl@0
   437
	101, //ENotSupported
sl@0
   438
	KMaxTInt, //EAlways Pass
sl@0
   439
	};
sl@0
   440
sl@0
   441
const TUint8 gServerPolicy10ElementsIndex[] = { 
sl@0
   442
	CPolicyServer::ECustomCheck, 
sl@0
   443
	CPolicyServer::EAlwaysPass, 
sl@0
   444
	CPolicyServer::ENotSupported,
sl@0
   445
	0, //RequireNetworkControl or EFail
sl@0
   446
	3, //RequireDiskAdmin or EQueryUser
sl@0
   447
	2, //RequireDiskAdmin or EFail
sl@0
   448
	1, //RequireNetworkControl or EQueryUser
sl@0
   449
	CPolicyServer::ENotSupported,
sl@0
   450
	3,
sl@0
   451
	CPolicyServer::ENotSupported,
sl@0
   452
	CPolicyServer::EAlwaysPass, 
sl@0
   453
	CPolicyServer::ENotSupported,
sl@0
   454
	CPolicyServer::EAlwaysPass, 
sl@0
   455
	};
sl@0
   456
sl@0
   457
const CPolicyServer::TPolicyElement gServerPolicy10Elements[] =
sl@0
   458
	{
sl@0
   459
	{_INIT_SECURITY_POLICY_C1(ECapabilityNetworkControl),CPolicyServer::EFailClient},
sl@0
   460
	{_INIT_SECURITY_POLICY_C1(ECapabilityNetworkControl),KQueryUser},
sl@0
   461
	{_INIT_SECURITY_POLICY_C1(ECapabilityDiskAdmin),CPolicyServer::EFailClient},
sl@0
   462
	{_INIT_SECURITY_POLICY_C1(ECapabilityDiskAdmin),KQueryUser},
sl@0
   463
	};
sl@0
   464
sl@0
   465
const CPolicyServer::TPolicy gServerPolicy10 = 
sl@0
   466
	{
sl@0
   467
	CPolicyServer::EAlwaysPass,gServerPolicy10RangeCount,
sl@0
   468
	gServerPolicy10Ranges,
sl@0
   469
	gServerPolicy10ElementsIndex,
sl@0
   470
	gServerPolicy10Elements,
sl@0
   471
	};
sl@0
   472
sl@0
   473
sl@0
   474
//A list of all the global policies
sl@0
   475
const CPolicyServer::TPolicy* gPolicyIndex[] = {
sl@0
   476
	&gServerPolicy1,
sl@0
   477
	&gServerPolicy2,
sl@0
   478
	&gServerPolicy3,
sl@0
   479
	&gServerPolicy4,
sl@0
   480
	&gServerPolicy5,
sl@0
   481
	&gServerPolicy6,
sl@0
   482
	&gServerPolicy7,
sl@0
   483
	&gServerPolicy8,
sl@0
   484
	&gServerPolicy9,
sl@0
   485
	&gServerPolicy10,
sl@0
   486
	};
sl@0
   487
sl@0
   488
sl@0
   489
#include "testprocess.h"
sl@0
   490
sl@0
   491
TInt StartServer(const CPolicyServer::TPolicy& aPolicy, TUint aServerIndex);
sl@0
   492
sl@0
   493
TInt DoTestProcess(TInt aTestNum,TInt aArg1,TInt aArg2)
sl@0
   494
	{
sl@0
   495
	switch(aTestNum)
sl@0
   496
		{
sl@0
   497
sl@0
   498
	case ETestProcessPolicyServer:
sl@0
   499
		{
sl@0
   500
		__ASSERT_ALWAYS(aArg1 >= 0 && aArg1 < (TInt)sizeof(gPolicyIndex)>>2, User::Panic(KPolSvr, KErrArgument));
sl@0
   501
		const CPolicyServer::TPolicy& policy = *(gPolicyIndex[aArg1]);
sl@0
   502
		__ASSERT_ALWAYS(aArg2 >= 0, User::Panic(KPolSvr, KErrArgument));
sl@0
   503
		TInt r;
sl@0
   504
		r=StartServer(policy, TUint(aArg2));
sl@0
   505
		if(r==KErrAlreadyExists)
sl@0
   506
			{
sl@0
   507
			User::After(2*1000*1000);
sl@0
   508
			r=StartServer(policy, TUint(aArg2));
sl@0
   509
			}
sl@0
   510
		return r;
sl@0
   511
		}
sl@0
   512
sl@0
   513
	default:
sl@0
   514
		User::Panic(_L("T_POLSVR"),1);
sl@0
   515
		}
sl@0
   516
sl@0
   517
	return KErrNone;
sl@0
   518
	}
sl@0
   519
sl@0
   520
sl@0
   521
//
sl@0
   522
// RTestThread
sl@0
   523
//
sl@0
   524
sl@0
   525
class RTestThread : public RThread
sl@0
   526
	{
sl@0
   527
public:
sl@0
   528
	void Create(TThreadFunction aFunction,TAny* aArg=0);
sl@0
   529
	};
sl@0
   530
sl@0
   531
void RTestThread::Create(TThreadFunction aFunction,TAny* aArg)
sl@0
   532
	{
sl@0
   533
	TInt r=RThread::Create(_L(""),aFunction,KDefaultStackSize,KDefaultStackSize,KDefaultStackSize,aArg);
sl@0
   534
	test(r==KErrNone);
sl@0
   535
	}
sl@0
   536
sl@0
   537
//
sl@0
   538
// CTestSession1
sl@0
   539
//
sl@0
   540
sl@0
   541
class CTestSession1 : public CSession2
sl@0
   542
	{
sl@0
   543
public:
sl@0
   544
	enum {EShutdown=100};
sl@0
   545
public:
sl@0
   546
	CTestSession1();
sl@0
   547
	virtual void ServiceL(const RMessage2& aMsg);
sl@0
   548
public:
sl@0
   549
	};
sl@0
   550
sl@0
   551
CTestSession1::CTestSession1()
sl@0
   552
	: CSession2()
sl@0
   553
	{}
sl@0
   554
sl@0
   555
sl@0
   556
void CTestSession1::ServiceL(const RMessage2& aMsg)
sl@0
   557
	{
sl@0
   558
	OrInFlags(aMsg, KServiceLMask);
sl@0
   559
	TInt fn = aMsg.Function();
sl@0
   560
	switch(fn)
sl@0
   561
		{
sl@0
   562
		case 2:
sl@0
   563
		case 4:
sl@0
   564
		case 5:
sl@0
   565
		case 6:
sl@0
   566
		case 8:
sl@0
   567
		case 9:
sl@0
   568
		case 12:
sl@0
   569
		case KMaxTInt:
sl@0
   570
			aMsg.Complete(KErrNone);
sl@0
   571
			break;
sl@0
   572
sl@0
   573
		case CTestSession1::EShutdown:
sl@0
   574
			CActiveScheduler::Stop();
sl@0
   575
			aMsg.Complete(KErrNone);
sl@0
   576
			break;
sl@0
   577
		default:
sl@0
   578
			//If we get here we have an unhandled condition in the test code.
sl@0
   579
			//The test code is specifically setup to try and catch all branches
sl@0
   580
			//through the policy server.  If you get, there is some problem in
sl@0
   581
			//the setup.
sl@0
   582
			test(0);
sl@0
   583
			break;
sl@0
   584
		}
sl@0
   585
	}
sl@0
   586
sl@0
   587
//
sl@0
   588
// CTestPolicyServer1
sl@0
   589
//
sl@0
   590
sl@0
   591
class CTestPolicyServer1 : public CPolicyServer
sl@0
   592
	{
sl@0
   593
public:
sl@0
   594
	CTestPolicyServer1(TInt aPriority, const TPolicy& aPolicy);
sl@0
   595
	virtual CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMsg) const;
sl@0
   596
	virtual TCustomResult CustomSecurityCheckL(const RMessage2& aMsg, TInt& aAction, TSecurityInfo& aMissing);
sl@0
   597
	virtual TCustomResult CustomFailureActionL(const RMessage2& aMsg, TInt aAction, const TSecurityInfo& aMissing);
sl@0
   598
	};
sl@0
   599
sl@0
   600
CTestPolicyServer1::CTestPolicyServer1(TInt aPriority, const TPolicy& aPolicy)
sl@0
   601
	: CPolicyServer(aPriority, aPolicy)
sl@0
   602
	{
sl@0
   603
	}
sl@0
   604
sl@0
   605
CSession2* CTestPolicyServer1::NewSessionL(const TVersion& /*aVersion*/,const RMessage2& /*aMsg*/) const
sl@0
   606
	{
sl@0
   607
	return new (ELeave) CTestSession1();
sl@0
   608
	}
sl@0
   609
sl@0
   610
CPolicyServer::TCustomResult CTestPolicyServer1::CustomSecurityCheckL(const RMessage2& aMsg, TInt& aAction, TSecurityInfo& aMissing)
sl@0
   611
	{
sl@0
   612
	TInt fn = aMsg.Function();
sl@0
   613
	if(fn >= 0)
sl@0
   614
		{
sl@0
   615
		//Connect messages don't use this debugging system
sl@0
   616
		OrInFlags(aMsg, KCustomCheckMask);
sl@0
   617
		}
sl@0
   618
	if(fn == -1) //Connect
sl@0
   619
		{
sl@0
   620
		return EPass;
sl@0
   621
		}
sl@0
   622
	else if(fn == 1)
sl@0
   623
		{
sl@0
   624
		aMissing.iCaps.AddCapability(ECapabilityCommDD);
sl@0
   625
		return EFail;
sl@0
   626
		}
sl@0
   627
	else if(fn == 2)
sl@0
   628
		{
sl@0
   629
		return EPass;
sl@0
   630
		}
sl@0
   631
	else if(fn == 3)
sl@0
   632
		{
sl@0
   633
		aMissing.iCaps.AddCapability(ECapabilityCommDD);
sl@0
   634
		aAction = KQueryUser;
sl@0
   635
		return EFail;
sl@0
   636
		}
sl@0
   637
	else if(fn == 4)
sl@0
   638
		{
sl@0
   639
		aMissing.iCaps.AddCapability(ECapabilityCommDD);
sl@0
   640
		aAction = KQueryUser;
sl@0
   641
		return EFail;
sl@0
   642
		}
sl@0
   643
	else if(fn == 5)
sl@0
   644
		{
sl@0
   645
		//Since we are returning ETrue here, setting the action shouldn't affect
sl@0
   646
		//anything.  This should result in the same as 2.
sl@0
   647
		aAction = KQueryUser;
sl@0
   648
		return EPass;
sl@0
   649
		}
sl@0
   650
	//If we get here we have an unhandled condition in the test code.  The test
sl@0
   651
	//code is specifically setup to try and catch all branches through the
sl@0
   652
	//policy server.  If you get, there is some problem in the setup.
sl@0
   653
	test(0);
sl@0
   654
	return EFail;
sl@0
   655
	}
sl@0
   656
sl@0
   657
CPolicyServer::TCustomResult CTestPolicyServer1::CustomFailureActionL(const RMessage2& aMsg, TInt aAction, const TSecurityInfo& aMissing)
sl@0
   658
	{
sl@0
   659
	(void)aMissing;
sl@0
   660
	(void)aMsg;
sl@0
   661
	(void)aAction;
sl@0
   662
	TInt fn = aMsg.Function();
sl@0
   663
	if(fn >= 0)
sl@0
   664
		{
sl@0
   665
		//Connect messages don't use this debugging system
sl@0
   666
		OrInFlags(aMsg, KCustomActionMask);
sl@0
   667
		}
sl@0
   668
	switch(fn)
sl@0
   669
		{
sl@0
   670
		case 3:
sl@0
   671
			return EFail;
sl@0
   672
		case 4:
sl@0
   673
			return EPass;
sl@0
   674
		case 11:
sl@0
   675
			return EFail;
sl@0
   676
		case 12:
sl@0
   677
			return EPass;
sl@0
   678
		default:
sl@0
   679
			break;
sl@0
   680
		}
sl@0
   681
sl@0
   682
	//If we get here we have an unhandled condition in the test code.  The test
sl@0
   683
	//code is specifically setup to try and catch all branches through the
sl@0
   684
	//policy server.  If you get, there is some problem in the setup.
sl@0
   685
	test(0);
sl@0
   686
	return EFail;
sl@0
   687
	}
sl@0
   688
sl@0
   689
//
sl@0
   690
// CTestPolicyServer2
sl@0
   691
//
sl@0
   692
sl@0
   693
class CTestPolicyServer2 : public CPolicyServer
sl@0
   694
	{
sl@0
   695
public:
sl@0
   696
	CTestPolicyServer2(TInt aPriority, const TPolicy& aPolicy);
sl@0
   697
	virtual CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMsg) const;
sl@0
   698
	//virtual TBool CustomSecurityCheckL(const RMessage2& aMsg, TInt& aAction);
sl@0
   699
	//virtual TBool CustomFailureActionL(const TSecurityPolicy* aPolicy, const RMessage2& aMsg, TInt aAction);
sl@0
   700
	};
sl@0
   701
sl@0
   702
//
sl@0
   703
// CTestSession2
sl@0
   704
//
sl@0
   705
sl@0
   706
class CTestSession2 : public CSession2
sl@0
   707
	{
sl@0
   708
public:
sl@0
   709
	enum {EShutdown=100};
sl@0
   710
public:
sl@0
   711
	CTestSession2();
sl@0
   712
	virtual void ServiceL(const RMessage2& aMsg);
sl@0
   713
public:
sl@0
   714
	};
sl@0
   715
sl@0
   716
CTestSession2::CTestSession2()
sl@0
   717
	: CSession2()
sl@0
   718
	{
sl@0
   719
	}
sl@0
   720
sl@0
   721
void CTestSession2::ServiceL(const RMessage2& aMsg)
sl@0
   722
	{
sl@0
   723
	TInt fn = aMsg.Function();
sl@0
   724
	switch(fn)
sl@0
   725
		{
sl@0
   726
		case CTestSession2::EShutdown:
sl@0
   727
			CActiveScheduler::Stop();
sl@0
   728
			aMsg.Complete(KErrNone);
sl@0
   729
			break;
sl@0
   730
		default:
sl@0
   731
			//If we get here we have an unhandled condition in the test code.
sl@0
   732
			//The test code is specifically setup to try and catch all branches
sl@0
   733
			//through the policy server.  If you get, there is some problem in
sl@0
   734
			//the setup.
sl@0
   735
			test(0);
sl@0
   736
			break;
sl@0
   737
		}
sl@0
   738
	}
sl@0
   739
sl@0
   740
CTestPolicyServer2::CTestPolicyServer2(TInt aPriority, const TPolicy& aPolicy)
sl@0
   741
	: CPolicyServer(aPriority, aPolicy)
sl@0
   742
	{
sl@0
   743
	}
sl@0
   744
sl@0
   745
CSession2* CTestPolicyServer2::NewSessionL(const TVersion& /*aVersion*/,const RMessage2& /*aMsg*/) const
sl@0
   746
	{
sl@0
   747
	return new (ELeave) CTestSession2();
sl@0
   748
	}
sl@0
   749
sl@0
   750
//
sl@0
   751
// CTestPolicyServer3
sl@0
   752
//
sl@0
   753
sl@0
   754
class CTestPolicyServer3 : public CPolicyServer
sl@0
   755
	{
sl@0
   756
public:
sl@0
   757
	CTestPolicyServer3(TInt aPriority, const TPolicy& aPolicy);
sl@0
   758
	virtual CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMsg) const;
sl@0
   759
	virtual TCustomResult CustomSecurityCheckL(const RMessage2& aMsg, TInt& aAction, TSecurityInfo&);
sl@0
   760
	virtual TCustomResult CustomFailureActionL(const RMessage2& aMsg, TInt aAction, const TSecurityInfo& aMissing);
sl@0
   761
	};
sl@0
   762
sl@0
   763
CPolicyServer::TCustomResult CTestPolicyServer3::CustomSecurityCheckL(const RMessage2& aMsg, TInt& aAction, TSecurityInfo& aMissing)
sl@0
   764
	{
sl@0
   765
	(void)aAction;
sl@0
   766
	(void)aMsg;
sl@0
   767
	(void)aMissing;
sl@0
   768
	//If we get here we have an unhandled condition in the test code.  The test
sl@0
   769
	//code is specifically setup to try and catch all branches through the
sl@0
   770
	//policy server.  If you get, there is some problem in the setup.
sl@0
   771
	test(0);
sl@0
   772
	return EFail;
sl@0
   773
	}
sl@0
   774
sl@0
   775
CPolicyServer::TCustomResult CTestPolicyServer3::CustomFailureActionL(const RMessage2& aMsg, TInt aAction, const TSecurityInfo& aMissing)
sl@0
   776
	{
sl@0
   777
	(void)aMissing;
sl@0
   778
	(void)aMsg;
sl@0
   779
	(void)aAction;
sl@0
   780
	TInt fn = aMsg.Function();
sl@0
   781
	switch(fn)
sl@0
   782
		{
sl@0
   783
		case -1:
sl@0
   784
			return EPass;
sl@0
   785
		default:
sl@0
   786
			break;
sl@0
   787
		}
sl@0
   788
sl@0
   789
	//If we get here we have an unhandled condition in the test code.  The test
sl@0
   790
	//code is specifically setup to try and catch all branches through the
sl@0
   791
	//policy server.  If you get, there is some problem in the setup.
sl@0
   792
	test(0);
sl@0
   793
	return EFail;
sl@0
   794
	}
sl@0
   795
sl@0
   796
//
sl@0
   797
// CTestSession3
sl@0
   798
//
sl@0
   799
sl@0
   800
class CTestSession3 : public CSession2
sl@0
   801
	{
sl@0
   802
public:
sl@0
   803
	enum {EShutdown=100};
sl@0
   804
public:
sl@0
   805
	CTestSession3();
sl@0
   806
	virtual void ServiceL(const RMessage2& aMsg);
sl@0
   807
public:
sl@0
   808
	};
sl@0
   809
sl@0
   810
CTestSession3::CTestSession3()
sl@0
   811
	: CSession2()
sl@0
   812
	{
sl@0
   813
	}
sl@0
   814
sl@0
   815
void CTestSession3::ServiceL(const RMessage2& aMsg)
sl@0
   816
	{
sl@0
   817
	TInt fn = aMsg.Function();
sl@0
   818
	switch(fn)
sl@0
   819
		{
sl@0
   820
		case CTestSession3::EShutdown:
sl@0
   821
			CActiveScheduler::Stop();
sl@0
   822
			aMsg.Complete(KErrNone);
sl@0
   823
			break;
sl@0
   824
		default:
sl@0
   825
			//If we get here we have an unhandled condition in the test code.
sl@0
   826
			//The test code is specifically setup to try and catch all branches
sl@0
   827
			//through the policy server.  If you get, there is some problem in
sl@0
   828
			//the setup.
sl@0
   829
			test(0);
sl@0
   830
			break;
sl@0
   831
		}
sl@0
   832
	}
sl@0
   833
sl@0
   834
CTestPolicyServer3::CTestPolicyServer3(TInt aPriority, const TPolicy& aPolicy)
sl@0
   835
	: CPolicyServer(aPriority, aPolicy)
sl@0
   836
	{
sl@0
   837
	}
sl@0
   838
sl@0
   839
CSession2* CTestPolicyServer3::NewSessionL(const TVersion& /*aVersion*/,const RMessage2& /*aMsg*/) const
sl@0
   840
	{
sl@0
   841
	return new (ELeave) CTestSession3();
sl@0
   842
	}
sl@0
   843
sl@0
   844
_LIT(KCustomActive, "CCustomActive");
sl@0
   845
//
sl@0
   846
// CCustomActive
sl@0
   847
//
sl@0
   848
sl@0
   849
class CCustomActive : public CActive
sl@0
   850
	{
sl@0
   851
public:
sl@0
   852
	static CCustomActive* NewL(CPolicyServer& aServer);
sl@0
   853
	void RunL();
sl@0
   854
	TInt RunError(TInt aError);
sl@0
   855
	void DoCancel();
sl@0
   856
	void CustomSecurityCheckL(const RMessage2& aMsg, TInt aAction);
sl@0
   857
	void CustomFailureActionL(const RMessage2& aMsg, TInt aAction);
sl@0
   858
protected:
sl@0
   859
	void HandleSecurityCheckResultL();
sl@0
   860
	void HandleFailureActionResultL();
sl@0
   861
	void ConstructL();	
sl@0
   862
private:
sl@0
   863
	CCustomActive(CPolicyServer& aServer);
sl@0
   864
	RTimer iTimer;
sl@0
   865
	CPolicyServer& iServer;
sl@0
   866
	const RMessage2* iMsg;
sl@0
   867
	enum TState {
sl@0
   868
		ECustomSecurityCheck,
sl@0
   869
		EFailureAction,
sl@0
   870
		};
sl@0
   871
	TState iState;
sl@0
   872
	TInt iAction;
sl@0
   873
	TSecurityInfo iMissing;
sl@0
   874
	};
sl@0
   875
sl@0
   876
CCustomActive::CCustomActive(CPolicyServer& aServer)
sl@0
   877
	: CActive(0), iServer(aServer), iMsg(0), iState(ECustomSecurityCheck)
sl@0
   878
	{
sl@0
   879
	CActiveScheduler::Add(this);
sl@0
   880
	}
sl@0
   881
sl@0
   882
CCustomActive* CCustomActive::NewL(CPolicyServer& aServer)
sl@0
   883
	{
sl@0
   884
	CCustomActive* self = new(ELeave)CCustomActive(aServer);
sl@0
   885
	CleanupStack::PushL(self);
sl@0
   886
	self->ConstructL();
sl@0
   887
	CleanupStack::Pop(self);
sl@0
   888
	return self;
sl@0
   889
	}
sl@0
   890
sl@0
   891
void CCustomActive::ConstructL()
sl@0
   892
	{
sl@0
   893
	User::LeaveIfError(iTimer.CreateLocal());
sl@0
   894
	memset(&iMissing, 0, sizeof(TSecurityInfo));
sl@0
   895
	}
sl@0
   896
sl@0
   897
void CCustomActive::HandleSecurityCheckResultL()
sl@0
   898
	{
sl@0
   899
	TInt fn = iMsg->Function();
sl@0
   900
	switch(fn)
sl@0
   901
		{
sl@0
   902
		case 0:
sl@0
   903
			iStatus = KErrGeneral;
sl@0
   904
			break;
sl@0
   905
		case 1: //pass
sl@0
   906
		case 4:
sl@0
   907
			break;
sl@0
   908
		case 2:
sl@0
   909
		case 3:
sl@0
   910
			iStatus = KErrGeneral;
sl@0
   911
			iAction = KQueryUser;
sl@0
   912
			break;
sl@0
   913
		default:
sl@0
   914
			test(0);
sl@0
   915
		}
sl@0
   916
	if(iStatus == KErrNone)
sl@0
   917
		{
sl@0
   918
		iServer.ProcessL(*iMsg);
sl@0
   919
		iMsg=0;
sl@0
   920
		}
sl@0
   921
	else
sl@0
   922
		{
sl@0
   923
		const RMessage2* ptr = iMsg;
sl@0
   924
		iMsg=0;
sl@0
   925
		iServer.CheckFailedL(*ptr, iAction, iMissing);
sl@0
   926
		}
sl@0
   927
	}
sl@0
   928
sl@0
   929
void CCustomActive::HandleFailureActionResultL()
sl@0
   930
	{
sl@0
   931
	TInt fn = iMsg->Function();
sl@0
   932
	switch(fn)
sl@0
   933
		{
sl@0
   934
		case 2:
sl@0
   935
			iStatus = KErrGeneral;
sl@0
   936
			break;
sl@0
   937
		case 3: //pass
sl@0
   938
		case 9:
sl@0
   939
		case 57: //passes through so ServiceL can leave with NoMem
sl@0
   940
			break;
sl@0
   941
		case 56:
sl@0
   942
			User::Leave(KErrNoMemory);
sl@0
   943
			break;
sl@0
   944
			
sl@0
   945
		default:
sl@0
   946
			test(0);
sl@0
   947
		}
sl@0
   948
	if(iStatus == KErrNone)
sl@0
   949
		iServer.ProcessL(*iMsg);
sl@0
   950
	else
sl@0
   951
		iMsg->Complete(KErrPermissionDenied);
sl@0
   952
	iMsg=0;
sl@0
   953
	}
sl@0
   954
sl@0
   955
void CCustomActive::RunL()
sl@0
   956
	{
sl@0
   957
	OrInFlags(*iMsg, KActiveRunLMask);
sl@0
   958
sl@0
   959
	switch(iState)
sl@0
   960
		{
sl@0
   961
		case ECustomSecurityCheck:
sl@0
   962
			HandleSecurityCheckResultL();
sl@0
   963
			break;
sl@0
   964
		case EFailureAction:
sl@0
   965
			HandleFailureActionResultL();
sl@0
   966
			break;
sl@0
   967
		default:
sl@0
   968
			//Invalid state
sl@0
   969
			User::Panic(KCustomActive, 11);
sl@0
   970
			break;
sl@0
   971
		}
sl@0
   972
	}
sl@0
   973
sl@0
   974
TInt CCustomActive::RunError(TInt aError)
sl@0
   975
	{
sl@0
   976
	OrInFlags(*iMsg, KActiveRunErrorMask);
sl@0
   977
	if(iMsg)
sl@0
   978
		{
sl@0
   979
		iServer.ProcessError(*iMsg, aError);
sl@0
   980
		iMsg = 0;
sl@0
   981
		iAction = CPolicyServer::EFailClient;
sl@0
   982
		return KErrNone;
sl@0
   983
		}
sl@0
   984
	else
sl@0
   985
		return aError;
sl@0
   986
	}
sl@0
   987
sl@0
   988
void CCustomActive::DoCancel()
sl@0
   989
	{
sl@0
   990
	OrInFlags(*iMsg, KActiveDoCancelMask);
sl@0
   991
	iTimer.Cancel();
sl@0
   992
	if(iMsg)
sl@0
   993
		{
sl@0
   994
		iMsg->Complete(KErrCancel);
sl@0
   995
		}
sl@0
   996
	iMsg = 0;
sl@0
   997
	iAction = CPolicyServer::EFailClient;
sl@0
   998
	}
sl@0
   999
sl@0
  1000
void CCustomActive::CustomSecurityCheckL(const RMessage2& aMsg, TInt aAction)
sl@0
  1001
	{
sl@0
  1002
	__ASSERT_ALWAYS(!IsActive(), User::Panic(KCustomActive, 1));
sl@0
  1003
	__ASSERT_ALWAYS(iMsg == 0, User::Panic(KCustomActive, 2));
sl@0
  1004
sl@0
  1005
	OrInFlags(aMsg, KActiveCheckMask);
sl@0
  1006
sl@0
  1007
	iTimer.After(iStatus, 100000);
sl@0
  1008
	SetActive();
sl@0
  1009
	iMsg = &aMsg;
sl@0
  1010
	iState = ECustomSecurityCheck;
sl@0
  1011
	iAction = aAction;
sl@0
  1012
	}
sl@0
  1013
sl@0
  1014
void CCustomActive::CustomFailureActionL(const RMessage2& aMsg, TInt aAction)
sl@0
  1015
	{
sl@0
  1016
	__ASSERT_ALWAYS(!IsActive(), User::Panic(KCustomActive, 3));
sl@0
  1017
	__ASSERT_ALWAYS(iMsg == 0, User::Panic(KCustomActive, 4));
sl@0
  1018
sl@0
  1019
	OrInFlags(aMsg, KActiveActionMask);
sl@0
  1020
sl@0
  1021
	iTimer.After(iStatus, 50000);
sl@0
  1022
	SetActive();
sl@0
  1023
	iMsg = &aMsg;
sl@0
  1024
	iState = EFailureAction;
sl@0
  1025
	iAction = aAction;
sl@0
  1026
sl@0
  1027
	if(aMsg.Function() == 55)
sl@0
  1028
		{
sl@0
  1029
		Cancel();
sl@0
  1030
		}
sl@0
  1031
	}
sl@0
  1032
sl@0
  1033
//
sl@0
  1034
// CTestPolicyServer4
sl@0
  1035
//
sl@0
  1036
sl@0
  1037
class CTestPolicyServer4 : public CPolicyServer
sl@0
  1038
	{
sl@0
  1039
public:
sl@0
  1040
	static CTestPolicyServer4* NewL(TInt aPriority, const TPolicy& aPolicy);
sl@0
  1041
	CTestPolicyServer4(TInt aPriority, const TPolicy& aPolicy);
sl@0
  1042
	virtual CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMsg) const;
sl@0
  1043
	virtual TCustomResult CustomSecurityCheckL(const RMessage2& aMsg, TInt& aAction, TSecurityInfo& aMissing);
sl@0
  1044
	virtual TCustomResult CustomFailureActionL(const RMessage2& aMsg, TInt aAction, const TSecurityInfo& aMissing);
sl@0
  1045
	CCustomActive* iActiveCheck;
sl@0
  1046
protected:
sl@0
  1047
	void ConstructL();
sl@0
  1048
	};
sl@0
  1049
sl@0
  1050
CTestPolicyServer4* CTestPolicyServer4::NewL(TInt aPriority, const TPolicy& aPolicy)
sl@0
  1051
	{
sl@0
  1052
	CTestPolicyServer4* self = new(ELeave)CTestPolicyServer4(aPriority, aPolicy);
sl@0
  1053
	CleanupStack::PushL(self);
sl@0
  1054
	self->ConstructL();
sl@0
  1055
	CleanupStack::Pop(self);
sl@0
  1056
	return self;
sl@0
  1057
	}
sl@0
  1058
sl@0
  1059
void CTestPolicyServer4::ConstructL()
sl@0
  1060
	{
sl@0
  1061
	iActiveCheck = CCustomActive::NewL(*this);
sl@0
  1062
	}
sl@0
  1063
sl@0
  1064
CPolicyServer::TCustomResult CTestPolicyServer4::CustomSecurityCheckL(const RMessage2& aMsg, TInt& aAction, TSecurityInfo& aMissing)
sl@0
  1065
	{
sl@0
  1066
	(void)aMissing;
sl@0
  1067
	OrInFlags(aMsg, KCustomCheckMask);
sl@0
  1068
	iActiveCheck->CustomSecurityCheckL(aMsg, aAction);
sl@0
  1069
	return EAsync;
sl@0
  1070
	}
sl@0
  1071
sl@0
  1072
CPolicyServer::TCustomResult CTestPolicyServer4::CustomFailureActionL(const RMessage2& aMsg, TInt aAction, const TSecurityInfo& aMissing)
sl@0
  1073
	{
sl@0
  1074
	(void)aMissing;
sl@0
  1075
	OrInFlags(aMsg, KCustomActionMask);
sl@0
  1076
	iActiveCheck->CustomFailureActionL(aMsg, aAction);
sl@0
  1077
	return EAsync;
sl@0
  1078
	}
sl@0
  1079
sl@0
  1080
//
sl@0
  1081
// CTestSession4
sl@0
  1082
//
sl@0
  1083
sl@0
  1084
class CTestSession4 : public CSession2
sl@0
  1085
	{
sl@0
  1086
public:
sl@0
  1087
	enum {EShutdown=100};
sl@0
  1088
public:
sl@0
  1089
	CTestSession4();
sl@0
  1090
	virtual void ServiceL(const RMessage2& aMsg);
sl@0
  1091
	virtual void ServiceError(const RMessage2& aMsg, TInt aError);
sl@0
  1092
public:
sl@0
  1093
	};
sl@0
  1094
sl@0
  1095
CTestSession4::CTestSession4()
sl@0
  1096
	: CSession2()
sl@0
  1097
	{
sl@0
  1098
	}
sl@0
  1099
sl@0
  1100
void CTestSession4::ServiceL(const RMessage2& aMsg)
sl@0
  1101
	{
sl@0
  1102
	TInt fn = aMsg.Function();
sl@0
  1103
	OrInFlags(aMsg, KServiceLMask);
sl@0
  1104
	switch(fn)
sl@0
  1105
		{
sl@0
  1106
		case 1:
sl@0
  1107
		case 3:
sl@0
  1108
		case 4:
sl@0
  1109
		case 5:
sl@0
  1110
		case 8:
sl@0
  1111
		case 9:
sl@0
  1112
		case 11:
sl@0
  1113
			aMsg.Complete(KErrNone);
sl@0
  1114
			break;
sl@0
  1115
		case 57:
sl@0
  1116
			User::Leave(KErrNoMemory);
sl@0
  1117
			break;
sl@0
  1118
		case CTestSession4::EShutdown:
sl@0
  1119
			CActiveScheduler::Stop();
sl@0
  1120
			aMsg.Complete(KErrNone);
sl@0
  1121
			break;
sl@0
  1122
		case KMaxTInt:
sl@0
  1123
			//KMaxTInt would otherwise interfere with the OrInFlags value, so
sl@0
  1124
			//we return our location this way instead.
sl@0
  1125
			aMsg.Complete(KMaxTInt);
sl@0
  1126
			break;
sl@0
  1127
		default:
sl@0
  1128
			//If we get here we have an unhandled condition in the test code.
sl@0
  1129
			//The test code is specifically setup to try and catch all branches
sl@0
  1130
			//through the policy server.  If you get, there is some problem in
sl@0
  1131
			//the setup.
sl@0
  1132
			test(0);
sl@0
  1133
			break;
sl@0
  1134
		}
sl@0
  1135
	}
sl@0
  1136
sl@0
  1137
void CTestSession4::ServiceError(const RMessage2& aMsg, TInt aError)
sl@0
  1138
	{
sl@0
  1139
	OrInFlags(aMsg, KServiceErrorMask);
sl@0
  1140
	if(!aMsg.IsNull())
sl@0
  1141
		aMsg.Complete(aError);
sl@0
  1142
	}
sl@0
  1143
sl@0
  1144
CTestPolicyServer4::CTestPolicyServer4(TInt aPriority, const TPolicy& aPolicy)
sl@0
  1145
	: CPolicyServer(aPriority, aPolicy)
sl@0
  1146
	{
sl@0
  1147
	}
sl@0
  1148
sl@0
  1149
CSession2* CTestPolicyServer4::NewSessionL(const TVersion& /*aVersion*/,const RMessage2& /*aMsg*/) const
sl@0
  1150
	{
sl@0
  1151
	return new (ELeave) CTestSession4();
sl@0
  1152
	}
sl@0
  1153
sl@0
  1154
sl@0
  1155
//
sl@0
  1156
// CTestActiveScheduler
sl@0
  1157
//
sl@0
  1158
sl@0
  1159
class CTestActiveScheduler : public CActiveScheduler
sl@0
  1160
	{
sl@0
  1161
public:
sl@0
  1162
	virtual void Error(TInt anError) const;
sl@0
  1163
	};
sl@0
  1164
sl@0
  1165
void CTestActiveScheduler::Error(TInt anError) const
sl@0
  1166
	{
sl@0
  1167
	User::Panic(_L("TestServer Error"),anError);
sl@0
  1168
	}
sl@0
  1169
sl@0
  1170
sl@0
  1171
sl@0
  1172
//
sl@0
  1173
// Server thread
sl@0
  1174
//
sl@0
  1175
sl@0
  1176
_LIT(KServerName,"T_POLSVR-server");
sl@0
  1177
const TInt KServerRendezvous = KRequestPending+1;
sl@0
  1178
sl@0
  1179
void DoStartServer(const CPolicyServer::TPolicy& aPolicy, TUint aServerIndex)
sl@0
  1180
	{
sl@0
  1181
	CTestActiveScheduler* activeScheduler = new (ELeave) CTestActiveScheduler;
sl@0
  1182
	CActiveScheduler::Install(activeScheduler);
sl@0
  1183
	CleanupStack::PushL(activeScheduler);
sl@0
  1184
sl@0
  1185
	CPolicyServer* server = 0;
sl@0
  1186
	switch(aServerIndex)
sl@0
  1187
		{
sl@0
  1188
		case 0:
sl@0
  1189
			server = new (ELeave) CTestPolicyServer1(0,aPolicy);
sl@0
  1190
			break;
sl@0
  1191
		case 1:
sl@0
  1192
			server = new (ELeave) CTestPolicyServer2(0,aPolicy);
sl@0
  1193
			break;
sl@0
  1194
		case 2:
sl@0
  1195
			server = new (ELeave) CTestPolicyServer3(0,aPolicy);
sl@0
  1196
			break;
sl@0
  1197
		case 3:
sl@0
  1198
			server = CTestPolicyServer4::NewL(0,aPolicy);
sl@0
  1199
			break;
sl@0
  1200
		default:
sl@0
  1201
			User::Panic(KPolSvr, KErrArgument);
sl@0
  1202
		}
sl@0
  1203
	CleanupStack::PushL(server);
sl@0
  1204
sl@0
  1205
	User::LeaveIfError(server->Start(KServerName));
sl@0
  1206
sl@0
  1207
	RProcess::Rendezvous(KServerRendezvous);
sl@0
  1208
sl@0
  1209
	CActiveScheduler::Start();
sl@0
  1210
sl@0
  1211
	CleanupStack::PopAndDestroy(2);
sl@0
  1212
	}
sl@0
  1213
sl@0
  1214
TInt StartServer(const CPolicyServer::TPolicy& aPolicy, TUint aServerIndex)
sl@0
  1215
	{
sl@0
  1216
	CTrapCleanup* cleanupStack = CTrapCleanup::New();
sl@0
  1217
	if(!cleanupStack)
sl@0
  1218
		return KErrNoMemory;
sl@0
  1219
	TRAPD(leaveError,DoStartServer(aPolicy,aServerIndex))
sl@0
  1220
	delete cleanupStack;
sl@0
  1221
	return leaveError;
sl@0
  1222
	}
sl@0
  1223
sl@0
  1224
sl@0
  1225
sl@0
  1226
//
sl@0
  1227
// RTestSession
sl@0
  1228
//
sl@0
  1229
sl@0
  1230
class RTestSession : public RSessionBase
sl@0
  1231
	{
sl@0
  1232
public:
sl@0
  1233
	inline TInt Connect()
sl@0
  1234
		{ return CreateSession(KServerName,TVersion());}
sl@0
  1235
//	inline TInt Send(TInt aFunction)
sl@0
  1236
//		{ return RSessionBase::SendReceive(aFunction); }
sl@0
  1237
	inline TInt Send(TInt aFunction,const TIpcArgs& aArgs)
sl@0
  1238
		{ return RSessionBase::SendReceive(aFunction,aArgs); }
sl@0
  1239
	inline void Send(TInt aFunction,TRequestStatus& aStatus)
sl@0
  1240
		{ RSessionBase::SendReceive(aFunction,aStatus); }
sl@0
  1241
	inline void Send(TInt aFunction,const TIpcArgs& aArgs,TRequestStatus& aStatus)
sl@0
  1242
		{ RSessionBase::SendReceive(aFunction,aArgs,aStatus); }
sl@0
  1243
	};
sl@0
  1244
sl@0
  1245
sl@0
  1246
sl@0
  1247
RTestSession Session;
sl@0
  1248
sl@0
  1249
#include <e32svr.h>
sl@0
  1250
sl@0
  1251
void TestServer1WithPolicy1()
sl@0
  1252
	{
sl@0
  1253
	RTestProcess server;
sl@0
  1254
	TRequestStatus rendezvous;
sl@0
  1255
	server.Create(~KTestCapabilities,ETestProcessPolicyServer,EPolicy1,ETestServer1);
sl@0
  1256
	server.Rendezvous(rendezvous);
sl@0
  1257
	server.Resume();
sl@0
  1258
	User::WaitForRequest(rendezvous);
sl@0
  1259
	test(rendezvous==KServerRendezvous);
sl@0
  1260
sl@0
  1261
	test.Next(_L("Server 1, Policy 1"));
sl@0
  1262
	TInt r = Session.Connect();
sl@0
  1263
	test(r==KErrNone);
sl@0
  1264
sl@0
  1265
	TBuf8<4> flags(4);
sl@0
  1266
sl@0
  1267
	//case 0: Not Supported, returned from policy server level.
sl@0
  1268
	SetFlags(flags, 0);
sl@0
  1269
	r = Session.Send(0, TIpcArgs(&flags));
sl@0
  1270
	test(r==KErrNotSupported);
sl@0
  1271
	test(FlagsValue(flags) == (0));
sl@0
  1272
sl@0
  1273
	//case 1: Custom Check, fails with KErrPermissionDenied
sl@0
  1274
	SetFlags(flags, 1);
sl@0
  1275
	r = Session.Send(1, TIpcArgs(&flags));
sl@0
  1276
	test(r==KErrPermissionDenied);
sl@0
  1277
	test(FlagsValue(flags) == (1 | KCustomCheckMask) ); 
sl@0
  1278
sl@0
  1279
	//case 2: Custom Check passes.
sl@0
  1280
	SetFlags(flags, 2);
sl@0
  1281
	r = Session.Send(2, TIpcArgs(&flags));
sl@0
  1282
	test(r==KErrNone);
sl@0
  1283
	test(FlagsValue(flags) == (2 | KCustomCheckMask | KServiceLMask) ); 
sl@0
  1284
sl@0
  1285
	//case 3: Custom Check fails but action set to EQueryUser, query
sl@0
  1286
	//subsequently fails
sl@0
  1287
	SetFlags(flags, 3);
sl@0
  1288
	r = Session.Send(3, TIpcArgs(&flags));
sl@0
  1289
	test(r==KErrPermissionDenied);
sl@0
  1290
	test(FlagsValue(flags) == (3 | KCustomCheckMask | KCustomActionMask ));
sl@0
  1291
sl@0
  1292
	//case 4: Custom Check fails but action set to EQueryUser, query
sl@0
  1293
	//subsequently passes
sl@0
  1294
	SetFlags(flags, 4);
sl@0
  1295
	r = Session.Send(4, TIpcArgs(&flags));
sl@0
  1296
	test(r==KErrNone);
sl@0
  1297
	test(FlagsValue(flags) == (4 | KCustomCheckMask | KCustomActionMask | KServiceLMask ));
sl@0
  1298
	
sl@0
  1299
	//case 5: Custom Check passes and action is set.  Action set shouldn't make
sl@0
  1300
	//a difference.  Should be same result as case 2.
sl@0
  1301
	SetFlags(flags, 5);
sl@0
  1302
	r = Session.Send(5, TIpcArgs(&flags));
sl@0
  1303
	test(r==KErrNone);
sl@0
  1304
	test(FlagsValue(flags) == (5 | KCustomCheckMask | KServiceLMask ));
sl@0
  1305
sl@0
  1306
	//case 6: Always passes at the policy server level.
sl@0
  1307
	SetFlags(flags, 6);
sl@0
  1308
	r = Session.Send(6, TIpcArgs(&flags));
sl@0
  1309
	test(r==KErrNone);
sl@0
  1310
	test(FlagsValue(flags) == (6 | KServiceLMask) );
sl@0
  1311
sl@0
  1312
	//case 7: Not Supported, returned from policy server level.
sl@0
  1313
	SetFlags(flags, 7);
sl@0
  1314
	r = Session.Send(7, TIpcArgs(&flags));
sl@0
  1315
	test(r==KErrNotSupported);
sl@0
  1316
	test(FlagsValue(flags) == (7));
sl@0
  1317
sl@0
  1318
	//case 8: Requires NetworkControl, which we have, so it passes.
sl@0
  1319
	SetFlags(flags, 8);
sl@0
  1320
	r = Session.Send(8, TIpcArgs(&flags));
sl@0
  1321
	test(r==KErrNone);
sl@0
  1322
	test(FlagsValue(flags) == (8 | KServiceLMask));
sl@0
  1323
sl@0
  1324
	//case 9: Requires NetworkControl -> pass.  Thrown in a EQueryUser to see
sl@0
  1325
	//if it causes any problems -> it shouldn't.  Should be same as case 8.
sl@0
  1326
	SetFlags(flags, 9);
sl@0
  1327
	r = Session.Send(9, TIpcArgs(&flags));
sl@0
  1328
	test(r==KErrNone);
sl@0
  1329
	test(FlagsValue(flags) == (9 | KServiceLMask));
sl@0
  1330
sl@0
  1331
	//case 10: Requires DiskAdmin which we don't have.  
sl@0
  1332
	SetFlags(flags, 10);
sl@0
  1333
	r = Session.Send(10, TIpcArgs(&flags));
sl@0
  1334
	test(r==KErrPermissionDenied);
sl@0
  1335
	test(FlagsValue(flags) == (10));
sl@0
  1336
sl@0
  1337
	//case 11: Requires DiskAdmin, which we don't have. EQueryUser is set, and
sl@0
  1338
	//it fails.
sl@0
  1339
	SetFlags(flags, 11);
sl@0
  1340
	r = Session.Send(11, TIpcArgs(&flags));
sl@0
  1341
	test(r==KErrPermissionDenied);
sl@0
  1342
	test(FlagsValue(flags) == (11 | KCustomActionMask));
sl@0
  1343
sl@0
  1344
	//case 12: Requires DiskAdmin, which we don't have. EQueryUser is set, and
sl@0
  1345
	//it passes.
sl@0
  1346
	SetFlags(flags, 12);
sl@0
  1347
	r = Session.Send(12, TIpcArgs(&flags));
sl@0
  1348
	test(r==KErrNone);
sl@0
  1349
	test(FlagsValue(flags) == (12 | KCustomActionMask | KServiceLMask));
sl@0
  1350
sl@0
  1351
	//case 13: Not Supported, returned from policy server level.
sl@0
  1352
	SetFlags(flags, 13);
sl@0
  1353
	r = Session.Send(13, TIpcArgs(&flags));
sl@0
  1354
	test(r==KErrNotSupported);
sl@0
  1355
	test(FlagsValue(flags) == (13));
sl@0
  1356
sl@0
  1357
	//case 14: Not Supported, returned from policy server level.
sl@0
  1358
	SetFlags(flags, 14);
sl@0
  1359
	r = Session.Send(14, TIpcArgs(&flags));
sl@0
  1360
	test(r==KErrNotSupported);
sl@0
  1361
	test(FlagsValue(flags) == (14));
sl@0
  1362
sl@0
  1363
	//case 55: Not Supported, returned from policy server level.
sl@0
  1364
	SetFlags(flags, 55);
sl@0
  1365
	r = Session.Send(55, TIpcArgs(&flags));
sl@0
  1366
	test(r==KErrNotSupported);
sl@0
  1367
	test(FlagsValue(flags) == (55));
sl@0
  1368
sl@0
  1369
	//case 86: Not Supported, returned from policy server level.
sl@0
  1370
	SetFlags(flags, 86);
sl@0
  1371
	r = Session.Send(86, TIpcArgs(&flags));
sl@0
  1372
	test(r==KErrNotSupported);
sl@0
  1373
	test(FlagsValue(flags) == (86));
sl@0
  1374
sl@0
  1375
	//case 99: Not Supported, returned from policy server level.
sl@0
  1376
	SetFlags(flags, 99);
sl@0
  1377
	r = Session.Send(99, TIpcArgs(&flags));
sl@0
  1378
	test(r==KErrNotSupported);
sl@0
  1379
	test(FlagsValue(flags) == (99));
sl@0
  1380
sl@0
  1381
	//case 101: Not Supported, returned from policy server level.
sl@0
  1382
	SetFlags(flags, 101);
sl@0
  1383
	r = Session.Send(101, TIpcArgs(&flags));
sl@0
  1384
	test(r==KErrNotSupported);
sl@0
  1385
	test(FlagsValue(flags) == (101));
sl@0
  1386
sl@0
  1387
	//case 1000191: Not Supported, returned from policy server level.
sl@0
  1388
	SetFlags(flags, 1000191);
sl@0
  1389
	r = Session.Send(1000191, TIpcArgs(&flags));
sl@0
  1390
	test(r==KErrNotSupported);
sl@0
  1391
	test(FlagsValue(flags) == (1000191));
sl@0
  1392
sl@0
  1393
	//case 1000848: Not Supported, returned from policy server level.
sl@0
  1394
	SetFlags(flags, 1000848);
sl@0
  1395
	r = Session.Send(1000848, TIpcArgs(&flags));
sl@0
  1396
	test(r==KErrNotSupported);
sl@0
  1397
	test(FlagsValue(flags) == (1000848));
sl@0
  1398
sl@0
  1399
	//case KMaxTInt-1: Not Supported, returned from policy server level.
sl@0
  1400
	SetFlags(flags, KMaxTInt-1);
sl@0
  1401
	r = Session.Send(KMaxTInt-1, TIpcArgs(&flags));
sl@0
  1402
	test(r==KErrNotSupported);
sl@0
  1403
	test(FlagsValue(flags) == (KMaxTInt-1));
sl@0
  1404
sl@0
  1405
	//case KMaxTInt: Not Supported, returned from policy server level.
sl@0
  1406
	SetFlags(flags, KMaxTInt);
sl@0
  1407
	r = Session.Send(KMaxTInt, TIpcArgs(&flags));
sl@0
  1408
	test(r==KErrNotSupported);
sl@0
  1409
	test(FlagsValue(flags) == (TUint)(KMaxTInt));
sl@0
  1410
sl@0
  1411
	r = Session.Send(CTestSession1::EShutdown, TIpcArgs(&flags));
sl@0
  1412
	test.Printf(_L("r = %d\n"),r);
sl@0
  1413
	test(r==KErrNone);
sl@0
  1414
sl@0
  1415
	Session.Close();
sl@0
  1416
	CLOSE_AND_WAIT(server);
sl@0
  1417
	}
sl@0
  1418
sl@0
  1419
#include <e32panic.h>
sl@0
  1420
sl@0
  1421
void TestServer1WithPolicy2()
sl@0
  1422
	{
sl@0
  1423
	test.Next(_L("Server 1, Policy 2"));
sl@0
  1424
	RTestProcess server;
sl@0
  1425
	TRequestStatus rendezvous;
sl@0
  1426
	server.Create(~KTestCapabilities,ETestProcessPolicyServer,EPolicy2,ETestServer1);
sl@0
  1427
	server.Rendezvous(rendezvous);
sl@0
  1428
	server.Resume();
sl@0
  1429
	User::WaitForRequest(rendezvous);
sl@0
  1430
#ifdef _DEBUG
sl@0
  1431
	//Debug mode does a policy integrity check
sl@0
  1432
	test(rendezvous==EPolSvr1stRangeNotZero);
sl@0
  1433
#else
sl@0
  1434
	test(rendezvous==KServerRendezvous);
sl@0
  1435
	server.Terminate(0);
sl@0
  1436
#endif
sl@0
  1437
	CLOSE_AND_WAIT(server);
sl@0
  1438
	}
sl@0
  1439
sl@0
  1440
void TestServer1WithPolicy3()
sl@0
  1441
	{
sl@0
  1442
	test.Next(_L("Server 1, Policy 3"));
sl@0
  1443
	RTestProcess server;
sl@0
  1444
	TRequestStatus rendezvous;
sl@0
  1445
	server.Create(~KTestCapabilities,ETestProcessPolicyServer,EPolicy3,ETestServer1);
sl@0
  1446
	server.Rendezvous(rendezvous);
sl@0
  1447
	server.Resume();
sl@0
  1448
	User::WaitForRequest(rendezvous);
sl@0
  1449
#ifdef _DEBUG
sl@0
  1450
	//Debug mode does a policy integrity check
sl@0
  1451
	test(rendezvous==EPolSvrRangesNotIncreasing);
sl@0
  1452
#else
sl@0
  1453
	test(rendezvous==KServerRendezvous);
sl@0
  1454
	server.Terminate(0);
sl@0
  1455
#endif
sl@0
  1456
	CLOSE_AND_WAIT(server);
sl@0
  1457
	}
sl@0
  1458
sl@0
  1459
void TestServer1WithPolicy4()
sl@0
  1460
	{
sl@0
  1461
	test.Next(_L("Server 1, Policy 4"));
sl@0
  1462
	RTestProcess server;
sl@0
  1463
	TRequestStatus rendezvous;
sl@0
  1464
	server.Create(~KTestCapabilities,ETestProcessPolicyServer,EPolicy4,ETestServer1);
sl@0
  1465
	server.Rendezvous(rendezvous);
sl@0
  1466
	server.Resume();
sl@0
  1467
	User::WaitForRequest(rendezvous);
sl@0
  1468
#ifdef _DEBUG
sl@0
  1469
	//Debug mode does a policy integrity check
sl@0
  1470
	test(rendezvous==EPolSvrElementsIndexValueInvalid);
sl@0
  1471
#else
sl@0
  1472
	test(rendezvous==KServerRendezvous);
sl@0
  1473
	server.Terminate(0);
sl@0
  1474
#endif
sl@0
  1475
	CLOSE_AND_WAIT(server);
sl@0
  1476
	}
sl@0
  1477
sl@0
  1478
void TestServer1WithPolicy5()
sl@0
  1479
	{
sl@0
  1480
	test.Next(_L("Server 1, Policy 5"));
sl@0
  1481
	RTestProcess server;
sl@0
  1482
	TRequestStatus rendezvous;
sl@0
  1483
	server.Create(~KTestCapabilities,ETestProcessPolicyServer,EPolicy5,ETestServer1);
sl@0
  1484
	server.Rendezvous(rendezvous);
sl@0
  1485
	server.Resume();
sl@0
  1486
	User::WaitForRequest(rendezvous);
sl@0
  1487
#ifdef _DEBUG
sl@0
  1488
	//Debug mode does a policy integrity check
sl@0
  1489
	test(rendezvous==EPolSvrElementsIndexValueInvalid);
sl@0
  1490
#else
sl@0
  1491
	test(rendezvous==KServerRendezvous);
sl@0
  1492
	server.Terminate(0);
sl@0
  1493
#endif
sl@0
  1494
	CLOSE_AND_WAIT(server);
sl@0
  1495
	}
sl@0
  1496
sl@0
  1497
void TestServer1WithPolicy6()
sl@0
  1498
	{
sl@0
  1499
	test.Next(_L("Server 1, Policy 6"));
sl@0
  1500
	RTestProcess server;
sl@0
  1501
	TRequestStatus rendezvous;
sl@0
  1502
	server.Create(~KTestCapabilities,ETestProcessPolicyServer,EPolicy6,ETestServer1);
sl@0
  1503
	server.Rendezvous(rendezvous);
sl@0
  1504
	server.Resume();
sl@0
  1505
	User::WaitForRequest(rendezvous);
sl@0
  1506
#ifdef _DEBUG
sl@0
  1507
	//Debug mode does a policy integrity check
sl@0
  1508
	test(rendezvous==EPolSvrIOnConnectValueInvalid);
sl@0
  1509
#else
sl@0
  1510
	test(rendezvous==KServerRendezvous);
sl@0
  1511
	server.Terminate(0);
sl@0
  1512
#endif
sl@0
  1513
	CLOSE_AND_WAIT(server);
sl@0
  1514
	}
sl@0
  1515
sl@0
  1516
void TestServer1WithPolicy7()
sl@0
  1517
	{
sl@0
  1518
	test.Next(_L("Server 1, Policy 7"));
sl@0
  1519
	RTestProcess server;
sl@0
  1520
	TRequestStatus rendezvous;
sl@0
  1521
	server.Create(~KTestCapabilities,ETestProcessPolicyServer,EPolicy7,ETestServer1);
sl@0
  1522
	server.Rendezvous(rendezvous);
sl@0
  1523
	server.Resume();
sl@0
  1524
	User::WaitForRequest(rendezvous);
sl@0
  1525
	test(rendezvous==KServerRendezvous);
sl@0
  1526
sl@0
  1527
	TInt r = Session.Connect();
sl@0
  1528
	test(r==KErrNotSupported);
sl@0
  1529
sl@0
  1530
	//We can do this because we have power management
sl@0
  1531
	server.Terminate(KErrGeneral);
sl@0
  1532
	CLOSE_AND_WAIT(server);
sl@0
  1533
	}
sl@0
  1534
sl@0
  1535
void TestServer1WithPolicy8()
sl@0
  1536
	{
sl@0
  1537
	test.Next(_L("Server 1, Policy 8"));
sl@0
  1538
	RTestProcess server;
sl@0
  1539
	TRequestStatus rendezvous;
sl@0
  1540
	server.Create(~KTestCapabilities,ETestProcessPolicyServer,EPolicy8,ETestServer1);
sl@0
  1541
	server.Rendezvous(rendezvous);
sl@0
  1542
	server.Resume();
sl@0
  1543
	User::WaitForRequest(rendezvous);
sl@0
  1544
	test(rendezvous==KServerRendezvous);
sl@0
  1545
sl@0
  1546
	//This will be calling through CustomSecurityCheckL (server1 will return
sl@0
  1547
	//pass), but there is no easy way to determine that it has followed the
sl@0
  1548
	//correct path.
sl@0
  1549
	TInt r = Session.Connect();
sl@0
  1550
	test(r==KErrNone);
sl@0
  1551
sl@0
  1552
	server.Terminate(KErrGeneral);
sl@0
  1553
	Session.Close();
sl@0
  1554
	CLOSE_AND_WAIT(server);
sl@0
  1555
	}
sl@0
  1556
sl@0
  1557
void TestServer2WithPolicy8()
sl@0
  1558
	{
sl@0
  1559
	test.Next(_L("Server 2, Policy 8"));
sl@0
  1560
	RTestProcess server;
sl@0
  1561
	TRequestStatus rendezvous;
sl@0
  1562
	TRequestStatus logon;
sl@0
  1563
	server.Create(~KTestCapabilities,ETestProcessPolicyServer,EPolicy8,ETestServer2);
sl@0
  1564
	server.Rendezvous(rendezvous);
sl@0
  1565
	server.Logon(logon);
sl@0
  1566
	server.Resume();
sl@0
  1567
	User::WaitForRequest(rendezvous);
sl@0
  1568
	test(rendezvous==KServerRendezvous);
sl@0
  1569
sl@0
  1570
	TInt r = Session.Connect();
sl@0
  1571
	test(r==KErrServerTerminated);
sl@0
  1572
sl@0
  1573
	//This is a simple way of testing that CustomSecurityCheckL is called for a
sl@0
  1574
	//connect custom check.  Server2 doesn't have an implementation of CustomSecurityCheckL
sl@0
  1575
	User::WaitForRequest(logon);
sl@0
  1576
	test(logon == EPolSvrCallingBaseImplementation);
sl@0
  1577
sl@0
  1578
	Session.Close();
sl@0
  1579
	CLOSE_AND_WAIT(server);
sl@0
  1580
	}
sl@0
  1581
sl@0
  1582
void TestServer3WithPolicy8()
sl@0
  1583
	{
sl@0
  1584
	test.Next(_L("Server 3, Policy 8"));
sl@0
  1585
	RTestProcess server;
sl@0
  1586
	TRequestStatus rendezvous;
sl@0
  1587
	server.Create(~KTestCapabilities,ETestProcessPolicyServer,EPolicy8,ETestServer1);
sl@0
  1588
	server.Rendezvous(rendezvous);
sl@0
  1589
	server.Resume();
sl@0
  1590
	User::WaitForRequest(rendezvous);
sl@0
  1591
	test(rendezvous==KServerRendezvous);
sl@0
  1592
sl@0
  1593
	//This will be calling through CustomSecurityCheckL
sl@0
  1594
	//(server3::CustomSecurityCheckL will fail this, but set the action to
sl@0
  1595
	//EQueryUser, which will call CustomFailureActionL which should will in
sl@0
  1596
	//this case pass) but there is no easy way to determine that it has
sl@0
  1597
	//followed the correct path.
sl@0
  1598
	TInt r = Session.Connect();
sl@0
  1599
	test(r==KErrNone);
sl@0
  1600
sl@0
  1601
	//This policy doesn't have any IPC's that work.  Only way to shutdown
sl@0
  1602
	//server is to kill it.
sl@0
  1603
	server.Terminate(KErrGeneral);
sl@0
  1604
	Session.Close();
sl@0
  1605
	CLOSE_AND_WAIT(server);
sl@0
  1606
	}
sl@0
  1607
sl@0
  1608
sl@0
  1609
void TestServer1WithPolicy9()
sl@0
  1610
	{
sl@0
  1611
	test.Next(_L("Server 1, Policy 9"));
sl@0
  1612
	RTestProcess server;
sl@0
  1613
	TRequestStatus rendezvous;
sl@0
  1614
	server.Create(~KTestCapabilities,ETestProcessPolicyServer,EPolicy9,ETestServer1);
sl@0
  1615
	server.Rendezvous(rendezvous);
sl@0
  1616
	server.Resume();
sl@0
  1617
	User::WaitForRequest(rendezvous);
sl@0
  1618
	test(rendezvous==KServerRendezvous);
sl@0
  1619
sl@0
  1620
	TInt r = Session.Connect();
sl@0
  1621
	test(r==KErrPermissionDenied);
sl@0
  1622
sl@0
  1623
	//We can do this because we have power management
sl@0
  1624
	server.Terminate(KErrGeneral);
sl@0
  1625
	CLOSE_AND_WAIT(server);
sl@0
  1626
	}
sl@0
  1627
sl@0
  1628
void TestServer2WithPolicy1()
sl@0
  1629
	{	
sl@0
  1630
	test.Next(_L("Server 2, Policy 1"));
sl@0
  1631
	RTestProcess server;
sl@0
  1632
	TRequestStatus rendezvous;
sl@0
  1633
	server.Create(~KTestCapabilities,ETestProcessPolicyServer,EPolicy1,ETestServer2);
sl@0
  1634
	server.Rendezvous(rendezvous);
sl@0
  1635
	server.Resume();
sl@0
  1636
	User::WaitForRequest(rendezvous);
sl@0
  1637
	test(rendezvous==KServerRendezvous);
sl@0
  1638
sl@0
  1639
	TInt r = Session.Connect();
sl@0
  1640
	test(r==KErrNone);
sl@0
  1641
sl@0
  1642
	TBuf8<4> flags(4);
sl@0
  1643
	r = Session.Send(CTestSession2::EShutdown, TIpcArgs(&flags));
sl@0
  1644
	test(r == KErrNone);
sl@0
  1645
	Session.Close();
sl@0
  1646
	CLOSE_AND_WAIT(server);
sl@0
  1647
	}
sl@0
  1648
sl@0
  1649
void TestServer4WithPolicy10()
sl@0
  1650
	{	
sl@0
  1651
	test.Next(_L("Server 4, Policy 10"));
sl@0
  1652
	RTestProcess server;
sl@0
  1653
	TRequestStatus rendezvous;
sl@0
  1654
	server.Create(~KTestCapabilities,ETestProcessPolicyServer,EPolicy10,ETestServer4);
sl@0
  1655
	server.Rendezvous(rendezvous);
sl@0
  1656
	server.Resume();
sl@0
  1657
	User::WaitForRequest(rendezvous);
sl@0
  1658
	test(rendezvous==KServerRendezvous);
sl@0
  1659
sl@0
  1660
	TInt r = Session.Connect();
sl@0
  1661
	test(r==KErrNone);
sl@0
  1662
sl@0
  1663
	TBuf8<4> flags(4);
sl@0
  1664
sl@0
  1665
	//case 0: Custom Check, fails with KErrPermissionDenied
sl@0
  1666
	SetFlags(flags, 0);
sl@0
  1667
	r = Session.Send(0, TIpcArgs(&flags));
sl@0
  1668
	test(r==KErrPermissionDenied);
sl@0
  1669
	test(FlagsValue(flags) == (0 | KCustomCheckMask | KActiveCheckMask | KActiveRunLMask) ); 
sl@0
  1670
sl@0
  1671
	//case 1: Custom Check passes.
sl@0
  1672
	SetFlags(flags, 1);
sl@0
  1673
	r = Session.Send(1, TIpcArgs(&flags));
sl@0
  1674
	test(r==KErrNone);
sl@0
  1675
	test(FlagsValue(flags) == (1 | KCustomCheckMask | KActiveCheckMask | KActiveRunLMask | KServiceLMask) ); 
sl@0
  1676
sl@0
  1677
	//case 2: Custom Check fails but action set to EQueryUser, query
sl@0
  1678
	//subsequently fails
sl@0
  1679
	SetFlags(flags, 2);
sl@0
  1680
	r = Session.Send(2, TIpcArgs(&flags));
sl@0
  1681
	test(r==KErrPermissionDenied);
sl@0
  1682
	test(FlagsValue(flags) == (2 | KCustomCheckMask | KActiveCheckMask | KActiveRunLMask | KCustomActionMask | KActiveActionMask ));
sl@0
  1683
sl@0
  1684
	//case 3: Custom Check fails but action set to EQueryUser, query
sl@0
  1685
	//subsequently passes
sl@0
  1686
	SetFlags(flags, 3);
sl@0
  1687
	r = Session.Send(3, TIpcArgs(&flags));
sl@0
  1688
	test(r==KErrNone);
sl@0
  1689
	test(FlagsValue(flags) == (3 | KCustomCheckMask | KActiveCheckMask | KActiveRunLMask | KCustomActionMask | KActiveActionMask | KServiceLMask ));
sl@0
  1690
	
sl@0
  1691
	//case 4: Custom Check passes and action is set.  Action set shouldn't make
sl@0
  1692
	//a difference.  Should be same result as case 1.
sl@0
  1693
	SetFlags(flags, 4);
sl@0
  1694
	r = Session.Send(4, TIpcArgs(&flags));
sl@0
  1695
	test(r==KErrNone);
sl@0
  1696
	test(FlagsValue(flags) == (4 | KCustomCheckMask | KActiveCheckMask | KActiveRunLMask | KServiceLMask) );
sl@0
  1697
sl@0
  1698
	//case 5: Always passes at the policy server level.
sl@0
  1699
	SetFlags(flags, 5);
sl@0
  1700
	r = Session.Send(5, TIpcArgs(&flags));
sl@0
  1701
	test(r==KErrNone);
sl@0
  1702
	test(FlagsValue(flags) == (5 | KServiceLMask) );
sl@0
  1703
sl@0
  1704
	//case 6: Not Supported, returned from policy server level.
sl@0
  1705
	SetFlags(flags, 6);
sl@0
  1706
	r = Session.Send(6, TIpcArgs(&flags));
sl@0
  1707
	test(r==KErrNotSupported);
sl@0
  1708
	test(FlagsValue(flags) == (6));
sl@0
  1709
sl@0
  1710
	//case 7: Not Supported, returned from policy server level.
sl@0
  1711
	SetFlags(flags, 7);
sl@0
  1712
	r = Session.Send(7, TIpcArgs(&flags));
sl@0
  1713
	test(r==KErrNotSupported);
sl@0
  1714
	test(FlagsValue(flags) == (7));
sl@0
  1715
sl@0
  1716
	//case 8: Requires NetworkControl, which we have, so it passes.
sl@0
  1717
	SetFlags(flags, 8);
sl@0
  1718
	r = Session.Send(8, TIpcArgs(&flags));
sl@0
  1719
	test(r==KErrNone);
sl@0
  1720
	test(FlagsValue(flags) == (8 | KServiceLMask));
sl@0
  1721
sl@0
  1722
	//case 9: Requires DiskAdmin, which we don't have. EQueryUser is set, and
sl@0
  1723
	//it passes.
sl@0
  1724
	SetFlags(flags, 9);
sl@0
  1725
	r = Session.Send(9, TIpcArgs(&flags));
sl@0
  1726
	test(r==KErrNone);
sl@0
  1727
	test(FlagsValue(flags) == (9 | KCustomActionMask | KActiveActionMask | KActiveRunLMask | KServiceLMask));
sl@0
  1728
sl@0
  1729
	//case 10: Requires DiskAdmin which we don't have.  
sl@0
  1730
	SetFlags(flags, 10);
sl@0
  1731
	r = Session.Send(10, TIpcArgs(&flags));
sl@0
  1732
	test(r==KErrPermissionDenied);
sl@0
  1733
	test(FlagsValue(flags) == (10));
sl@0
  1734
sl@0
  1735
	//case 11: Requires NetworkControl -> pass.  Thrown in a EQueryUser to see
sl@0
  1736
	//if it causes any problems -> it shouldn't.  Should be same as case 8.
sl@0
  1737
	SetFlags(flags, 11);
sl@0
  1738
	r = Session.Send(11, TIpcArgs(&flags));
sl@0
  1739
	test(r==KErrNone);
sl@0
  1740
	test(FlagsValue(flags) == (11 | KServiceLMask));
sl@0
  1741
sl@0
  1742
	//case 12: Not Supported, returned from policy server level.
sl@0
  1743
	SetFlags(flags, 12);
sl@0
  1744
	r = Session.Send(12, TIpcArgs(&flags));
sl@0
  1745
	test(r==KErrNotSupported);
sl@0
  1746
	test(FlagsValue(flags) == (12));
sl@0
  1747
sl@0
  1748
	//case 13: Not Supported, returned from policy server level.
sl@0
  1749
	SetFlags(flags, 13);
sl@0
  1750
	r = Session.Send(13, TIpcArgs(&flags));
sl@0
  1751
	test(r==KErrNotSupported);
sl@0
  1752
	test(FlagsValue(flags) == (13));
sl@0
  1753
sl@0
  1754
	//case 54: Not Supported, returned from policy server level.
sl@0
  1755
	SetFlags(flags, 54);
sl@0
  1756
	r = Session.Send(54, TIpcArgs(&flags));
sl@0
  1757
	test(r==KErrNotSupported);
sl@0
  1758
	test(FlagsValue(flags) == (54));
sl@0
  1759
sl@0
  1760
	//case 55: Requires DiskAdmin -> Fail.  But then we query user, and then we
sl@0
  1761
	//cancel that.
sl@0
  1762
	SetFlags(flags, 55);
sl@0
  1763
	r = Session.Send(55, TIpcArgs(&flags));
sl@0
  1764
	test(r==KErrCancel);
sl@0
  1765
	test(FlagsValue(flags) == (55 | KCustomActionMask | KActiveActionMask | KActiveDoCancelMask));
sl@0
  1766
sl@0
  1767
	//case 56: Requires DiskAdmin -> Fail.  But then we query user which leaves.
sl@0
  1768
	SetFlags(flags, 56);
sl@0
  1769
	r = Session.Send(56, TIpcArgs(&flags));
sl@0
  1770
	test(r==KErrNoMemory);
sl@0
  1771
	test(FlagsValue(flags) == (56 | KCustomActionMask | KActiveActionMask | KActiveRunLMask | KActiveRunErrorMask));
sl@0
  1772
sl@0
  1773
	//case 57: Requires DiskAdmin -> Fail.  But then we query user which passes
sl@0
  1774
	//and then we leave in the ServiceL
sl@0
  1775
	SetFlags(flags, 57);
sl@0
  1776
	r = Session.Send(57, TIpcArgs(&flags));
sl@0
  1777
	test(r==KErrNoMemory);
sl@0
  1778
	test(FlagsValue(flags) == (57 | KCustomActionMask | KActiveActionMask | KActiveRunLMask | KServiceLMask | KActiveRunErrorMask | KServiceErrorMask ));
sl@0
  1779
sl@0
  1780
	//case 58: Not Supported, returned from policy server level.
sl@0
  1781
	SetFlags(flags, 58);
sl@0
  1782
	r = Session.Send(58, TIpcArgs(&flags));
sl@0
  1783
	test(r==KErrNotSupported);
sl@0
  1784
	test(FlagsValue(flags) == (58));
sl@0
  1785
sl@0
  1786
	//case 86: Not Supported, returned from policy server level.
sl@0
  1787
	SetFlags(flags, 86);
sl@0
  1788
	r = Session.Send(86, TIpcArgs(&flags));
sl@0
  1789
	test(r==KErrNotSupported);
sl@0
  1790
	test(FlagsValue(flags) == (86));
sl@0
  1791
sl@0
  1792
	//case 99: Not Supported, returned from policy server level.
sl@0
  1793
	SetFlags(flags, 99);
sl@0
  1794
	r = Session.Send(99, TIpcArgs(&flags));
sl@0
  1795
	test(r==KErrNotSupported);
sl@0
  1796
	test(FlagsValue(flags) == (99));
sl@0
  1797
sl@0
  1798
	//case 101: Not Supported, returned from policy server level.
sl@0
  1799
	SetFlags(flags, 101);
sl@0
  1800
	r = Session.Send(101, TIpcArgs(&flags));
sl@0
  1801
	test(r==KErrNotSupported);
sl@0
  1802
	test(FlagsValue(flags) == (101));
sl@0
  1803
sl@0
  1804
	//case 5000: Not Supported, returned from policy server level.
sl@0
  1805
	SetFlags(flags, 5000);
sl@0
  1806
	r = Session.Send(5000, TIpcArgs(&flags));
sl@0
  1807
	test(r==KErrNotSupported);
sl@0
  1808
	test(FlagsValue(flags) == (5000));
sl@0
  1809
sl@0
  1810
	//case KMaxTInt-1: Not Supported, returned from policy server level.
sl@0
  1811
	SetFlags(flags, KMaxTInt-1);
sl@0
  1812
	r = Session.Send(KMaxTInt-1, TIpcArgs(&flags));
sl@0
  1813
	test(r==KErrNotSupported);
sl@0
  1814
	test(FlagsValue(flags) == (KMaxTInt-1));
sl@0
  1815
sl@0
  1816
	//case KMaxTInt: Always pass from policy framework
sl@0
  1817
	//This also tests another exit condition from the binary search
sl@0
  1818
	SetFlags(flags, 0);
sl@0
  1819
	r = Session.Send(KMaxTInt, TIpcArgs(&flags));
sl@0
  1820
	//Instead of KErrNone we return KMaxTInt as we can't fit the KMaxTInt in
sl@0
  1821
	//the flags without overwriting stuff
sl@0
  1822
	test(r==KMaxTInt);
sl@0
  1823
	test(FlagsValue(flags) == (0 | KServiceLMask ));
sl@0
  1824
sl@0
  1825
	r = Session.Send(CTestSession2::EShutdown, TIpcArgs(&flags));
sl@0
  1826
	test(r == KErrNone);
sl@0
  1827
	Session.Close();
sl@0
  1828
	CLOSE_AND_WAIT(server);
sl@0
  1829
	}
sl@0
  1830
sl@0
  1831
GLDEF_C TInt E32Main()
sl@0
  1832
    {
sl@0
  1833
	TBuf16<512> cmd;
sl@0
  1834
	User::CommandLine(cmd);
sl@0
  1835
	if(cmd.Length() && TChar(cmd[0]).IsDigit())
sl@0
  1836
		{
sl@0
  1837
		TInt function = -1;
sl@0
  1838
		TInt arg1 = -1;
sl@0
  1839
		TInt arg2 = -1;
sl@0
  1840
		TLex lex(cmd);
sl@0
  1841
sl@0
  1842
		lex.Val(function);
sl@0
  1843
		lex.SkipSpace();
sl@0
  1844
		lex.Val(arg1);
sl@0
  1845
		lex.SkipSpace();
sl@0
  1846
		lex.Val(arg2);
sl@0
  1847
		return DoTestProcess(function,arg1,arg2);
sl@0
  1848
		}
sl@0
  1849
sl@0
  1850
	test.Title();
sl@0
  1851
sl@0
  1852
	if(!PlatSec::ConfigSetting(PlatSec::EPlatSecEnforcement))
sl@0
  1853
		{
sl@0
  1854
		test.Start(_L("TESTS NOT RUN - EPlatSecEnforcement is OFF"));
sl@0
  1855
		test.End();
sl@0
  1856
		return 0;
sl@0
  1857
		}
sl@0
  1858
sl@0
  1859
	test.Start(_L("Policy Server Tests"));
sl@0
  1860
sl@0
  1861
	/* Server1 has implementations of CustomSecurityCheckL and
sl@0
  1862
	CustomFailureActionL This is the test for all the paths in a policy servers
sl@0
  1863
	implementations -- not all connect paths though
sl@0
  1864
	This test also ensures that every path through the binary search is
sl@0
  1865
	covered. */
sl@0
  1866
	TestServer1WithPolicy1();
sl@0
  1867
sl@0
  1868
	/* Policy2,3,4,5,6, are bad policies that should cause the server to panic
sl@0
  1869
	in debug mode.  In release, they'll just pass, however, if you later tried
sl@0
  1870
	to use them, something would go horribly wrong */
sl@0
  1871
	TestServer1WithPolicy2();
sl@0
  1872
	TestServer1WithPolicy3();
sl@0
  1873
	TestServer1WithPolicy4();
sl@0
  1874
	TestServer1WithPolicy5();
sl@0
  1875
	TestServer1WithPolicy6();
sl@0
  1876
sl@0
  1877
	/* Policies 7,8,9 check various types of connect policies. */
sl@0
  1878
	TestServer1WithPolicy7();
sl@0
  1879
	// Server 1,2,3 are used here all with policy 8 because you can only test 1
sl@0
  1880
	// type of connect policy per server.
sl@0
  1881
	TestServer1WithPolicy8();
sl@0
  1882
	TestServer2WithPolicy8();
sl@0
  1883
	TestServer3WithPolicy8();
sl@0
  1884
	TestServer1WithPolicy9();
sl@0
  1885
sl@0
  1886
	/* Sever2 does not have implementations of CustomSecurityCheckL and
sl@0
  1887
	CustomFailureActionL. When these functions are called it should crash */
sl@0
  1888
	TestServer2WithPolicy1();
sl@0
  1889
sl@0
  1890
	/* Server4 is used for checking what happens when the custom functions use
sl@0
  1891
	another active object.  This test encompasses leaving due to OOM, and
sl@0
  1892
	cancellation. */
sl@0
  1893
	TestServer4WithPolicy10();
sl@0
  1894
sl@0
  1895
	test.End();
sl@0
  1896
	return(0);
sl@0
  1897
    }
sl@0
  1898