Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

17 LTW broker test cases #1867

Merged
merged 38 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
af03382
commit 17 LTW broker test cases
yixilin09 Jul 31, 2023
aec7665
fixed typo of method name
yixilin09 Jul 31, 2023
7a69c72
Merge branch 'dev' into user/yixi/LTW_broker_test_cases
yixilin09 Aug 2, 2023
153ac8f
Merge branch 'dev' into user/yixi/LTW_broker_test_cases
yixilin09 Aug 4, 2023
1bddad8
fix assert expectation
yixilin09 Aug 4, 2023
997f954
Merge branch 'dev' into user/yixi/LTW_broker_test_cases
yixilin09 Aug 7, 2023
46cefae
Merge branch 'dev' into user/yixi/LTW_broker_test_cases
yixilin09 Aug 8, 2023
7b464da
add annotation for cases that use oneauthtestapp
yixilin09 Aug 8, 2023
55c5c78
add supportedbrokers annotation and remove unneccessary broker instal…
yixilin09 Aug 8, 2023
4e7e3e0
Merge branch 'dev' into user/yixi/LTW_broker_test_cases
yixilin09 Aug 14, 2023
f313cbe
Merge branch 'dev' into user/yixi/LTW_broker_test_cases
yixilin09 Aug 18, 2023
3bff61e
remove msalTestApp.uninstall()
yixilin09 Aug 18, 2023
b4842d4
move to package broker.ltw
yixilin09 Aug 18, 2023
d855b98
move ltw basic test case to package msalonly.ltw
yixilin09 Aug 18, 2023
c042698
revome unnecessary steps
yixilin09 Aug 18, 2023
2467443
modify testcase2517374
yixilin09 Aug 20, 2023
c751bb8
Merge branch 'dev' into user/yixi/LTW_broker_test_cases
yixilin09 Aug 20, 2023
1abcf51
remove unnecessary uninstall()
yixilin09 Aug 21, 2023
96fcdf4
Merge branch 'dev' into user/yixi/LTW_broker_test_cases
yixilin09 Aug 24, 2023
b6433de
move test cases to ltw package under broker
yixilin09 Aug 24, 2023
6578176
Merge branch 'dev' into user/yixi/LTW_broker_test_cases
yixilin09 Aug 28, 2023
22390db
change sessionExpected to true
yixilin09 Aug 29, 2023
0d6ff31
fix comments
yixilin09 Aug 29, 2023
0be0b1f
change testcase 2517374 and 2517381 to extends AbstractMsalUiTest cla…
yixilin09 Aug 29, 2023
f17cf83
add comment
yixilin09 Aug 31, 2023
adff51c
Merge branch 'dev' into user/yixi/LTW_broker_test_cases
amoyixi Sep 5, 2023
c9c27f3
add supportbroker annotation for cases that install Authenticator first
yixilin09 Sep 5, 2023
1362620
Merge branch 'dev' into user/yixi/LTW_broker_test_cases
amoyixi Sep 7, 2023
2947184
Merge branch 'dev' into user/yixi/LTW_broker_test_cases
amoyixi Sep 14, 2023
50703e6
Merge branch 'dev' into user/yixi/LTW_broker_test_cases
amoyixi Sep 20, 2023
54b63c4
Handle browser first run in case 2517374&2517381
cikelengfeng Sep 22, 2023
aa60490
update common for browser handle first run
cikelengfeng Sep 22, 2023
d191b4a
Merge branch 'dev' into user/yixi/LTW_broker_test_cases
amoyixi Sep 27, 2023
9b0e289
revert common change
yixilin09 Oct 12, 2023
b8d3f8b
Merge branch 'dev' into user/yixi/LTW_broker_test_cases
yixilin09 Oct 12, 2023
5af863b
update latest code
yixilin09 Oct 27, 2023
ff1927c
Merge branch 'dev' into user/yixi/LTW_broker_test_cases
amoyixi Oct 27, 2023
c18713b
Merge branch 'dev' into user/yixi/LTW_broker_test_cases
amoyixi Nov 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
// Copyright (c) Microsoft Corporation.
// All rights reserved.
//
// This code is licensed under the MIT License.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files(the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions :
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package com.microsoft.identity.client.msal.automationapp.testpass.broker.ltw;

