From 1aa7be600605baa687919ea80594b144b39f16e8 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Tue, 20 Dec 2022 16:20:56 +0100 Subject: [PATCH 1/5] version bump --- box.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/box.json b/box.json index 8a90095..355c10f 100644 --- a/box.json +++ b/box.json @@ -1,6 +1,6 @@ { "name":"ColdBox Mail Services", - "version":"2.6.2", + "version":"2.7.0", "location":"https://downloads.ortussolutions.com/ortussolutions/coldbox-modules/cbmailservices/@build.version@/cbmailservices-@build.version@.zip", "author":"Ortus Solutions.com Date: Mon, 16 Jan 2023 10:04:06 +0000 Subject: [PATCH 2/5] Mailgun EU Region Domains (#32) * Added test for MAILGUN_BASEURL property * FIXED var scoping of attachments variable * Updated to make MAILGUN_APIURL optional Added support for Mailgun EU region by making MAILGUN_APIURL an optional property with https://api.mailgun.net/v3/ as the default. * Updated to handle a response that is not JSON Mailgun returns only "Forbidden" when the wrong Base URL region is used. --- .env.template | 1 + models/protocols/MailgunProtocol.cfc | 23 ++++++++++++++++--- .../specs/protocols/MailgunProtocolTest.cfc | 9 +++++--- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/.env.template b/.env.template index 8efb626..3b277e9 100644 --- a/.env.template +++ b/.env.template @@ -1,3 +1,4 @@ POSTMARK_API_KEY= MAILGUN_API_KEY= MAILGUN_DOMAIN= +MAILGUN_BASEURL= diff --git a/models/protocols/MailgunProtocol.cfc b/models/protocols/MailgunProtocol.cfc index bfe927a..e8d384f 100755 --- a/models/protocols/MailgunProtocol.cfc +++ b/models/protocols/MailgunProtocol.cfc @@ -8,6 +8,9 @@ * - apikey : The mailgun secret api key * - domain : The mailgun domain to send the email through * + * An optional property, "baseURL" is required when using an EU region + * - baseURL : The mailgun region where the Mailgun domain was created + * * @author Scott Steinbeck */ component @@ -24,7 +27,6 @@ component MailgunProtocol function init( struct properties = {} ){ variables.name = "Mailgun"; variables.DEFAULT_TIMEOUT = 30; // in seconds - variables.MAILGUN_APIURL = "https://api.mailgun.net/v3/"; // super size it super.init( argumentCollection = arguments ); @@ -40,6 +42,14 @@ component throw( message = "ApiKey is Required", type = "MailgunProtocol.PropertyNotFound" ); } + // Check for Base URL property + if ( !propertyExists( "baseURL" ) ) { + // No baseURL key was found, so use the US default. + variables.MAILGUN_APIURL = "https://api.mailgun.net/v3/"; + } else { + variables.MAILGUN_APIURL = getProperty( "baseURL" ); + } + return this; } @@ -101,7 +111,7 @@ component data.delete( "bodyTokens" ); // cleanup payload // Process the mail attachments and encode them how mailgun likes them - attachments = arguments.payload + var attachments = arguments.payload .getMailParams() .filter( function( thisParam ){ return structKeyExists( arguments.thisParam, "file" ); @@ -185,7 +195,14 @@ component } // Inflate HTTP Results - var mailgunResults = deserializeJSON( httpResults.fileContent.toString() ); + if( isJSON( httpResults.fileContent.toString() ) ) { + var mailgunResults = deserializeJSON( httpResults.fileContent.toString() ); + } else { + results.messages = [ 'Error sending mail. Mailgun returned "#httpResults.fileContent.toString()#".' ]; + + return results; + } + // Process Mailgun Results if ( mailgunResults.message eq "Queued. Thank you." ) { results.error = false; diff --git a/test-harness/tests/specs/protocols/MailgunProtocolTest.cfc b/test-harness/tests/specs/protocols/MailgunProtocolTest.cfc index fcdfa58..abb8851 100755 --- a/test-harness/tests/specs/protocols/MailgunProtocolTest.cfc +++ b/test-harness/tests/specs/protocols/MailgunProtocolTest.cfc @@ -14,6 +14,7 @@ component extends="coldbox.system.testing.BaseTestCase" { variables.mailservice = getInstance( "MailService@cbmailservices" ); variables.apikey = getUtil().getSystemSetting( "MAILGUN_API_KEY", "MAILGUN_API_KEY" ); variables.domain = getUtil().getSystemSetting( "MAILGUN_DOMAIN", "MAILGUN_DOMAIN" ); + variables.baseURL = getUtil().getSystemSetting( "MAILGUN_BASEURL", "MAILGUN_BASEURL" ); } /*********************************** BDD SUITES ***********************************/ @@ -23,15 +24,17 @@ component extends="coldbox.system.testing.BaseTestCase" { describe( "Mailgun Protocol", function(){ beforeEach( function( currentSpec ){ // Create a mock instance of the protocol. - variables.protocol = createMock( "cbmailservices.models.protocols.MailgunProtocol" ).init( { - apiKey : variables.apikey, - domain : variables.domain + variables.protocol = createMock( "cbmailservices.models.protocols.MailgunProtocol" ).init( { + apiKey : variables.apikey, + domain : variables.domain, + baseURL : variables.baseURL } ); } ); it( "can be inited correctly", function(){ expect( variables.protocol.propertyExists( "apiKey" ) ).toBeTrue(); expect( variables.protocol.propertyExists( "domain" ) ).toBeTrue(); + expect( variables.protocol.propertyExists( "baseURL" ) ).toBeTrue(); } ); it( "data is formatted for sending to mailgun", function(){ From 23d6458eaa092fa2f9ee590161ffa2072a4354e1 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Mon, 16 Jan 2023 11:10:52 +0100 Subject: [PATCH 3/5] Updated all gha according to new standards thanks to @michaelborn and @jclausen --- .github/workflows/ci.yml | 8 ++++---- .github/workflows/gh-release.yml | 4 ++-- .github/workflows/pr.yml | 2 +- .github/workflows/tests.yml | 14 +++++++------- changelog.md | 20 ++++++++++++++++++++ 5 files changed, 34 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 32ca60b..e70c7ff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,14 +28,14 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout Repository - uses: actions/checkout@v2 + uses: actions/checkout@v3.2.0 with: fetch-depth: 0 - name: Setup Java - uses: actions/setup-java@v2 + uses: actions/setup-java@v3.9.0 with: - distribution: "adopt" + distribution: "temurin" java-version: "11" - name: Cache CommandBox Dependencies @@ -72,7 +72,7 @@ jobs: - name: Upload Build Artifacts if: success() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3.1.1 with: name: ${{ env.MODULE_ID }} path: | diff --git a/.github/workflows/gh-release.yml b/.github/workflows/gh-release.yml index 5193ae5..3de37b9 100644 --- a/.github/workflows/gh-release.yml +++ b/.github/workflows/gh-release.yml @@ -10,8 +10,8 @@ jobs: create-release: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: taiki-e/create-gh-release-action@v1.5.0 + - uses: actions/checkout@v3.2.0 + - uses: taiki-e/create-gh-release-action@v1.6.1 with: # Produced by the build/Build.cfc changelog: changelog.md diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index ead8984..114a833 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout Repository - uses: actions/checkout@v2 + uses: actions/checkout@v3.2.0 - uses: Ortus-Solutions/commandbox-action@v1.0.2 with: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d5df3d8..784177e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,12 +20,12 @@ jobs: cfengine: [ "lucee@5", "adobe@2018", "adobe@2021" ] steps: - name: Checkout Repository - uses: actions/checkout@v2 + uses: actions/checkout@v3.2.0 - name: Setup Java - uses: actions/setup-java@v2 + uses: actions/setup-java@v3.9.0 with: - distribution: "adopt" + distribution: "temurin" java-version: "11" - name: Setup CommandBox CLI @@ -67,15 +67,15 @@ jobs: box testbox run --verbose outputFile=test-harness/tests/results/test-results outputFormats=json,antjunit - name: Publish Test Results - uses: EnricoMi/publish-unit-test-result-action@v1 + uses: EnricoMi/publish-unit-test-result-action@v2 if: always() with: - files: test-harness/tests/results/**/*.xml + junit_files: test-harness/tests/results/**/*.xml check_name: "${{ matrix.cfengine }} Test Results" - name: Upload Test Results to Artifacts if: always() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3.1.1 with: name: test-results-${{ matrix.cfengine }} path: | @@ -90,7 +90,7 @@ jobs: - name: Upload Debug Logs To Artifacts if: ${{ failure() }} - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3.1.1 with: name: Failure Debugging Info - ${{ matrix.cfengine }} path: | diff --git a/changelog.md b/changelog.md index e5a562d..b01f473 100644 --- a/changelog.md +++ b/changelog.md @@ -8,6 +8,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ---- +## [v2.7.0] => 2023-JAN-16 + +A big thanks to @richardherbert for all the updates in this release. + +### Fixed + +* FIXED var scoping of attachments variable +* Updated to handle a response that is not JSON +* 🐛 FIX: Update GHA to avoid deprecated syntax + +### Added + +* Added test for MAILGUN_BASEURL property +* Updated to make MAILGUN_APIURL optional +* Added support for Mailgun EU region by making MAILGUN_APIURL an optional property with https://api.mailgun.net/v3/ as the default. + + +---- + + ## [v2.6.2] => 2022-DEC-20 ### Fixed From 30b3333e5028f769aba2ff568e42ef28bd833dbf Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Mon, 16 Jan 2023 11:14:12 +0100 Subject: [PATCH 4/5] more gha action updates --- .github/workflows/ci.yml | 2 +- .github/workflows/tests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e70c7ff..b06d8c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: java-version: "11" - name: Cache CommandBox Dependencies - uses: actions/cache@v1 + uses: actions/cache@v3 if: ${{ true }} with: path: ~/.CommandBox/artifacts diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 784177e..b5cd2fd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -32,7 +32,7 @@ jobs: uses: Ortus-Solutions/setup-commandbox@v2.0.1 - name: Cache CommandBox Dependencies - uses: actions/cache@v1 + uses: actions/cache@v3 if: ${{ true }} with: path: ~/.CommandBox/artifacts From b53fcb720f673b3b5558313ecd5852e1b9e1cffe Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Mon, 16 Jan 2023 11:16:12 +0100 Subject: [PATCH 5/5] updated changelog --- changelog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/changelog.md b/changelog.md index b01f473..bf7e724 100644 --- a/changelog.md +++ b/changelog.md @@ -24,6 +24,9 @@ A big thanks to @richardherbert for all the updates in this release. * Updated to make MAILGUN_APIURL optional * Added support for Mailgun EU region by making MAILGUN_APIURL an optional property with https://api.mailgun.net/v3/ as the default. +### Changed + +* Updated all GHA actions to latest versions and moved to use `temurin` Java distributions from adopt due to deprecation of the service. ----