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

Add code formatter workflow #1661

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 25 additions & 0 deletions .github/workflows/formatter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This is a workflow to run the deploy snapshot pipeline in Azure DevOps
name: formatting

# Controls when the action will run. Triggers the workflow on pull request
# events but only for the dev branch
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches: [ dev ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# Make sure we have a changelog entry
formatting:
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- run: echo "The action here is ${{ github.event.name }}"
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
- uses: axel-op/[email protected]
with:
args: "--replace --aosp --skip-reflowing-long-strings --skip-javadoc-formatting"
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@

package com.microsoft.aad.adal;

import static androidx.test.InstrumentationRegistry.getInstrumentation;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.res.Configuration;
Expand All @@ -39,10 +44,6 @@

import java.util.Locale;

import static androidx.test.InstrumentationRegistry.getInstrumentation;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

@RunWith(AndroidJUnit4.class)
public class ADALErrorTest {

Expand All @@ -53,23 +54,17 @@ public class ADALErrorTest {
public void setUp() throws Exception {
System.setProperty(
"dexmaker.dexcache",
androidx.test.platform.app.InstrumentationRegistry
.getInstrumentation()
androidx.test.platform.app.InstrumentationRegistry.getInstrumentation()
.getTargetContext()
.getCacheDir()
.getPath()
);
.getPath());

System.setProperty(
"org.mockito.android.target",
ApplicationProvider
.getApplicationContext()
.getCacheDir()
.getPath()
);
ApplicationProvider.getApplicationContext().getCacheDir().getPath());

AuthenticationSettings.INSTANCE
.setBrokerPackageName(AuthenticationConstants.Broker.COMPANY_PORTAL_APP_PACKAGE_NAME);
AuthenticationSettings.INSTANCE.setBrokerPackageName(
AuthenticationConstants.Broker.COMPANY_PORTAL_APP_PACKAGE_NAME);
Logger.d(TAG, "mTestSignature is set");
}

Expand All @@ -78,22 +73,35 @@ public void setUp() throws Exception {
public void testResourceOverwrite() {
ADALError err = ADALError.DEVELOPER_AUTHORITY_CAN_NOT_BE_VALIDED;
String msg = err.getDescription();
Logger.i(TAG, "", "Test context packagename:" + getInstrumentation().getTargetContext().getPackageName());
Logger.i(
TAG,
"",
"Test context packagename:"
+ getInstrumentation().getTargetContext().getPackageName());
Locale locale2 = new Locale("de");
Locale.setDefault(locale2);
Configuration config = new Configuration();
config.setLocale(locale2);
getInstrumentation().getContext().getResources().updateConfiguration(config,
getInstrumentation().getContext().getResources().getDisplayMetrics());
getInstrumentation()
.getContext()
.getResources()
.updateConfiguration(
config,
getInstrumentation().getContext().getResources().getDisplayMetrics());
String localizedMsg = err.getLocalizedDescription(getInstrumentation().getContext());

assertFalse("Error description is different in resource", msg.equalsIgnoreCase(localizedMsg));
assertFalse(
"Error description is different in resource", msg.equalsIgnoreCase(localizedMsg));

Locale localefr = new Locale("fr");
Locale.setDefault(localefr);
config.setLocale(localefr);
getInstrumentation().getContext().getResources().updateConfiguration(config,
getInstrumentation().getContext().getResources().getDisplayMetrics());
getInstrumentation()
.getContext()
.getResources()
.updateConfiguration(
config,
getInstrumentation().getContext().getResources().getDisplayMetrics());
localizedMsg = err.getLocalizedDescription(getInstrumentation().getContext());

assertFalse("Same as english", msg.equalsIgnoreCase(localizedMsg));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
// THE SOFTWARE.
package com.microsoft.aad.adal;


import androidx.test.filters.SmallTest;

import junit.framework.TestCase;
Expand All @@ -38,24 +37,19 @@ public class ADFSWebFingerValidatorTests extends TestCase {
@SmallTest
public void testTrustedRealmFieldInitialized()
throws NoSuchFieldException, IllegalAccessException {
final Field trustedRealmURI = ADFSWebFingerValidator.class.getDeclaredField("TRUSTED_REALM_REL");
final Field trustedRealmURI =
ADFSWebFingerValidator.class.getDeclaredField("TRUSTED_REALM_REL");
trustedRealmURI.setAccessible(true);
assertEquals(
trustedRealmURI.get(null).toString(),
"http://schemas.microsoft.com/rel/trusted-realm"
);
"http://schemas.microsoft.com/rel/trusted-realm");
}

@SmallTest
public void testRealmIsTrustedEmptyMetadata() throws URISyntaxException {
final URI testAuthority = new URI("https://fs.ngctest.nttest.microsoft.com/adfs/ls/");
final WebFingerMetadata metadata = new WebFingerMetadata();
assertFalse(
ADFSWebFingerValidator.realmIsTrusted(
testAuthority,
metadata
)
);
assertFalse(ADFSWebFingerValidator.realmIsTrusted(testAuthority, metadata));
}

public void testRealmIsTrusted() throws URISyntaxException {
Expand All @@ -71,11 +65,6 @@ public void testRealmIsTrusted() throws URISyntaxException {

metadata.setLinks(links);

assertTrue(
ADFSWebFingerValidator.realmIsTrusted(
testAuthority,
metadata
)
);
assertTrue(ADFSWebFingerValidator.realmIsTrusted(testAuthority, metadata));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
// THE SOFTWARE.
package com.microsoft.aad.adal;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import com.microsoft.identity.common.adal.internal.util.StringExtensions;

import org.junit.Test;
Expand All @@ -31,10 +35,6 @@
import java.util.HashMap;
import java.util.Map;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public final class APIEventTest {

@Test
Expand Down
Loading