Skip to content

Commit cdd6cad

Browse files
authored
Merge pull request #1154 from AzureAD/rapong/mergemasterseptodev
Merge Master (September release) to dev
2 parents 84ef390 + 5649b26 commit cdd6cad

File tree

19 files changed

+1157
-15
lines changed

19 files changed

+1157
-15
lines changed

build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ allprojects {
2020
google()
2121
mavenLocal()
2222
jcenter()
23+
// Adding here because Travis cannot access AndroidADAL feed.
24+
maven {
25+
url 'https://pkgs.dev.azure.com/MicrosoftDeviceSDK/DuoSDK-Public/_packaging/Duo-SDK-Feed/maven/v1'
26+
name 'Duo-SDK-Feed'
27+
}
2328
maven {
2429
name "vsts-maven-adal-android"
2530
url "https://identitydivision.pkgs.visualstudio.com/_packaging/AndroidADAL/maven/v1"
@@ -28,11 +33,6 @@ allprojects {
2833
password project.vstsPassword
2934
}
3035
}
31-
// Adding here because Travis cannot access AndroidADAL feed.
32-
maven {
33-
url 'https://pkgs.dev.azure.com/MicrosoftDeviceSDK/DuoSDK-Public/_packaging/Duo-SDK-Feed%40Local/maven/v1'
34-
name 'Duo-SDK-Feed@Local'
35-
}
3636
}
3737
}
3838

changelog

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
MSAL Wiki : https://github.com/AzureAD/microsoft-authentication-library-for-android/wiki
22

