Skip to content

Commit de89662

Browse files
Copilotsomalaya
andauthored
refactor: rename processEstsReturnRedirect to processEstsHostRedirect and related identifiers
Agent-Logs-Url: https://github.com/AzureAD/microsoft-authentication-library-common-for-android/sessions/78e45bd4-5958-4e41-9f10-eaadb93b8b4f Co-authored-by: somalaya <69237821+somalaya@users.noreply.github.com>
1 parent fade585 commit de89662

4 files changed

Lines changed: 20 additions & 20 deletions

File tree

common/src/main/java/com/microsoft/identity/common/internal/ui/webview/AzureActiveDirectoryWebViewClient.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,8 @@ else if (isRedirectUrl(formattedURL)) {
365365
processHeaderForwardingRequiredUri(view, url);
366366
} else if (CommonFlightsManager.INSTANCE.getFlightsProvider().isFlightEnabled(CommonFlight.ENABLE_PRT_HEADER_FOR_ESTS_RETURN_REDIRECT)
367367
&& isEstsCloudHost(url)) {
368-
Logger.info(methodTag, "Navigation returns to eSTS cloud host, re-attaching PRT header.");
369-
processEstsReturnRedirect(view, url);
368+
Logger.info(methodTag, "Navigation redirects to eSTS cloud host, re-attaching PRT header.");
369+
processEstsHostRedirect(view, url);
370370
} else if (CommonFlightsManager.INSTANCE.getFlightsProvider().isFlightEnabled(CommonFlight.ENABLE_ATTACH_PRT_HEADER_WHEN_CROSS_CLOUD) && isCrossCloudRedirect(formattedURL)) {
371371
Logger.info(methodTag,"Navigation contains cross cloud redirect.");
372372
processCrossCloudRedirect(view, url);
@@ -1166,15 +1166,15 @@ boolean isEstsCloudHost(@NonNull final String url) {
11661166
}
11671167

11681168
/**
1169-
* Processes a return-to-eSTS redirect by generating a fresh PRT credential JWT and attaching it.
1169+
* Processes an eSTS host redirect by generating a fresh PRT credential JWT and attaching it.
11701170
*/
1171-
private void processEstsReturnRedirect(@NonNull final WebView view, @NonNull final String url) {
1172-
final String methodTag = TAG + ":processEstsReturnRedirect";
1173-
Logger.info(methodTag, "Processing return-to-eSTS redirect with PRT re-attachment.");
1174-
final Span span = createSpanWithAttributesFromParent(SpanName.EstsReturnRedirectPrtAttach.name());
1171+
private void processEstsHostRedirect(@NonNull final WebView view, @NonNull final String url) {
1172+
final String methodTag = TAG + ":processEstsHostRedirect";
1173+
Logger.info(methodTag, "Processing eSTS host redirect with PRT re-attachment.");
1174+
final Span span = createSpanWithAttributesFromParent(SpanName.EstsHostRedirectPrtAttach.name());
11751175
try {
11761176
final String host = new URL(url).getHost();
1177-
span.setAttribute(AttributeName.ests_return_host.name(), host);
1177+
span.setAttribute(AttributeName.ests_redirect_host.name(), host);
11781178
} catch (final MalformedURLException e) {
11791179
// Domain attribute is best-effort for telemetry
11801180
}

common/src/test/java/com/microsoft/identity/common/internal/ui/webview/AzureActiveDirectoryWebViewClientEstsReturnRedirectTest.java renamed to common/src/test/java/com/microsoft/identity/common/internal/ui/webview/AzureActiveDirectoryWebViewClientEstsHostRedirectTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
* {@link AzureActiveDirectoryWebViewClient}.
6161
*/
6262
@RunWith(RobolectricTestRunner.class)
63-
public class AzureActiveDirectoryWebViewClientEstsReturnRedirectTest {
63+
public class AzureActiveDirectoryWebViewClientEstsHostRedirectTest {
6464

6565
private static final String TEST_REDIRECT_URI = "abc12";
6666
private static final String TEST_ESTS_URL =
@@ -144,7 +144,7 @@ public void handleUrl_whenFlightEnabled_andEstsHost_returnsTrue() {
144144
}
145145

146146
@Test
147-
public void handleUrl_whenFlightDisabled_andEstsHost_doesNotCallProcessEstsReturnRedirect() {
147+
public void handleUrl_whenFlightDisabled_andEstsHost_doesNotCallProcessEstsHostRedirect() {
148148
final IFlightsProvider mockFlightsProvider = Mockito.mock(IFlightsProvider.class);
149149
when(mockFlightsProvider.isFlightEnabled(CommonFlight.ENABLE_PRT_HEADER_FOR_ESTS_RETURN_REDIRECT))
150150
.thenReturn(false);
@@ -160,7 +160,7 @@ public void handleUrl_whenFlightDisabled_andEstsHost_doesNotCallProcessEstsRetur
160160
}
161161

162162
@Test
163-
public void handleUrl_whenFlightEnabled_andNonEstsHost_doesNotHandleAsEstsReturn() {
163+
public void handleUrl_whenFlightEnabled_andNonEstsHost_doesNotHandleAsEstsHostRedirect() {
164164
final IFlightsProvider mockFlightsProvider = Mockito.mock(IFlightsProvider.class);
165165
when(mockFlightsProvider.isFlightEnabled(CommonFlight.ENABLE_PRT_HEADER_FOR_ESTS_RETURN_REDIRECT))
166166
.thenReturn(true);
@@ -180,8 +180,8 @@ public void handleUrl_whenFlightEnabled_andNonEstsHost_doesNotHandleAsEstsReturn
180180
@Test
181181
public void setRequestUrl_extractsLoginHint_whenPresent() {
182182
// Verifies that setRequestUrl does not throw and populates mLoginHint by
183-
// checking indirectly: when the flight is enabled and the redirect returns
184-
// to an eSTS host, the handler is called (i.e., processEstsReturnRedirect
183+
// checking indirectly: when the flight is enabled and the redirect goes to
184+
// an eSTS host, the handler is called (i.e., processEstsHostRedirect
185185
// was triggered), meaning the URL was handled.
186186
final IFlightsProvider mockFlightsProvider = Mockito.mock(IFlightsProvider.class);
187187
when(mockFlightsProvider.isFlightEnabled(CommonFlight.ENABLE_PRT_HEADER_FOR_ESTS_RETURN_REDIRECT))
@@ -193,10 +193,10 @@ public void setRequestUrl_extractsLoginHint_whenPresent() {
193193
// Set request URL with login_hint — this also populates mLoginHint
194194
mWebViewClient.setRequestUrl(TEST_ESTS_URL_WITH_LOGIN_HINT);
195195

196-
// The redirect back to an eSTS host should be handled by the new code path
196+
// The eSTS host redirect should be handled by the new code path
197197
final AzureActiveDirectoryWebViewClient spyClient = spy(mWebViewClient);
198198
final boolean result = spyClient.shouldOverrideUrlLoading(mMockWebView, TEST_ESTS_URL);
199-
assertTrue("Expected eSTS redirect to be handled after login_hint extraction", result);
199+
assertTrue("Expected eSTS host redirect to be handled after login_hint extraction", result);
200200
}
201201

202202
@Test

common4j/src/main/com/microsoft/identity/common/java/opentelemetry/AttributeName.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -665,12 +665,12 @@ public enum AttributeName {
665665
target_blank_navigation_route,
666666

667667
/**
668-
* The hostname of the eSTS cloud host to which a WebView redirect returned,
669-
* used for telemetry during PRT header re-attachment on eSTS return redirects.
668+
* The hostname of the eSTS cloud host targeted by a WebView redirect,
669+
* used for telemetry during PRT header re-attachment on eSTS host redirects.
670670
* Value: the URL host string (e.g. "login.microsoftonline.com").
671671
* NOTE: This attribute must also be added to the broker repo's AttributeName.java.
672672
*/
673-
ests_return_host,
673+
ests_redirect_host,
674674

675675
//endregion
676676
}

common4j/src/main/com/microsoft/identity/common/java/opentelemetry/SpanName.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ public enum SpanName {
6464
KeyPairGeneration,
6565
ProcessCrossCloudRedirect,
6666
/**
67-
* Span name for PRT header re-attachment when WebView returns to an eSTS cloud host.
67+
* Span name for PRT header re-attachment when WebView redirects to an eSTS cloud host.
6868
*/
69-
EstsReturnRedirectPrtAttach,
69+
EstsHostRedirectPrtAttach,
7070
SwitchBrowserResume,
7171
SwitchBrowserProcess,
7272
WrappedKeyAlgorithmIdentifier,

0 commit comments

Comments
 (0)