sl@0: // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Example CTestStep derived implementation sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file Authentication_TEF0Step.cpp sl@0: */ sl@0: #include "authentication_TEF0Step.h" sl@0: #include "Te_authentication_TEFSuiteDefs.h" sl@0: sl@0: #include sl@0: sl@0: CAuthentication_TEF0Step::~CAuthentication_TEF0Step() sl@0: /** sl@0: * Destructor sl@0: */ sl@0: { sl@0: } sl@0: sl@0: CAuthentication_TEF0Step::CAuthentication_TEF0Step() sl@0: /** sl@0: * Constructor sl@0: */ sl@0: { sl@0: // **MUST** call SetTestStepName in the constructor as the controlling sl@0: // framework uses the test step name immediately following construction to set sl@0: // up the step's unique logging ID. sl@0: SetTestStepName(KAuthentication_TEF0Step); sl@0: } sl@0: sl@0: TVerdict CAuthentication_TEF0Step::doTestStepPreambleL() sl@0: /** sl@0: * @return - TVerdict code sl@0: * Override of base class virtual sl@0: */ sl@0: { sl@0: SetTestStepResult(EPass); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TVerdict CAuthentication_TEF0Step::doTestStepL() sl@0: /** sl@0: * @return - TVerdict code sl@0: * Override of base class pure virtual sl@0: * Our implementation only gets called if the base class doTestStepPreambleL() did sl@0: * not leave. That being the case, the current test result value will be EPass. sl@0: */ sl@0: { sl@0: __UHEAP_MARK; sl@0: sl@0: CAuthentication* auth; sl@0: CUri8* uri; sl@0: TPtrC8 name; sl@0: TPtrC8 pwd; sl@0: sl@0: // create auth obj from name and pwd sl@0: auth = CAuthentication::NewL(KUser1, KPwd1); sl@0: CleanupStack::PushL(auth); sl@0: sl@0: sl@0: // *********** test default parameters *********** // sl@0: sl@0: // get name and compare to expected sl@0: name.Set(auth->Name()); sl@0: if(name.Compare(KUser1) != 0) sl@0: { sl@0: INFO_PRINTF1(KNameNotRetreivedProperly); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: // get pwd and compare to expected sl@0: pwd.Set(auth->Password()); sl@0: if(pwd.Compare(KPwd1) != 0) sl@0: { sl@0: INFO_PRINTF1(KPasswordNotRetreivedProperly); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: // compare default method to expected sl@0: if(auth->Method() != CAuthentication::EDigest) sl@0: { sl@0: INFO_PRINTF1(KMethodNotRetreivedProperly); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: // *********** test changing parameters *********** // sl@0: sl@0: // change and check new name sl@0: auth->SetNameL(KUser2); sl@0: name.Set(auth->Name()); sl@0: if(name.Compare(KUser2) != 0) sl@0: { sl@0: INFO_PRINTF1(KNameNotRetreivedProperly); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: // change and check new pwd sl@0: auth->SetPasswordL(KPwd2); sl@0: pwd.Set(auth->Password()); sl@0: if(pwd.Compare(KPwd2) != 0) sl@0: { sl@0: INFO_PRINTF1(KPasswordNotRetreivedProperly); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: // change and check new method sl@0: auth->SetMethod(CAuthentication::EBasic); sl@0: if(auth->Method() != CAuthentication::EBasic) sl@0: { sl@0: INFO_PRINTF1(KMethodNotRetreivedProperly); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(auth); sl@0: sl@0: // *********** test default parameters set using TUriC *********** // sl@0: sl@0: TUriParser8 uriParser; sl@0: uriParser.Parse(KUriUserInfoComplete); sl@0: uri = CUri8::NewLC(uriParser); sl@0: TUriC8 tUri = uri->Uri(); sl@0: sl@0: auth = CAuthentication::NewL(tUri); sl@0: CleanupStack::PushL(auth); sl@0: sl@0: name.Set(auth->Name()); sl@0: if(name.Compare(KUser1) != 0) sl@0: { sl@0: INFO_PRINTF1(KNameNotRetreivedProperly); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: // get pwd and compare to expected sl@0: pwd.Set(auth->Password()); sl@0: if(pwd.Compare(KPwd1) != 0) sl@0: { sl@0: INFO_PRINTF1(KPasswordNotRetreivedProperly); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: // compare default method to expected sl@0: if(auth->Method() != CAuthentication::EDigest) sl@0: { sl@0: INFO_PRINTF1(KMethodNotRetreivedProperly); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(2, uri); sl@0: sl@0: // *********** test with incomplete or missing User Info *********** // sl@0: sl@0: TUriParser8 incompleteUriParser; sl@0: CUri8* incompleteUri; sl@0: sl@0: // *** test incomplete uri type 1 sl@0: incompleteUriParser.Parse(KUriUserInfoIncomplete1); sl@0: incompleteUri = CUri8::NewLC(incompleteUriParser); sl@0: TUriC8 tIncompleteUri = incompleteUri->Uri(); sl@0: sl@0: // create from uri type 1 sl@0: auth = CAuthentication::NewL(tIncompleteUri); sl@0: CleanupStack::PushL(auth); sl@0: sl@0: // check has user and no pwd sl@0: name.Set(auth->Name()); sl@0: if(name.Compare(KUser1) != 0) sl@0: { sl@0: INFO_PRINTF1(KNameNotRetreivedProperly); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: pwd.Set(auth->Password()); sl@0: if(pwd.Compare(KNullDesC8) != 0) sl@0: { sl@0: INFO_PRINTF1(KPasswordNotRetreivedProperly); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: CleanupStack::PopAndDestroy(2, incompleteUri); sl@0: sl@0: // *** test incomplete uri type 2 sl@0: incompleteUriParser.Parse(KUriUserInfoIncomplete2); sl@0: incompleteUri = CUri8::NewLC(incompleteUriParser); sl@0: TUriC8 tIncompleteUri2 = incompleteUri->Uri(); sl@0: sl@0: // create from uri type 2 sl@0: auth = CAuthentication::NewL(tIncompleteUri2); sl@0: CleanupStack::PushL(auth); sl@0: sl@0: // check has user and no pwd sl@0: name.Set(auth->Name()); sl@0: if(name.Compare(KUser1) != 0) sl@0: { sl@0: INFO_PRINTF1(KNameNotRetreivedProperly); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: pwd.Set(auth->Password()); sl@0: if(pwd.Compare(KNullDesC8) != 0) sl@0: { sl@0: INFO_PRINTF1(KPasswordNotRetreivedProperly); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: CleanupStack::PopAndDestroy(2, incompleteUri); sl@0: sl@0: // *** test incomplete uri type 3 sl@0: incompleteUriParser.Parse(KUriUserInfoIncomplete3); sl@0: incompleteUri = CUri8::NewLC(incompleteUriParser); sl@0: TUriC8 tIncompleteUri3 = incompleteUri->Uri(); sl@0: sl@0: // create from uri type 3 sl@0: auth = CAuthentication::NewL(tIncompleteUri3); sl@0: CleanupStack::PushL(auth); sl@0: sl@0: // check no user name but has pwd sl@0: name.Set(auth->Name()); sl@0: if(name.Compare(KNullDesC8) != 0) sl@0: { sl@0: INFO_PRINTF1(KNameNotRetreivedProperly); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: pwd.Set(auth->Password()); sl@0: if(pwd.Compare(KPwd1) != 0) sl@0: { sl@0: INFO_PRINTF1(KPasswordNotRetreivedProperly); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: CleanupStack::PopAndDestroy(2, incompleteUri); sl@0: sl@0: // *** test incomplete uri type 4 sl@0: incompleteUriParser.Parse(KUriUserInfoIncomplete4); sl@0: incompleteUri = CUri8::NewLC(incompleteUriParser); sl@0: TUriC8 tIncompleteUri4 = incompleteUri->Uri(); sl@0: sl@0: // create from uri type 4 sl@0: auth = CAuthentication::NewL(tIncompleteUri4); sl@0: CleanupStack::PushL(auth); sl@0: sl@0: // check there is neither user nor pwd sl@0: name.Set(auth->Name()); sl@0: if(name.Compare(KNullDesC8) != 0) sl@0: { sl@0: INFO_PRINTF1(KNameNotRetreivedProperly); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: pwd.Set(auth->Password()); sl@0: if(pwd.Compare(KNullDesC8) != 0) sl@0: { sl@0: INFO_PRINTF1(KPasswordNotRetreivedProperly); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: CleanupStack::PopAndDestroy(2, incompleteUri); sl@0: sl@0: // *** test incomplete uri type 5 sl@0: incompleteUriParser.Parse(KUriUserInfoIncomplete4); sl@0: incompleteUri = CUri8::NewLC(incompleteUriParser); sl@0: TUriC8 tIncompleteUri5 = incompleteUri->Uri(); sl@0: sl@0: // create from uri type 5 sl@0: auth = CAuthentication::NewL(tIncompleteUri5); sl@0: CleanupStack::PushL(auth); sl@0: sl@0: // check there is neither user nor pwd sl@0: name.Set(auth->Name()); sl@0: if(name.Compare(KNullDesC8) != 0) sl@0: { sl@0: INFO_PRINTF1(KNameNotRetreivedProperly); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: pwd.Set(auth->Password()); sl@0: if(pwd.Compare(KNullDesC8) != 0) sl@0: { sl@0: INFO_PRINTF1(KPasswordNotRetreivedProperly); sl@0: SetTestStepResult(EFail); sl@0: } sl@0: CleanupStack::PopAndDestroy(2, incompleteUri); sl@0: sl@0: // *** test no user info. Must Leave with KErrNotFound. sl@0: incompleteUriParser.Parse(KUriNoUserInfo); sl@0: incompleteUri = CUri8::NewLC(incompleteUriParser); sl@0: TUriC8 tNoUserInfo = incompleteUri->Uri(); sl@0: sl@0: // create from uri with no user info sl@0: TRAPD(err, auth = CAuthentication::NewL(tNoUserInfo)); sl@0: if(err != KErrNotFound) sl@0: { sl@0: INFO_PRINTF1(KFailedToLeaveWithKErrNotFound); sl@0: SetTestStepResult(EFail); sl@0: delete auth; sl@0: } sl@0: CleanupStack::PopAndDestroy(incompleteUri); sl@0: sl@0: __UHEAP_MARKEND; sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: TVerdict CAuthentication_TEF0Step::doTestStepPostambleL() sl@0: /** sl@0: * @return - TVerdict code sl@0: * Override of base class virtual sl@0: */ sl@0: { sl@0: return TestStepResult(); sl@0: }