From 2ab7f2469d52d4e31de4d6a645499f75c7669d21 Mon Sep 17 00:00:00 2001 From: shayaantx <5449086+shayaantx@users.noreply.github.com> Date: Tue, 19 Dec 2023 20:47:23 -0500 Subject: [PATCH] Fix broken test case (#116) * Fix broken test case & Fix github action checking out development instead of PR branch * Switch to v3 checkout and custom ref * More actions updates --- .github/workflows/development-branch.yml | 2 -- .github/workflows/pull-request.yml | 7 ++++--- .../utilities/Log4jSensitiveDataPatternTests.java | 15 ++++++++++++++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/workflows/development-branch.yml b/.github/workflows/development-branch.yml index 6bf09b2..ff6174d 100644 --- a/.github/workflows/development-branch.yml +++ b/.github/workflows/development-branch.yml @@ -27,8 +27,6 @@ jobs: echo "Building $VERSION" - name: Build run: mvn --no-transfer-progress compile - - name: Test - run: mvn --no-transfer-progress test - name: Package run: mvn --no-transfer-progress package -DskipTests - name: Create Github Release diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 95bd565..c9f9fa0 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -2,14 +2,15 @@ name: pull-request on: pull_request_target: types: [opened, synchronize, reopened] - branches: - - 'development' + jobs: test: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Setup java uses: actions/setup-java@v1 with: diff --git a/src/test/java/com/botdarr/utilities/Log4jSensitiveDataPatternTests.java b/src/test/java/com/botdarr/utilities/Log4jSensitiveDataPatternTests.java index 4300cc0..d05cbc7 100644 --- a/src/test/java/com/botdarr/utilities/Log4jSensitiveDataPatternTests.java +++ b/src/test/java/com/botdarr/utilities/Log4jSensitiveDataPatternTests.java @@ -31,7 +31,20 @@ public void format_apiKeyInString_noMaskedText() { }}; patternConverter.format(mockedEvent, output); //input should remain unchanged - Assert.assertEquals("http://localhost?apiKey=****", output.toString()); + Assert.assertEquals("http://localhost?****", output.toString()); + } + + @Test + public void format_access_tokenInString_noMaskedText() { + String input = "http://localhost?access_token=fdskjkjfd"; + LogEventPatternConverter patternConverter = new Log4jSensitiveDataPattern("test", "style"); + StringBuilder output = new StringBuilder(); + new Expectations() {{ + mockedEvent.getMessage().getFormattedMessage(); result = input; + }}; + patternConverter.format(mockedEvent, output); + //input should remain unchanged + Assert.assertEquals("http://localhost?****", output.toString()); } @Mocked