Skip to content

Commit 57238cb

Browse files
committed
Refactor for clarity and better code practices
1 parent 7b41d7d commit 57238cb

File tree

6 files changed

+7
-10
lines changed

6 files changed

+7
-10
lines changed

src/integrationtest/java/com.microsoft.aad.msal4j/DeviceCodeIT.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ public void DeviceCodeFlowADTest(String environment) throws Exception {
6161

6262
@Test(dataProvider = "environments", dataProviderClass = EnvironmentsProvider.class)
6363
public void DeviceCodeFlowADFSv2019Test(String environment) throws Exception {
64-
cfg = new Config(environment);
6564

6665
User user = labUserProvider.getOnPremAdfsUser(FederationProvider.ADFS_2019);
6766

src/main/java/com/microsoft/aad/msal4j/AADAuthority.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ class AADAuthority extends Authority {
2323
private final static String AAD_TOKEN_ENDPOINT_FORMAT = AAD_AUTHORITY_FORMAT + TOKEN_ENDPOINT;
2424
private final static String DEVICE_CODE_ENDPOINT_FORMAT = AAD_AUTHORITY_FORMAT + DEVICE_CODE_ENDPOINT;
2525

26-
String deviceCodeEndpoint;
27-
2826
AADAuthority(final URL authorityUrl) {
2927
super(authorityUrl, AuthorityType.AAD);
3028
setAuthorityProperties();

src/main/java/com/microsoft/aad/msal4j/ADFSAuthority.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ class ADFSAuthority extends Authority{
1414
private final static String ADFS_AUTHORITY_FORMAT = "https://%s/%s/";
1515
private final static String DEVICE_CODE_ENDPOINT_FORMAT = ADFS_AUTHORITY_FORMAT + DEVICE_CODE_ENDPOINT;
1616

17-
String deviceCodeEndpoint;
18-
1917
ADFSAuthority(final URL authorityUrl) {
2018
super(authorityUrl, AuthorityType.ADFS);
2119
this.authority = String.format(ADFS_AUTHORITY_FORMAT, host, tenant);
@@ -25,7 +23,5 @@ class ADFSAuthority extends Authority{
2523
this.deviceCodeEndpoint = String.format(DEVICE_CODE_ENDPOINT_FORMAT, host, tenant);
2624
}
2725

28-
String deviceCodeEndpoint() {
29-
return deviceCodeEndpoint;
30-
}
26+
3127
}

src/main/java/com/microsoft/aad/msal4j/Authority.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,8 @@ private static boolean isAdfsAuthority(final String firstPath) {
147147
private static boolean isB2CAuthority(final String firstPath) {
148148
return firstPath.compareToIgnoreCase(B2C_PATH_SEGMENT) == 0;
149149
}
150+
151+
String deviceCodeEndpoint() {
152+
return deviceCodeEndpoint;
153+
}
150154
}

src/main/java/com/microsoft/aad/msal4j/PublicClientApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public CompletableFuture<IAuthenticationResult> acquireToken(DeviceCodeFlowParam
5858
if (!(AuthorityType.AAD.equals(authenticationAuthority.authorityType()) ||
5959
AuthorityType.ADFS.equals(authenticationAuthority.authorityType()))) {
6060
throw new IllegalArgumentException(
61-
"Invalid authority type. Device Flow is only supported by AAD and ADFS authority");
61+
"Invalid authority type. Device Flow is only supported by AAD and ADFS authorities");
6262
}
6363

6464
validateNotNull("parameters", parameters);

src/test/java/com/microsoft/aad/msal4j/DeviceCodeFlowTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public void deviceCodeFlowTest() throws Exception {
150150
}
151151

152152
@Test(expectedExceptions = IllegalArgumentException.class,
153-
expectedExceptionsMessageRegExp = "Invalid authority type. Device Flow is only supported by AAD and ADFS authority")
153+
expectedExceptionsMessageRegExp = "Invalid authority type. Device Flow is only supported by AAD and ADFS authorities")
154154
public void executeAcquireDeviceCode_B2CAuthorityUsed_IllegalArgumentExceptionThrown()
155155
throws Exception {
156156

0 commit comments

Comments
 (0)