import com.microsoft.identity.client.msal.automationapp.R;
import com.microsoft.identity.client.msal.automationapp.testpass.broker.AbstractMsalBrokerTest;
import com.microsoft.identity.client.ui.automation.annotations.LTWTests;
import com.microsoft.identity.client.ui.automation.annotations.RunOnAPI29Minus;
import com.microsoft.identity.client.ui.automation.annotations.SupportedBrokers;
import com.microsoft.identity.client.ui.automation.app.MsalTestApp;
import com.microsoft.identity.client.ui.automation.app.OneAuthTestApp;
import com.microsoft.identity.client.ui.automation.broker.BrokerCompanyPortal;
import com.microsoft.identity.client.ui.automation.broker.BrokerLTW;
import com.microsoft.identity.client.ui.automation.interaction.FirstPartyAppPromptHandlerParameters;
import com.microsoft.identity.client.ui.automation.interaction.PromptParameter;
import com.microsoft.identity.client.ui.automation.interaction.microsoftsts.MicrosoftStsPromptHandlerParameters;
import com.microsoft.identity.labapi.utilities.client.LabQuery;
import com.microsoft.identity.labapi.utilities.constants.TempUserType;

import org.junit.Assert;
import org.junit.Test;

// Samsung GA Coverage
// https://identitydivision.visualstudio.com/Engineering/_workitems/edit/2571345
@LTWTests
@RunOnAPI29Minus
@SupportedBrokers(brokers = {BrokerLTW.class})
public class TestCase2571345 extends AbstractMsalBrokerTest {
@Test
public void test_2571345() throws Throwable{
final String username = mLabAccount.getUsername();
final String password = mLabAccount.getPassword();

// Install new OneAuthTestApp
final OneAuthTestApp oneAuthTestApp = new OneAuthTestApp();
oneAuthTestApp.install();
oneAuthTestApp.launch();
oneAuthTestApp.handleFirstRun();

final FirstPartyAppPromptHandlerParameters promptHandlerParametersOneAuth = FirstPartyAppPromptHandlerParameters.builder()
amoyixi marked this conversation as resolved.
Show resolved Hide resolved
.broker(mBroker)
.prompt(PromptParameter.LOGIN)
.loginHint(username)
.consentPageExpected(false)
.speedBumpExpected(false)
.sessionExpected(false)
.expectingBrokerAccountChooserActivity(false)
.expectingLoginPageAccountPicker(false)
.enrollPageExpected(false)
.build();
// Click on sign in button, prompted to enter username and password
oneAuthTestApp.addFirstAccount(username, password, promptHandlerParametersOneAuth);
oneAuthTestApp.confirmAccount(username);

// Install new MsalTestApp
final MsalTestApp msalTestApp = new MsalTestApp();
msalTestApp.install();
msalTestApp.launch();
msalTestApp.handleFirstRun();

final MicrosoftStsPromptHandlerParameters promptHandlerParametersMsal = MicrosoftStsPromptHandlerParameters.builder()
.prompt(PromptParameter.SELECT_ACCOUNT)
.loginHint(username)
.sessionExpected(false)
.broker(mBroker)
.expectingBrokerAccountChooserActivity(false)
.expectingProvidedAccountInBroker(false)
.expectingLoginPageAccountPicker(false)
.expectingProvidedAccountInCookie(false)
.consentPageExpected(false)
.passwordPageExpected(false)
.speedBumpExpected(false)
.registerPageExpected(false)
.enrollPageExpected(false)
.staySignedInPageExpected(false)
.verifyYourIdentityPageExpected(false)
.howWouldYouLikeToSignInExpected(false)
.build();

// Add login hint as the username and Click on AcquireToken button
// NOT prompted for credentials.
msalTestApp.handleUserNameInput(username);
final String token = msalTestApp.acquireToken(username, password, promptHandlerParametersMsal, false);
Assert.assertNotNull(token);

// Click on "Get Active Broker Pkg Name" button
//The response msg should show LTW's pkg name
msalTestApp.handleBackButton();
final String activeBroker = msalTestApp.getActiveBrokerPackageName();
Assert.assertEquals("Active broker pkg name : " + BrokerLTW.BROKER_LTW_APP_PACKAGE_NAME, activeBroker);
}

@Override
public LabQuery getLabQuery() {
return null;
}

@Override
public TempUserType getTempUserType() {
return TempUserType.BASIC;
}

@Override
public String[] getScopes() {
return new String[]{"User.read"};
}

@Override
public String getAuthority() {
return mApplication.getConfiguration().getDefaultAuthority().getAuthorityURL().toString();
}

@Override
public int getConfigFileResourceId() {
return R.raw.msal_config_default;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
// Copyright (c) Microsoft Corporation.
// All rights reserved.
//
// This code is licensed under the MIT License.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files(the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions :
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package com.microsoft.identity.client.msal.automationapp.testpass.broker.ltw;

import com.microsoft.identity.client.msal.automationapp.R;
import com.microsoft.identity.client.msal.automationapp.testpass.broker.AbstractMsalBrokerTest;
import com.microsoft.identity.client.ui.automation.annotations.LTWTests;
import com.microsoft.identity.client.ui.automation.annotations.RunOnAPI29Minus;
import com.microsoft.identity.client.ui.automation.annotations.SupportedBrokers;
import com.microsoft.identity.client.ui.automation.app.MsalTestApp;
import com.microsoft.identity.client.ui.automation.app.OneAuthTestApp;
import com.microsoft.identity.client.ui.automation.broker.BrokerCompanyPortal;
import com.microsoft.identity.client.ui.automation.broker.BrokerLTW;
import com.microsoft.identity.client.ui.automation.interaction.FirstPartyAppPromptHandlerParameters;
import com.microsoft.identity.client.ui.automation.interaction.PromptParameter;
import com.microsoft.identity.client.ui.automation.interaction.microsoftsts.MicrosoftStsPromptHandlerParameters;
import com.microsoft.identity.labapi.utilities.client.LabQuery;
import com.microsoft.identity.labapi.utilities.constants.TempUserType;

import org.junit.Assert;
import org.junit.Test;

// If Company Portal is installed after LTW, user should still get SSO
// https://identitydivision.visualstudio.com/Engineering/_workitems/edit/2571361
@LTWTests
@RunOnAPI29Minus
@SupportedBrokers(brokers = {BrokerLTW.class})
public class TestCase2571361 extends AbstractMsalBrokerTest {

@Test
public void test_2571361() throws Throwable {
final String username = mLabAccount.getUsername();
final String password = mLabAccount.getPassword();

// AcquireToken interactively on OneAuthTestApp
final OneAuthTestApp oneAuthTestApp = new OneAuthTestApp();
oneAuthTestApp.install();
oneAuthTestApp.launch();
oneAuthTestApp.handleFirstRun();

final FirstPartyAppPromptHandlerParameters promptHandlerParameters = FirstPartyAppPromptHandlerParameters.builder()
.broker(mBroker)
.prompt(PromptParameter.LOGIN)
.loginHint(username)
.consentPageExpected(false)
.speedBumpExpected(false)
.sessionExpected(false)
.expectingBrokerAccountChooserActivity(false)
.expectingLoginPageAccountPicker(false)
.enrollPageExpected(false)
.build();
oneAuthTestApp.addFirstAccount(username, password, promptHandlerParameters);
oneAuthTestApp.confirmAccount(username);

// Install new Company Portal
final BrokerCompanyPortal brokerCompanyPortal = new BrokerCompanyPortal();
brokerCompanyPortal.install();

// Install new MsalTestApp
final MsalTestApp msalTestApp = new MsalTestApp();
msalTestApp.install();
msalTestApp.launch();
msalTestApp.handleFirstRun();

final MicrosoftStsPromptHandlerParameters promptHandlerParametersMsal = MicrosoftStsPromptHandlerParameters.builder()
.prompt(PromptParameter.SELECT_ACCOUNT)
.loginHint(username)
.sessionExpected(false)
.broker(mBroker)
.expectingBrokerAccountChooserActivity(false)
.expectingProvidedAccountInBroker(false)
.expectingLoginPageAccountPicker(false)
.expectingProvidedAccountInCookie(false)
.consentPageExpected(false)
.passwordPageExpected(false)
.speedBumpExpected(false)
.registerPageExpected(false)
.enrollPageExpected(false)
.staySignedInPageExpected(false)
.verifyYourIdentityPageExpected(false)
.howWouldYouLikeToSignInExpected(false)
.build();

// Add login hint and click on acquireToken button
// will not be prompted to enter credentials
msalTestApp.handleUserNameInput(username);
final String token = msalTestApp.acquireToken(username, password, promptHandlerParametersMsal, false);
Assert.assertNotNull(token);

// Click on "Get Active Broker Pkg Name" button
//The response msg should show LTW's pkg name
msalTestApp.handleBackButton();
final String activeBroker = msalTestApp.getActiveBrokerPackageName();
Assert.assertEquals("Active broker pkg name : " + BrokerLTW.BROKER_LTW_APP_PACKAGE_NAME, activeBroker);
}

@Override
public LabQuery getLabQuery() {
return null;
}

@Override
public TempUserType getTempUserType() {
return TempUserType.BASIC;
}

@Override
public String[] getScopes() {
return new String[]{"User.read"};
}

@Override
public String getAuthority() {
return mApplication.getConfiguration().getDefaultAuthority().getAuthorityURL().toString();
}

@Override
public int getConfigFileResourceId() {
return R.raw.msal_config_default;
}
}
Loading