os/security/authorisation/userpromptservice/server/test/upstest/upstest.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/authorisation/userpromptservice/server/test/upstest/upstest.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,607 @@
     1.4 +/*
     1.5 +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +* Test program exercises the skeleton UPS server API.
    1.19 +* See individual test functions for more information.
    1.20 +*
    1.21 +*/
    1.22 +
    1.23 +
    1.24 +/**
    1.25 + @file
    1.26 +*/
    1.27 +
    1.28 +#include <e32ldr.h>
    1.29 +#include <e32ldr_private.h>
    1.30 +#include "rtestwrapper.h"
    1.31 +
    1.32 +#include <ups/upsclient.h>
    1.33 +#include <ups/upserr.h>
    1.34 +#include "f32file.h"
    1.35 +
    1.36 +using namespace UserPromptService;
    1.37 +
    1.38 +/** Top-level test object renders stages and confirms conditions. */
    1.39 +static RTestWrapper test(_L("UPSTEST"));
    1.40 +
    1.41 +/**
    1.42 +	This session handle is defined at the file level so each individual test
    1.43 +	does not have to connect to the server.
    1.44 + */
    1.45 +static RUpsSession sTestSession;
    1.46 +/**
    1.47 +	This subsession handle is defined at the file level so each individual test
    1.48 +	does not have to connect to the server and create a subssesion.
    1.49 + */
    1.50 +static RUpsSubsession sTestSubsession;
    1.51 +
    1.52 +// -------- open / close session --------
    1.53 +
    1.54 +static void TestOpenCloseSession()
    1.55 +/**
    1.56 +	Open and close a connection to the UPS server.
    1.57 + */
    1.58 +	{
    1.59 +	test.Start(_L("TestOpenCloseSession"));
    1.60 +	
    1.61 +	RUpsSession s;
    1.62 +	TInt r = s.Connect();
    1.63 +	test(r == KErrNone);
    1.64 +
    1.65 +	r = s.ShareAuto();
    1.66 +	test(r == KErrNone);
    1.67 +	
    1.68 +	s.Close();
    1.69 +	
    1.70 +	test.End();
    1.71 +	}
    1.72 +
    1.73 +// -------- open / close subsession --------
    1.74 +
    1.75 +static void TestOpenCloseSubsession()
    1.76 +/**
    1.77 +	Open and close a subsession on the UPS server.
    1.78 + */
    1.79 +	{
    1.80 +	test.Start(_L("TestOpenCloseSubsession"));
    1.81 +	
    1.82 +	RUpsSubsession ss;
    1.83 +	RThread thd;
    1.84 +	TInt r = ss.Initialise(sTestSession, thd);
    1.85 +	test(r == KErrNone);
    1.86 +	ss.Close();
    1.87 +	
    1.88 +	test.End();
    1.89 +	}
    1.90 +
    1.91 +// -------- Authorise succeed, cancel --------
    1.92 +_LIT8(KOpaqueData, "<ce>fred</ce>");
    1.93 +static void TestAuthoriseL()
    1.94 +/**
    1.95 +	Launch an asynchronous Authorise request on a UPS subsession.
    1.96 +	Let it complete normally, and also cancel it.
    1.97 + */
    1.98 +	{
    1.99 +	test.Start(_L("TestAuthorise"));
   1.100 +	
   1.101 +	TServiceId serviceId = {43};
   1.102 +	TRequestStatus rs;
   1.103 +
   1.104 +	
   1.105 +	test.Next(_L("complete normally - no opaque data\n"));
   1.106 +	TUpsDecision dec = EUpsDecYes;
   1.107 +	sTestSubsession.Authorise(EFalse, serviceId, KNullDesC, dec, rs);
   1.108 +	test(dec == EUpsDecYes);	// not changed yet
   1.109 +	User::WaitForRequest(rs);
   1.110 +	test(rs == KErrNone);
   1.111 +	test(dec == EUpsDecNo);
   1.112 +	
   1.113 +	test.Next(_L("cancel - empty opaque data\n"));
   1.114 +	dec = EUpsDecYes;	// ensure changed
   1.115 +	sTestSubsession.Authorise(EFalse, serviceId, KNullDesC, KNullDesC8, dec, rs);
   1.116 +	test(dec == EUpsDecYes);	// not changed yet
   1.117 +	test.Printf(_L("About to cancel - current status is %d"), rs.Int());
   1.118 +	sTestSubsession.CancelPrompt();
   1.119 +	User::WaitForRequest(rs);
   1.120 +	test(rs == KErrCancel);
   1.121 +	test(dec == EUpsDecYes);	// not changed
   1.122 +
   1.123 +	test.Next(_L("Opaque data\n"));
   1.124 +	dec = EUpsDecYes;	// ensure changed
   1.125 +	sTestSubsession.Authorise(EFalse, serviceId, _L("opaque data test"), KOpaqueData, dec, rs);
   1.126 +	test(dec == EUpsDecYes);	// not changed yet
   1.127 +	User::WaitForRequest(rs);
   1.128 +	test(rs == KErrNone);
   1.129 +	test(dec == EUpsDecNo);
   1.130 +
   1.131 +	
   1.132 +	test.Next(_L("cancel when no outstanding - harmless\n"));
   1.133 +	sTestSubsession.CancelPrompt();
   1.134 +
   1.135 +	test.Next(_L("cancel/close when sub session never created - harmless\n"));
   1.136 +	RUpsSubsession uninitialisedCancel;
   1.137 +	uninitialisedCancel.CancelPrompt();
   1.138 +	uninitialisedCancel.Close();
   1.139 +	
   1.140 +	test.End();
   1.141 +	}
   1.142 +
   1.143 +static void TestFlurryL()
   1.144 +/**
   1.145 +	Launch multiple requests
   1.146 + */
   1.147 +	{
   1.148 +	test.Start(_L("TestFlurry"));
   1.149 +
   1.150 +	RThread thd;
   1.151 +	RUpsSubsession testSubsession1;
   1.152 +	testSubsession1.Initialise(sTestSession, thd);
   1.153 +	RUpsSubsession testSubsession2;
   1.154 +	testSubsession2.Initialise(sTestSession, thd);
   1.155 +	RUpsSubsession testSubsession3;
   1.156 +	testSubsession3.Initialise(sTestSession, thd);
   1.157 +	RUpsSubsession testSubsession4;
   1.158 +	testSubsession4.Initialise(sTestSession, thd);
   1.159 +	RUpsSubsession testSubsession5;
   1.160 +	testSubsession5.Initialise(sTestSession, thd);
   1.161 +	RUpsSubsession testSubsession6;
   1.162 +	testSubsession6.Initialise(sTestSession, thd);
   1.163 +	
   1.164 +	TServiceId serviceId = {43};
   1.165 +	TRequestStatus rs1;
   1.166 +	TRequestStatus rs2;
   1.167 +	TRequestStatus rs3;
   1.168 +	TRequestStatus rs4;
   1.169 +	TRequestStatus rs5;
   1.170 +	TRequestStatus rs6;
   1.171 +	
   1.172 +	// complete normally - no opaque data
   1.173 +	TUpsDecision dec1 = EUpsDecYes;
   1.174 +	TUpsDecision dec2 = EUpsDecYes;
   1.175 +	TUpsDecision dec3 = EUpsDecYes;
   1.176 +	TUpsDecision dec4 = EUpsDecYes;
   1.177 +	TUpsDecision dec5 = EUpsDecYes;
   1.178 +	TUpsDecision dec6 = EUpsDecYes;
   1.179 +	testSubsession1.Authorise(EFalse, serviceId, _L("req1"), dec1, rs1);
   1.180 +	testSubsession2.Authorise(EFalse, serviceId, _L("reqX"), dec2, rs2);
   1.181 +	testSubsession3.Authorise(EFalse, serviceId, _L("req2"), dec3, rs3);
   1.182 +	testSubsession4.Authorise(EFalse, serviceId, _L("reqX"), dec4, rs4);
   1.183 +	testSubsession5.Authorise(EFalse, serviceId, _L("req3"), dec5, rs5);
   1.184 +	testSubsession6.Authorise(EFalse, serviceId, _L("req4"), dec6, rs6);
   1.185 +#if 0
   1.186 +	// Will change immediately in non-interactive testing
   1.187 +	test(dec1 == EUpsDecYes);	// not changed yet
   1.188 +	test(dec2 == EUpsDecYes);	// not changed yet
   1.189 +	test(dec3 == EUpsDecYes);	// not changed yet
   1.190 +	test(dec4 == EUpsDecYes);	// not changed yet
   1.191 +	test(dec5 == EUpsDecYes);	// not changed yet
   1.192 +	test(dec6 == EUpsDecYes);	// not changed yet
   1.193 +#endif
   1.194 +	User::After(1000);
   1.195 +
   1.196 +	User::WaitForRequest(rs1);
   1.197 +
   1.198 +	User::WaitForRequest(rs2);
   1.199 +	User::WaitForRequest(rs4);
   1.200 +
   1.201 +	User::WaitForRequest(rs3);
   1.202 +	User::WaitForRequest(rs5);
   1.203 +	User::WaitForRequest(rs6);
   1.204 +	test(rs1 == KErrNone);
   1.205 +	test(rs2 == KErrNone);
   1.206 +	test(rs3 == KErrNone);
   1.207 +	test(rs4 == KErrNone);
   1.208 +	test(rs5 == KErrNone);
   1.209 +	test(rs6 == KErrNone);
   1.210 +	test(dec1 == EUpsDecNo);
   1.211 +	test(dec2 == EUpsDecNo);
   1.212 +	test(dec3 == EUpsDecNo);
   1.213 +	test(dec4 == EUpsDecNo);
   1.214 +	test(dec5 == EUpsDecNo);
   1.215 +	test(dec6 == EUpsDecNo);
   1.216 +	
   1.217 +	test.End();
   1.218 +	}
   1.219 +
   1.220 +// -------- RUpsSubsession --------
   1.221 +_LIT(KSayYes,"SayYes");
   1.222 +static void TestRUpsSubsession()
   1.223 +/**
   1.224 +	Attempt query with server checks passed and without
   1.225 + */
   1.226 +	{
   1.227 +	//
   1.228 +	// Tests for RUpsSubsession
   1.229 +	//
   1.230 +	RThread thd;
   1.231 +
   1.232 +	test.Start(_L("Testing RUpsSubsession"));
   1.233 +	RUpsSubsession clientSubsession;
   1.234 +	TInt r = clientSubsession.Initialise(sTestSession, thd);
   1.235 +	test(r == KErrNone);
   1.236 +
   1.237 +	test.Next(_L("Query with server checks passed"));
   1.238 +	TServiceId serviceId = {42};
   1.239 +	TUpsDecision dec = EUpsDecNo;
   1.240 +	TRequestStatus rs;
   1.241 +	// Query saying our checks were ok, expect to get decision set to EUpsDecYes
   1.242 +	clientSubsession.Authorise(ETrue, serviceId, _L("Destination"), _L8("Opaque data"), dec, rs);
   1.243 +	User::WaitForRequest(rs);
   1.244 +	test(rs == KErrNone);
   1.245 +	test(dec == EUpsDecYes);
   1.246 +
   1.247 +
   1.248 +
   1.249 +	test.Next(_L("Try closing client subsession before it is really created"));
   1.250 +	clientSubsession.Close();
   1.251 +
   1.252 +	test.Next(_L("Re-\"create\" client subsession"));
   1.253 +	r = clientSubsession.Initialise(sTestSession, thd);
   1.254 +	test(r == KErrNone);
   1.255 +
   1.256 +	test.Next(_L("Query with server checks failed, ie query UPS, expect fail"));
   1.257 +	// Query saying our checks failed, should talk to UPS and change decision to EUpsDecNo
   1.258 +	dec = EUpsDecYes;
   1.259 +	clientSubsession.Authorise(EFalse, serviceId, KNullDesC, dec, rs);
   1.260 +	User::WaitForRequest(rs);
   1.261 +	test(rs == KErrNone);
   1.262 +	test(dec == EUpsDecNo);
   1.263 +
   1.264 +
   1.265 +	test.Next(_L("Query with server checks failed, ie query UPS, special destination, expect yes"));
   1.266 +	// Query saying our checks failed, should talk to UPS and change decision to EUpsDecNo
   1.267 +	dec = EUpsDecYes;
   1.268 +	clientSubsession.Authorise(EFalse, serviceId, KSayYes(), dec, rs);
   1.269 +	User::WaitForRequest(rs);
   1.270 +	test(rs == KErrNone);
   1.271 +	test(dec == EUpsDecYes);
   1.272 +
   1.273 +
   1.274 +	clientSubsession.Close();
   1.275 +	test.End();
   1.276 +	}
   1.277 +
   1.278 +TInt ThreadFunction(TAny *)
   1.279 +	{
   1.280 +	return KErrNone;
   1.281 +	}
   1.282 +
   1.283 +static void TestRUpsSubsessionDeathL()
   1.284 +	{
   1.285 +	RThread thd;
   1.286 +	TRequestStatus thdStatus;
   1.287 +	User::LeaveIfError(thd.Create(_L("MyThread"), ThreadFunction, 4096, 4096, 4096, 0, EOwnerThread));
   1.288 +//	thd.SetHandle(666);
   1.289 +	thd.Rendezvous(thdStatus);
   1.290 +	thd.Kill(KErrAbort);
   1.291 +	User::WaitForRequest(thdStatus);
   1.292 +
   1.293 +	test.Start(_L("Testing RUpsSubsession"));
   1.294 +	RUpsSubsession clientSubsession;
   1.295 +	TInt r = clientSubsession.Initialise(sTestSession, thd);
   1.296 +	test(r == KErrNone);
   1.297 +
   1.298 +	test.Next(_L("Query with dead thread id"));
   1.299 +	TServiceId serviceId = {43};
   1.300 +	TUpsDecision dec = EUpsDecYes;
   1.301 +	TRequestStatus rs;
   1.302 +	thd.Close();
   1.303 +	clientSubsession.Authorise(EFalse, serviceId, _L("req1"), dec, rs);
   1.304 +	User::WaitForRequest(rs);
   1.305 +	test(rs == KErrNone);
   1.306 +	test(dec == EUpsDecNo);
   1.307 +
   1.308 +	
   1.309 +	clientSubsession.Close();
   1.310 +	test.End();
   1.311 +	}
   1.312 +
   1.313 +static void TestRUpsManagementL()
   1.314 +/**
   1.315 +	Attempt to delete database
   1.316 + */
   1.317 +	{
   1.318 +	test.Start(_L("Testing RUpsManagement"));
   1.319 +	RThread thd;
   1.320 +	TRequestStatus rs;
   1.321 +
   1.322 +	// Create filter
   1.323 +	TServiceId serviceId = {43};
   1.324 +	CDecisionFilter *filter = CDecisionFilter::NewLC();
   1.325 +	filter->SetClientSid(thd.SecureId(), EEqual);
   1.326 +	filter->SetServerSid(thd.SecureId(), EEqual);
   1.327 +	filter->SetServiceId(serviceId, EEqual);
   1.328 +
   1.329 +	RUpsSubsession clientSubsession;
   1.330 +	TInt r = clientSubsession.Initialise(sTestSession, thd);
   1.331 +	test(r == KErrNone);
   1.332 +
   1.333 +	test.Next(_L("Open management session"));
   1.334 +	RUpsManagement mngmnt;
   1.335 +	r = mngmnt.Connect();
   1.336 +	test(r == KErrNone);
   1.337 +	User::LeaveIfError(r);
   1.338 +
   1.339 +	test.Next(_L("View create - then delete DB"));
   1.340 +	mngmnt.CreateView(*filter, rs);
   1.341 +
   1.342 +	test.Next(_L("Delete database"));
   1.343 +	TRAP(r, mngmnt.DeleteDatabaseL());
   1.344 +	test(r == KErrNone);
   1.345 +
   1.346 +	test.Next(_L("Now see what view create completed with...."));
   1.347 +	User::WaitForRequest(rs);
   1.348 +	test(rs.Int() == KErrAbort);
   1.349 +
   1.350 +	test.Next(_L("Add entry to new database"));
   1.351 +	TUpsDecision dec = EUpsDecYes;
   1.352 +	clientSubsession.Authorise(EFalse, serviceId, _L("DB delete 1"), _L8("Opaque data"), dec, rs);
   1.353 +	User::WaitForRequest(rs);
   1.354 +	test(rs == KErrNone);
   1.355 +	test(dec == EUpsDecNo);
   1.356 +
   1.357 +	dec = EUpsDecYes;
   1.358 +	clientSubsession.Authorise(EFalse, serviceId, _L("DB delete 2"), _L8("Opaque data"), dec, rs);
   1.359 +	User::WaitForRequest(rs);
   1.360 +	test(rs == KErrNone);
   1.361 +	test(dec == EUpsDecNo);
   1.362 +
   1.363 +
   1.364 +	test.Next(_L("View create - immediate cancel"));
   1.365 +	mngmnt.CreateView(*filter, rs);
   1.366 +	mngmnt.CancelAndCloseView();
   1.367 +	User::WaitForRequest(rs);
   1.368 +	test(rs.Int() == KErrCancel);
   1.369 +
   1.370 +	mngmnt.UpdateDecision(TUint32(-23), ETrue, rs);
   1.371 +	mngmnt.CancelUpdateDecision();
   1.372 +	User::WaitForRequest(rs);
   1.373 +	test(rs.Int() == KErrCancel);
   1.374 +
   1.375 +	mngmnt.UpdateDecision(TUint32(-23), ETrue, rs);
   1.376 +	User::WaitForRequest(rs);
   1.377 +	test(rs.Int() == KErrNotFound);
   1.378 +
   1.379 +	test.Next(_L("View create - when busy"));
   1.380 +	TRequestStatus rs2;
   1.381 +	mngmnt.CreateView(*filter, rs);
   1.382 +	mngmnt.CreateView(*filter, rs2);
   1.383 +	User::WaitForRequest(rs2);
   1.384 +	test(rs2.Int() == KErrServerBusy);
   1.385 +	User::WaitForRequest(rs);
   1.386 +	test(rs.Int() == KErrNone);
   1.387 +	mngmnt.CancelAndCloseView();
   1.388 +
   1.389 +	test.Next(_L("View create - iterate through it"));
   1.390 +	mngmnt.CreateView(*filter, rs);
   1.391 +
   1.392 +	User::WaitForRequest(rs);
   1.393 +	test(rs.Int() == KErrNone);
   1.394 +	
   1.395 +	CleanupStack::PopAndDestroy(filter);
   1.396 +
   1.397 +	CDecisionRecord *record = 0;
   1.398 +	r = KErrNone;
   1.399 +	TInt recordCount = 0;
   1.400 +	while(r == KErrNone)
   1.401 +		{
   1.402 +		TRAP(r, record = mngmnt.NextMatchL());
   1.403 +		if(record == 0)
   1.404 +			{
   1.405 +			break;
   1.406 +			}
   1.407 +		test(r == KErrNone);
   1.408 +		if(r == KErrNone)
   1.409 +			{
   1.410 +			++recordCount;
   1.411 +			CleanupStack::PushL(record);
   1.412 +			CDecisionFilter *exactFilter = CDecisionFilter::NewLC(record->iClientSid,
   1.413 +																  record->iEvaluatorId,
   1.414 +																  record->iServiceId,
   1.415 +																  record->iServerSid,
   1.416 +																  record->iFingerprint,
   1.417 +																  record->iClientEntity,
   1.418 +																  record->iMajorPolicyVersion);
   1.419 +				
   1.420 +			
   1.421 +			mngmnt.UpdateDecision(record->iRecordId, ETrue, rs);
   1.422 +			User::WaitForRequest(rs);
   1.423 +			test(rs.Int() == KErrNone);
   1.424 +			TRAP(r, mngmnt.RemoveDecisionsL(*exactFilter));
   1.425 +			test(r == KErrNone);
   1.426 +
   1.427 +			CleanupStack::PopAndDestroy(exactFilter);
   1.428 +			CleanupStack::PopAndDestroy(record);
   1.429 +			}
   1.430 +		
   1.431 +		};
   1.432 +	test(recordCount == 2);
   1.433 +	
   1.434 +	TRAP(r, record = mngmnt.NextMatchL());
   1.435 +	test((r == KErrNone) && (record == 0));
   1.436 +
   1.437 +	mngmnt.CancelAndCloseView();
   1.438 +
   1.439 +	test.Next(_L("Close management session and clientSubsession"));
   1.440 +	mngmnt.Close();
   1.441 +	clientSubsession.Close();
   1.442 +
   1.443 +	test.End();
   1.444 +	}
   1.445 +
   1.446 +void TestSwiObserverSecurityL()
   1.447 +{
   1.448 +	test.Start(_L("Testing swi observer functions do not work from here..."));
   1.449 +
   1.450 +	TInt r;
   1.451 +
   1.452 +	RUpsManagement session;
   1.453 +	User::LeaveIfError(session.Connect());
   1.454 +	CleanupClosePushL(session);
   1.455 +
   1.456 +	TUid ourSid;
   1.457 +	ourSid.iUid = 0x10283559;
   1.458 +	TRAP(r, session.DeleteDecisionsForExeL(ourSid));
   1.459 +	test(r == KErrPermissionDenied);
   1.460 +
   1.461 +	TRAP(r, session.NotifyPluginsMayHaveChangedL());
   1.462 +	test(r == KErrPermissionDenied);
   1.463 +
   1.464 +	TRequestStatus rs;
   1.465 +	session.NotifyPolicyFilesChanged(rs);
   1.466 +	User::WaitForRequest(rs);
   1.467 +
   1.468 +	test(rs.Int() == KErrPermissionDenied);
   1.469 +
   1.470 +	session.CancelNotifyPolicyFilesChanged();
   1.471 +
   1.472 +	CleanupStack::PopAndDestroy(&session);
   1.473 +	
   1.474 +	test.End();
   1.475 +}
   1.476 +
   1.477 +// -------- entrypoint --------
   1.478 +
   1.479 +
   1.480 +void MainL()
   1.481 +	{
   1.482 +	test.Title(_L("c:\\upstest.log"));
   1.483 +	test.Start(_L(" @SYMTestCaseID:SEC-UPS-0001 Testing RUpsSubsession "));
   1.484 +
   1.485 +	RFs fs;
   1.486 +	User::LeaveIfError(fs.Connect());
   1.487 +	CleanupClosePushL(fs);
   1.488 +	
   1.489 +	TBuf<21> notifierConfig(_L("!:\\upsrefnotifier.txt"));
   1.490 +	notifierConfig[0] = fs.GetSystemDriveChar();
   1.491 +
   1.492 +	TBuf<35> database(_L("!:\\Private\\10283558\\database\\ups.db"));
   1.493 +	database[0] = fs.GetSystemDriveChar();
   1.494 +
   1.495 +	TInt lineLength = User::CommandLineLength();
   1.496 +	switch(lineLength)
   1.497 +		{
   1.498 +	default:
   1.499 +		case 2:
   1.500 +			(void) fs.Delete(database);
   1.501 +			// Fall through to also delete notifier config file
   1.502 +		case 1:
   1.503 +			(void) fs.Delete(notifierConfig);
   1.504 +			break;
   1.505 +		case 0:
   1.506 +			{
   1.507 +			// No args so run in silent mode
   1.508 +			(void) fs.Delete(database);
   1.509 +			(void) fs.Delete(notifierConfig);
   1.510 +			RFile file;
   1.511 +			User::LeaveIfError(file.Create(fs, notifierConfig, EFileShareExclusive | EFileWrite));
   1.512 +			User::LeaveIfError(file.Write(_L8("Never")));
   1.513 +			file.Close();
   1.514 +			break;
   1.515 +			}
   1.516 +		}
   1.517 +
   1.518 +	//RThread ourThread;
   1.519 +	//ourThread.SetPriority(EPriorityMore);
   1.520 +	//ourThread.Close();
   1.521 +//	User::SetProcessCritical(User::ESystemCritical);
   1.522 +//	User::SetCritical(User::ESystemCritical);
   1.523 +	TestOpenCloseSession();
   1.524 +
   1.525 +
   1.526 +	TInt r = sTestSession.Connect();
   1.527 +	test(r == KErrNone);
   1.528 +	User::LeaveIfError(r);
   1.529 +
   1.530 +	TestRUpsSubsessionDeathL();
   1.531 +
   1.532 +	TestOpenCloseSubsession();
   1.533 +
   1.534 +	TestSwiObserverSecurityL();
   1.535 +	
   1.536 +	RThread thd;
   1.537 +	r = sTestSubsession.Initialise(sTestSession, thd);
   1.538 +	test(r == KErrNone);
   1.539 +	User::LeaveIfError(r);
   1.540 +	
   1.541 +	TestFlurryL();
   1.542 +
   1.543 +	TestAuthoriseL();
   1.544 +	
   1.545 +	sTestSubsession.Close();
   1.546 +
   1.547 +	TestRUpsSubsession();
   1.548 +
   1.549 +	TestRUpsManagementL();
   1.550 +
   1.551 +	sTestSession.ShutdownServer();
   1.552 +
   1.553 +	// Close top level session (low level session was closed by
   1.554 +	// ShutdownServer, but we still need to do the RUpsSession
   1.555 +	// cleanup).
   1.556 +	sTestSession.Close();
   1.557 +
   1.558 +	(void) fs.Delete(notifierConfig);
   1.559 +	CleanupStack::PopAndDestroy(&fs);
   1.560 +	
   1.561 +	test.End();
   1.562 +	test.Close();
   1.563 +}
   1.564 +
   1.565 +void PanicIfError(TInt r)
   1.566 +	{
   1.567 +	if(r != KErrNone)
   1.568 +		{
   1.569 +		User::Panic(_L("upstest failed: "), r);
   1.570 +		}
   1.571 +	}
   1.572 +
   1.573 +
   1.574 +TInt E32Main()
   1.575 +/**
   1.576 +	Executable entrypoint establishes connection with UPS server
   1.577 +	and then invokes tests for each functional area.
   1.578 +	
   1.579 +	@return					Symbian OS error code where KErrNone indicates
   1.580 +							success and any other value indicates failure.
   1.581 + */
   1.582 +	{
   1.583 +	// disable lazy DLL unloading so kernel heap balances at end
   1.584 +	RLoader l;
   1.585 +	PanicIfError(l.Connect());
   1.586 +	PanicIfError(l.CancelLazyDllUnload());
   1.587 +	l.Close();
   1.588 +	
   1.589 +	__UHEAP_MARK;
   1.590 +	//__KHEAP_MARK;
   1.591 +	
   1.592 +	// allocating a cleanup stack also installs it
   1.593 +	CTrapCleanup* tc = CTrapCleanup::New();
   1.594 +	if (tc == 0)
   1.595 +		return KErrNoMemory;
   1.596 +
   1.597 +	TRAPD(err, MainL());
   1.598 +	if(err != KErrNone)
   1.599 +		{
   1.600 +		User::Panic(_L("upstest failed: "), err);
   1.601 +		}
   1.602 +	delete tc;
   1.603 +	
   1.604 +	//__KHEAP_MARKEND;
   1.605 +	__UHEAP_MARKEND;
   1.606 +	
   1.607 +	
   1.608 +	return KErrNone;
   1.609 +	}
   1.610 +