Skip to content

Commit

Permalink
Gradle update, remove eu.codearte.catch-exception
Browse files Browse the repository at this point in the history
  • Loading branch information
regdos committed Apr 4, 2024
1 parent 37cb9b6 commit 1d5f083
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 11
java-version: 17
- name: Get app version
id: app_version
run: echo "APP_VERSION=$(./gradlew version --no-daemon --console=plain -q | tail -n 1)" >> $GITHUB_OUTPUT
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 11
java-version: 17
- name: Run test
run: ./gradlew test
- name: Run build
Expand Down
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath 'com.android.tools.build:gradle:8.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.33.12"
Expand Down Expand Up @@ -63,7 +63,6 @@ project.ext {
assertJsVersion = "3.24.2"
assertJGuavaVersion = "3.24.2"
mockitoVersion = "5.8.0"
catchException2Version = "1.4.6"
}

project.ext {
Expand Down
6 changes: 4 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
# The setting is particularly useful for tweaking memory settings.
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx4608m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Xmx4608m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
android.jetifier.ignorelist=bcprov-jdk15on
-Xjvm-default=enable
android.disableAutomaticComponentCreation=true
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Oct 15 22:38:33 CEST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
1 change: 0 additions & 1 deletion payment-add-card-module/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ dependencies {
api project(path:':payment-library-api-client')

testImplementation "org.assertj:assertj-core:$project.assertJsVersion"
testImplementation "eu.codearte.catch-exception:catch-exception:$project.catchException2Version"
testImplementation "org.mockito:mockito-core:$project.mockitoVersion"
testImplementation "org.robolectric:robolectric:$project.robolectricVersion"
testImplementation "junit:junit:$project.junitVersion"
Expand Down
1 change: 0 additions & 1 deletion payment-library-api-client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ dependencies {
api "com.squareup.okhttp3:logging-interceptor:$project.okhttpLogInterceptorVersion"

testImplementation "org.mockito:mockito-core:$project.mockitoVersion"
testImplementation "eu.codearte.catch-exception:catch-exception:$project.catchException2Version"
testImplementation "org.assertj:assertj-core:$project.assertJsVersion"
testImplementation "junit:junit:$project.junitVersion"
testImplementation "org.robolectric:robolectric:$project.robolectricVersion"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.payu.android.front.sdk.payment_library_api_client.internal.rest.client.ssl;

import static com.google.common.collect.Lists.newArrayList;
import static com.googlecode.catchexception.CatchException.catchException;
import static com.googlecode.catchexception.CatchException.caughtException;
import static com.googlecode.catchexception.CatchException.resetCaughtException;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatNoException;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.openMocks;
import static java.util.Arrays.asList;
Expand Down Expand Up @@ -59,15 +57,12 @@ public void shouldAcceptTrustedCertificateThatMatchesFirstCertificateInChain() t
fakeCertificates.add(new SslCertificate(knownPublicKeyHash, serialNumber));
objectUnderTest = new AndroidAndProvidedCertificateListVerifier(trustManagerMock, fakeCertificates);

// when
objectUnderTest.checkServerTrusted(asList(certificateMock, caCertificateMock).toArray(new X509Certificate[2]), null);

// then
assertThat((Throwable) caughtException()).isNull();
// when + then
assertThatNoException().isThrownBy(() -> objectUnderTest.checkServerTrusted(asList(certificateMock, caCertificateMock).toArray(new X509Certificate[2]), null));
}

@Test
public void shouldAcceptTrustedCertificateThatMatchesSecondCertificateInChain() throws CertificateException {
public void shouldAcceptTrustedCertificateThatMatchesSecondCertificateInChain() {
// given
String knownPublicKeyHash = "knownPublicKeyHash";
String serialNumber = "36122296c5e338a520a1d25f4cd70954";
Expand All @@ -76,21 +71,15 @@ public void shouldAcceptTrustedCertificateThatMatchesSecondCertificateInChain()
fakeCertificates.add(new SslCertificate(knownPublicKeyHash, serialNumber));
objectUnderTest = new AndroidAndProvidedCertificateListVerifier(trustManagerMock, fakeCertificates);

// when
objectUnderTest.checkServerTrusted(asList(certificateMock, caCertificateMock).toArray(new X509Certificate[2]), null);

// then
assertThat((Throwable) caughtException()).isNull();
// when + then
assertThatNoException().isThrownBy(() -> objectUnderTest.checkServerTrusted(asList(certificateMock, caCertificateMock).toArray(new X509Certificate[2]), null));
}


@Test
public void shouldCheckClientPositivelyWithAndroidVerifier() throws CertificateException {
// when
catchException(objectUnderTest).checkClientTrusted(null, null);

// then
assertThat((Throwable) caughtException()).isNull();
public void shouldCheckClientPositivelyWithAndroidVerifier() {
// when + then
assertThatNoException().isThrownBy(() -> objectUnderTest.checkClientTrusted(null, null));
}

@Test
Expand All @@ -106,43 +95,29 @@ public void shouldGetNullIssuersIfAndroidTrustManagerIsNotSet() {
}

@Test
public void shouldNotThrowCertificateExceptionIfAndroidVerifierIsNotAvailable() throws CertificateException {
public void shouldNotThrowCertificateExceptionIfAndroidVerifierIsNotAvailable() {
// given
objectUnderTest = new AndroidAndProvidedCertificateListVerifier(null, fakeCertificates);

// when
catchException(objectUnderTest).checkClientTrusted(null, null);

// then
assertThat((Throwable) caughtException()).isNull();
// when + then
assertThatNoException().isThrownBy(() -> objectUnderTest.checkClientTrusted(null, null));
}

@Test
@Test(expected = CertificateException.class)
public void shouldRejectUntrustedCertificatesIfNoCertificatesConfigured() throws CertificateException {
// when
catchException(objectUnderTest).checkServerTrusted(asList(certificateMock, caCertificateMock).toArray(new
objectUnderTest.checkServerTrusted(asList(certificateMock, caCertificateMock).toArray(new
X509Certificate[2]), null);

// then
assertThat((Throwable) caughtException()).isInstanceOf(CertificateException.class);
}

@Test
@Test(expected = CertificateException.class)
public void shouldRejectUntrustedCertificatesIfUnknownCertificatesConfigured() throws CertificateException {
// given
fakeCertificates.add(new SslCertificate("anypublickeyhash", "serialnumber"));

// when
catchException(objectUnderTest).checkServerTrusted(asList(certificateMock, caCertificateMock).toArray(new
objectUnderTest.checkServerTrusted(asList(certificateMock, caCertificateMock).toArray(new
X509Certificate[2]), null);

// then
assertThat((Throwable) caughtException()).isInstanceOf(CertificateException.class);
}

@After
public void tearDown() {
resetCaughtException();
}

private void configureCertificateAndPublicKeyMocks(String firstCertificateSerialNumber, String knownPublicKeyHash,
Expand Down
1 change: 0 additions & 1 deletion payment-library-webview-module/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ dependencies {
testImplementation "org.robolectric:robolectric:$project.robolectricVersion"

testImplementation "org.mockito:mockito-core:$project.mockitoVersion"
testImplementation "eu.codearte.catch-exception:catch-exception:$project.catchException2Version"
testImplementation "org.assertj:assertj-core:$project.assertJsVersion"

androidTestImplementation "androidx.test.ext:junit:$project.junitAssertionsVersion"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.payu.android.front.sdk.payment_library_webview_module.web.authorization.client;

import static com.googlecode.catchexception.CatchException.catchException;
import static com.googlecode.catchexception.CatchException.caughtException;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatNoException;
import static org.mockito.Mockito.verify;

import android.view.View;
Expand Down Expand Up @@ -45,11 +43,8 @@ public void shouldReactForLostViewReference() {
// given
objectUnderTest = new WebAuthorizationViewChromeClient(null);

// when
catchException(objectUnderTest).onProgressChanged(null, 64);

// then
assertThat((Throwable) caughtException()).isNull();
// when + then
assertThatNoException().isThrownBy(() -> objectUnderTest.onProgressChanged(null, 64));
}

@Test
Expand All @@ -75,4 +70,4 @@ public void shouldShouldHideProgressWhenFinished() {
// then
verify(progressBar).setVisibility(View.GONE);
}
}
}

0 comments on commit 1d5f083

Please sign in to comment.