3-
Version v.Next
3+
Version 2.0.0
44
----------
5-
- Allow Broker apps to obtain an RT associated to Broker's client ID (for WPJ).
6-
- Moved broker controller and strategy classes to common for MSALCPP brokered auth.
7-
- Removed 'defaultAuthority' param from TokenShareUtility; MSA RT ingestion always uses WW-/consumers.
5+
- Add Device Code Flow Support (#1112)
6+
- Moved broker controller and strategy classes to common for MSALCPP brokered auth. (#1115)
7+
- Allow Broker apps to obtain an RT associated to Broker's client ID (for WPJ). (#1126)
8+
- (API Breaking Change) Removed 'defaultAuthority' param from TokenShareUtility; MSA RT ingestion always uses WW-/consumers. (#1147)
9+
810

911
Version 1.6.0
1012
-----------

common

Submodule common updated 27 files

msal/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ dependencies {
148148
transitive = false
149149
}
150150

151-
snapshotApi(group: 'com.microsoft.identity', name: 'common', version: '2.0.15-SNAPSHOT', changing: true)
151+
snapshotApi(group: 'com.microsoft.identity', name: 'common', version: '3.0.1', changing: true)
152152

153-
distApi("com.microsoft.identity:common:2.0.15") {
153+
distApi("com.microsoft.identity:common:3.0.1") {
154154
transitive = false
155155
}
156156
}

msal/src/test/java/com/microsoft/identity/client/e2e/tests/mocked/DeviceCodeFlowApiTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,12 @@ private MicrosoftStsTokenRequest createMockTokenRequest() {
218218

219219
final MicrosoftStsTokenRequest tokenRequest = new MicrosoftStsTokenRequest();
220220
tokenRequest.setCodeVerifier("");
221-
tokenRequest.setCorrelationId(UUID.fromString("a-b-c-d-e"));
221+
tokenRequest.setCorrelationId(UUID.randomUUID());
222222
tokenRequest.setClientId(config.getClientId());
223223
tokenRequest.setGrantType(TokenRequest.GrantTypes.DEVICE_CODE);
224224
tokenRequest.setRedirectUri(config.getRedirectUri());
225+
tokenRequest.setClientAppName("TestApp");
226+
tokenRequest.setClientAppVersion("1.0");
225227

226228
return tokenRequest;
227229
}

msal/versioning/version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#Wed Aug 01 15:24:11 PDT 2018
2-
versionName=1.6.0
2+
versionName=2.0.0
33
versionCode=0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// All rights reserved.
3+
//
4+
// This code is licensed under the MIT License.
5+
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files(the "Software"), to deal
8+
// in the Software without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
10+
// copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions :
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
// THE SOFTWARE.
23+
package com.microsoft.identity.client.msal.automationapp;
24+
25+
import com.microsoft.identity.client.ui.automation.app.IApp;
26+
import com.microsoft.identity.client.ui.automation.browser.BrowserChrome;
27+
import com.microsoft.identity.internal.testutils.labutils.LabUserHelper;
28+
import com.microsoft.identity.internal.testutils.labutils.LabUserQuery;
29+
30+
import org.junit.Before;
31+
32+
public abstract class AbstractAcquireTokenNetworkTest extends AbstractAcquireTokenTest implements IAcquireTokenNetworkTest {
33+
34+
protected String mLoginHint;
35+
36+
public static final int TEMP_USER_WAIT_TIME = 15000;
37+
38+
@Before
39+
public void setup() {
40+
final LabUserQuery query = getLabUserQuery();
41+
final String tempUserType = getTempUserType();
42+
43+
if (query != null) {
44+
mLoginHint = LabUserHelper.loadUserForTest(query);
45+
} else if (tempUserType != null) {
46+
mLoginHint = LabUserHelper.loadTempUser(tempUserType);
47+
try {
48+
// temp user takes some time to actually being created even though it may be
49+
// returned by the LAB API. Adding a wait here before we proceed with the test.
50+
Thread.sleep(TEMP_USER_WAIT_TIME);
51+
} catch (InterruptedException e) {
52+
e.printStackTrace();
53+
}
54+
} else {
55+
throw new IllegalArgumentException("Both Lab User query and temp user type were null.");
56+
}
57+
58+
super.setup();
59+
}
60+
61+
@Override
62+
public IApp getBrowser() {
63+
return new BrowserChrome();
64+
}
65+
66+
}
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// All rights reserved.
3+
//
4+
// This code is licensed under the MIT License.
5+
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files(the "Software"), to deal
8+
// in the Software without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
10+
// copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions :
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
// THE SOFTWARE.
23+
package com.microsoft.identity.client.msal.automationapp;
24+
25+
import com.microsoft.identity.client.AuthenticationCallback;
26+
import com.microsoft.identity.client.IAccount;
27+
import com.microsoft.identity.client.IAuthenticationResult;
28+
import com.microsoft.identity.client.SilentAuthenticationCallback;
29+
import com.microsoft.identity.client.exception.MsalException;
30+
import com.microsoft.identity.client.ui.automation.app.IApp;
31+
import com.microsoft.identity.client.ui.automation.broker.ITestBroker;
32+
import com.microsoft.identity.client.ui.automation.utils.AdbShellUtils;
33+
import com.microsoft.identity.common.internal.util.StringUtil;
34+
35+
import org.junit.After;
36+
import org.junit.Assert;
37+
import org.junit.Before;
38+
39+
import java.util.concurrent.CountDownLatch;
40+
41+
import static com.microsoft.identity.common.adal.internal.AuthenticationConstants.Broker.AZURE_AUTHENTICATOR_APP_PACKAGE_NAME;
42+
import static com.microsoft.identity.common.adal.internal.AuthenticationConstants.Broker.COMPANY_PORTAL_APP_PACKAGE_NAME;
43+
import static junit.framework.Assert.fail;
44+
45+
public abstract class AbstractAcquireTokenTest extends AbstractPublicClientApplicationTest implements IAcquireTokenTest {
46+
47+
private static final String TAG = AbstractAcquireTokenTest.class.getSimpleName();
48+
49+
protected String[] mScopes;
50+
protected ITestBroker mBroker;
51+
protected IAccount mAccount;
52+
protected IApp mBrowser;
53+
54+
protected IAccount getAccount() {
55+
return mAccount;
56+
}
57+
58+
@Before
59+
public void setup() {
60+
mScopes = getScopes();
61+
mBroker = getBroker();
62+
mBrowser = getBrowser();
63+
64+
// clear all cookies in the browser
65+
mBrowser.clear();
66+
67+
// remove existing authenticator and company portal apps
68+
AdbShellUtils.removePackage(AZURE_AUTHENTICATOR_APP_PACKAGE_NAME);
69+
AdbShellUtils.removePackage(COMPANY_PORTAL_APP_PACKAGE_NAME);
70+
71+
if (mBroker != null) {
72+
// do a fresh install of broker
73+
mBroker.install();
74+
}
75+
76+
super.setup();
77+
}
78+
79+
@After
80+
public void cleanup() {
81+
mAccount = null;
82+
}
83+
84+
/**
85+
* A callback that can be used to perform assertions on completion of an interactive request
86+
* (success case) test.
87+
*
88+
* @param latch the latch associated to this request
89+
* @return an {@link AuthenticationCallback} object
90+
*/
91+
protected AuthenticationCallback successfulInteractiveCallback(final CountDownLatch latch) {
92+
return new AuthenticationCallback() {
93+
@Override
94+
public void onSuccess(IAuthenticationResult authenticationResult) {
95+
Assert.assertFalse(StringUtil.isEmpty(authenticationResult.getAccessToken()));
96+
mAccount = authenticationResult.getAccount();
97+
latch.countDown();
98+
}
99+
100+
@Override
101+
public void onError(MsalException exception) {
102+
fail(exception.getMessage());
103+
latch.countDown();
104+
}
105+
106+
@Override
107+
public void onCancel() {
108+
fail("User cancelled flow");
109+
latch.countDown();
110+
}
111+
};
112+
}
113+
114+
/**
115+
* A callback that can be used to perform assertions on completion of an silent request
116+
* (success case) test.
117+
*
118+
* @param latch the latch associated to this request
119+
* @return an {@link AuthenticationCallback} object
120+
*/
121+
protected SilentAuthenticationCallback successfulSilentCallback(final CountDownLatch latch) {
122+
return new SilentAuthenticationCallback() {
123+
@Override
124+
public void onSuccess(IAuthenticationResult authenticationResult) {
125+
Assert.assertFalse(StringUtil.isEmpty(authenticationResult.getAccessToken()));
126+
mAccount = authenticationResult.getAccount();
127+
latch.countDown();
128+
}
129+
130+
@Override
131+
public void onError(MsalException exception) {
132+
fail(exception.getMessage());
133+
latch.countDown();
134+
}
135+
};
136+
}
137+
138+
/**
139+
* A callback that can be used to perform assertions on completion of an interactive request
140+
* (failure case) test.
141+
*
142+
* @param latch the latch associated to this request
143+
* @return an {@link AuthenticationCallback} object
144+
*/
145+
protected AuthenticationCallback failureInteractiveCallback(final CountDownLatch latch, final String errorCode) {
146+
return new AuthenticationCallback() {
147+
@Override
148+
public void onSuccess(IAuthenticationResult authenticationResult) {
149+
fail("Unexpected success");
150+
latch.countDown();
151+
}
152+
153+
@Override
154+
public void onError(MsalException exception) {
155+
Assert.assertEquals(errorCode, exception.getErrorCode());
156+
latch.countDown();
157+
}
158+
159+
@Override
160+
public void onCancel() {
161+
fail("User cancelled flow");
162+
latch.countDown();
163+
}
164+
};
165+
}
166+
167+
/**
168+
* A callback that can be used to perform assertions on completion of an silent request
169+
* (failure case) test.
170+
*
171+
* @param latch the latch associated to this request
172+
* @return an {@link AuthenticationCallback} object
173+
*/
174+
protected SilentAuthenticationCallback failureSilentCallback(final CountDownLatch latch, final String errorCode) {
175+
return new SilentAuthenticationCallback() {
176+
@Override
177+
public void onSuccess(IAuthenticationResult authenticationResult) {
178+
fail("Unexpected success");
179+
latch.countDown();
180+
}
181+
182+
@Override
183+
public void onError(MsalException exception) {
184+
Assert.assertSame(errorCode, exception.getErrorCode());
185+
latch.countDown();
186+
}
187+
};
188+
}
189+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// All rights reserved.
3+
//
4+
// This code is licensed under the MIT License.
5+
//
6+
// Permission is hereby granted, free of charge, to any person obtaining a copy
7+
// of this software and associated documentation files(the "Software"), to deal
8+
// in the Software without restriction, including without limitation the rights
9+
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
10+
// copies of the Software, and to permit persons to whom the Software is
11+
// furnished to do so, subject to the following conditions :
12+
//
13+
// The above copyright notice and this permission notice shall be included in
14+
// all copies or substantial portions of the Software.
15+
//
16+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
// THE SOFTWARE.
23+
package com.microsoft.identity.client.msal.automationapp;
24+
25+
import android.app.Activity;
26+
import android.content.Context;
27+
28+
import androidx.test.core.app.ApplicationProvider;
29+
import androidx.test.rule.ActivityTestRule;
30+
31+
import com.microsoft.identity.client.IPublicClientApplication;
32+
import com.microsoft.identity.client.PublicClientApplication;
33+
import com.microsoft.identity.client.exception.MsalException;
34+
35+
import org.junit.Before;
36+
import org.junit.Rule;
37+
38+
import static org.junit.Assert.fail;
39+
40+
public abstract class AbstractPublicClientApplicationTest implements IPublicClientApplicationTest {
41+
42+
@Rule
43+
public ActivityTestRule<MainActivity> mActivityRule =
44+
new ActivityTestRule(MainActivity.class);
45+
46+
protected Context mContext;
47+
protected Activity mActivity;
48+
protected IPublicClientApplication mApplication;
49+
50+
@Before
51+
public void setup() {
52+
mContext = ApplicationProvider.getApplicationContext();
53+
mActivity = mActivityRule.getActivity();
54+
setupPCA();
55+
}
56+
57+
private void setupPCA() {
58+
try {
59+
mApplication = PublicClientApplication.create(mContext, getConfigFileResourceId());
60+
} catch (InterruptedException e) {
61+
fail(e.getMessage());
62+
} catch (MsalException e) {
63+
fail(e.getMessage());
64+
}
65+
}
66+
}

0 commit comments

Comments
 (0)