authenticationservices/authenticationserver/test/securitytests/source/authwritedevicedata.cpp
changeset 29 ece3df019add
equal deleted inserted replaced
19:cd501b96611d 29:ece3df019add
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "authwritedevicedata.h"
       
    20 #include <authserver/authclient.h>
       
    21 #include <authserver/authmgrclient.h>
       
    22 #include <scs/cleanuputils.h>
       
    23 #include <e32def.h>
       
    24 
       
    25 _LIT(KAuthWriteDeviceDataSecName, "Auth WriteDeviceData APIs test");
       
    26 
       
    27 using namespace AuthServer;
       
    28 
       
    29 CAuthWriteDeviceDataSecTest* CAuthWriteDeviceDataSecTest::NewL()
       
    30 	{
       
    31 	CAuthWriteDeviceDataSecTest* self=new(ELeave) CAuthWriteDeviceDataSecTest();
       
    32 	CleanupStack::PushL(self);
       
    33 	self->ConstructL();
       
    34 	CleanupStack::Pop(self);
       
    35 	return self;
       
    36 	}
       
    37 
       
    38 CAuthWriteDeviceDataSecTest::CAuthWriteDeviceDataSecTest()
       
    39 	{
       
    40 	SetCapabilityRequired(ECapabilityWriteDeviceData);
       
    41 	}
       
    42 	
       
    43 void CAuthWriteDeviceDataSecTest::ConstructL()
       
    44 	{
       
    45 	SetNameL(KAuthWriteDeviceDataSecName);
       
    46 	}
       
    47 
       
    48 void CAuthWriteDeviceDataSecTest::RunTestL()
       
    49 	{
       
    50 	AuthServer::RAuthMgrClient authMgrClient;	
       
    51 	User::LeaveIfError(authMgrClient.Connect());
       
    52 	CleanupClosePushL(authMgrClient);
       
    53 
       
    54 	TInt err(0);
       
    55 	TPluginId pluginId = 536883941;
       
    56 			
       
    57 	TRAP(err, authMgrClient.SetPreferredTypePluginL(EAuthKnowledge, pluginId));
       
    58 	CheckFailL(err, _L("AuthServer::SetPreferredTypePluginL()."));
       
    59 
       
    60 	TIdentityId identity = 420; // Any thing but 0 since client does sanity check
       
    61 	
       
    62 	TRAP(err, authMgrClient.RemoveIdentityL(identity));
       
    63 	CheckFailL(err, _L("AuthServer::RemoveIdentityL()."));
       
    64 		
       
    65 	TRAP(err, authMgrClient.ResetIdentityL(identity, _L("")));
       
    66 	CheckFailL(err, _L("AuthServer::ResetIdentityL() 1st overload."));
       
    67 
       
    68 	TRAP(err, authMgrClient.ResetIdentityL(identity, EAuthKnowledge, _L("")));
       
    69 	CheckFailL(err, _L("AuthServer::ResetIdentityL() 2nd overload."));
       
    70 
       
    71 	RArray<TPluginId> pluginList;
       
    72 	CleanupClosePushL(pluginList);
       
    73 	RPointerArray<const HBufC> regDataList;
       
    74 	CleanupResetAndDestroyPushL(regDataList);
       
    75 	pluginList.AppendL(pluginId);
       
    76 	regDataList.AppendL(KNullDesC().AllocL());
       
    77 	TRAP(err, authMgrClient.ResetIdentityL(identity, pluginList, regDataList));
       
    78 	CheckFailL(err, _L("AuthServer::ResetIdentityL() 3rd overload."));
       
    79 	CleanupStack::PopAndDestroy(2, &pluginList);
       
    80 
       
    81 	CleanupStack::PopAndDestroy(&authMgrClient);
       
    82 	}
       
    83