From b1a6600f3fcede8ec6af059bb9323d4cc6cce686 Mon Sep 17 00:00:00 2001 From: Daniel Steuernol Date: Fri, 11 Dec 2020 11:28:33 -0800 Subject: [PATCH 1/9] Adding a test for localizations --- .../dyspatch/client/api/IntegrationTest.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/test/java/io/dyspatch/client/api/IntegrationTest.java b/src/test/java/io/dyspatch/client/api/IntegrationTest.java index c9f0053..0a24003 100644 --- a/src/test/java/io/dyspatch/client/api/IntegrationTest.java +++ b/src/test/java/io/dyspatch/client/api/IntegrationTest.java @@ -7,6 +7,7 @@ import io.dyspatch.client.api.DraftsApi; import io.dyspatch.client.api.TemplatesApi; +import io.dyspatch.client.model.InlineObject; import org.junit.Test; /** @@ -14,7 +15,7 @@ * THESE ARE HAND BUILT AND NOT GENERATED, DO NOT DELETE */ public class IntegrationTest { - String version = "application/vnd.dyspatch.2020.04+json"; + String version = "application/vnd.dyspatch.2020.11+json"; ApiClient client; DraftsApi drafts; TemplatesApi templates; @@ -22,6 +23,10 @@ public class IntegrationTest { public IntegrationTest() { client = Configuration.getDefaultApiClient(); + String basePath = System.getenv("DYSPATCH_BASE_PATH"); + if (basePath.length() > 0) { + client.setBasePath(basePath); + } client.setApiKey(System.getenv("DYSPATCH_API_KEY")); client.setApiKeyPrefix("Bearer"); @@ -33,7 +38,7 @@ public IntegrationTest() { public void getTemplates() throws ApiException { templates.getTemplates(version, ""); - String templateId = "tem_01de5teh6k59kya8q92mb01qzq"; + String templateId = System.getenv("templateId"); templates.getTemplateById(templateId, "handlebars", version); } @@ -41,7 +46,15 @@ public void getTemplates() throws ApiException { public void getDrafts() throws ApiException { drafts.getDrafts(version, "", ""); - String draftId = "tdft_01dxkwr0nevs5h2baa3n3dgktp"; + String draftId = System.getenv("draftId"); drafts.getDraftById(draftId, "handlebars", version); } + + @Test + public void localizations() throws ApiException { + String draftId = System.getenv("draftId"); + InlineObject io = new InlineObject(); + io.name("moonbeam"); + drafts.saveLocalization(draftId, "en-CA", version, io); + } } From 98e7f983958b4473f654ec49349573a25292d639 Mon Sep 17 00:00:00 2001 From: Daniel Steuernol Date: Fri, 11 Dec 2020 11:37:54 -0800 Subject: [PATCH 2/9] update github action --- .github/workflows/ci.yml | 3 +++ src/test/java/io/dyspatch/client/api/IntegrationTest.java | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ca96f96..6fd5ab2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,3 +41,6 @@ jobs: run: ./gradlew build env: DYSPATCH_API_KEY: ${{ secrets.DYSPATCH_API_KEY }} + with: + template_id: ${{ steps.vars.outputs.templateId }} + draft_id: ${{ steps.vars.outputs.draftId }} diff --git a/src/test/java/io/dyspatch/client/api/IntegrationTest.java b/src/test/java/io/dyspatch/client/api/IntegrationTest.java index 0a24003..c30dac6 100644 --- a/src/test/java/io/dyspatch/client/api/IntegrationTest.java +++ b/src/test/java/io/dyspatch/client/api/IntegrationTest.java @@ -38,7 +38,7 @@ public IntegrationTest() { public void getTemplates() throws ApiException { templates.getTemplates(version, ""); - String templateId = System.getenv("templateId"); + String templateId = System.getenv("INPUT_TEMPLATE_ID"); templates.getTemplateById(templateId, "handlebars", version); } @@ -46,13 +46,13 @@ public void getTemplates() throws ApiException { public void getDrafts() throws ApiException { drafts.getDrafts(version, "", ""); - String draftId = System.getenv("draftId"); + String draftId = System.getenv("INPUT_DRAFT_ID"); drafts.getDraftById(draftId, "handlebars", version); } @Test public void localizations() throws ApiException { - String draftId = System.getenv("draftId"); + String draftId = System.getenv("INPUT_DRAFT_ID"); InlineObject io = new InlineObject(); io.name("moonbeam"); drafts.saveLocalization(draftId, "en-CA", version, io); From 5c7c19fc9d23c3eb9002e3820864ca81b049fc26 Mon Sep 17 00:00:00 2001 From: Daniel Steuernol Date: Fri, 11 Dec 2020 11:41:08 -0800 Subject: [PATCH 3/9] test using env vars --- .github/workflows/ci.yml | 5 ++--- src/test/java/io/dyspatch/client/api/IntegrationTest.java | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6fd5ab2..e040c39 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,6 +41,5 @@ jobs: run: ./gradlew build env: DYSPATCH_API_KEY: ${{ secrets.DYSPATCH_API_KEY }} - with: - template_id: ${{ steps.vars.outputs.templateId }} - draft_id: ${{ steps.vars.outputs.draftId }} + DYSPATCH_TEMPLATE_ID: ${{ steps.vars.outputs.templateId }} + DYSPATCH_DRAFT_ID: ${{ steps.vars.outputs.draftId }} diff --git a/src/test/java/io/dyspatch/client/api/IntegrationTest.java b/src/test/java/io/dyspatch/client/api/IntegrationTest.java index c30dac6..ae77d95 100644 --- a/src/test/java/io/dyspatch/client/api/IntegrationTest.java +++ b/src/test/java/io/dyspatch/client/api/IntegrationTest.java @@ -38,7 +38,7 @@ public IntegrationTest() { public void getTemplates() throws ApiException { templates.getTemplates(version, ""); - String templateId = System.getenv("INPUT_TEMPLATE_ID"); + String templateId = System.getenv("DYSPATCH_TEMPLATE_ID"); templates.getTemplateById(templateId, "handlebars", version); } @@ -46,13 +46,13 @@ public void getTemplates() throws ApiException { public void getDrafts() throws ApiException { drafts.getDrafts(version, "", ""); - String draftId = System.getenv("INPUT_DRAFT_ID"); + String draftId = System.getenv("DYSPATCH_DRAFT_ID"); drafts.getDraftById(draftId, "handlebars", version); } @Test public void localizations() throws ApiException { - String draftId = System.getenv("INPUT_DRAFT_ID"); + String draftId = System.getenv("DYSPATCH_DRAFT_ID"); InlineObject io = new InlineObject(); io.name("moonbeam"); drafts.saveLocalization(draftId, "en-CA", version, io); From 3356dc9fbb0696ed6b6ccc5f9812ca32e658a56b Mon Sep 17 00:00:00 2001 From: Daniel Steuernol Date: Fri, 11 Dec 2020 12:07:03 -0800 Subject: [PATCH 4/9] verifying outputs --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e040c39..398a534 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,6 +37,9 @@ jobs: with: java-version: 13 + - name: Verify Outputs + run: "echo ${{ steps.vars.outputs.templateId }} + - name: Build with Gradle run: ./gradlew build env: From 3d7d336d49cef19b5b79fc0af3e32a07ea7ca8d3 Mon Sep 17 00:00:00 2001 From: Daniel Steuernol Date: Fri, 11 Dec 2020 12:14:09 -0800 Subject: [PATCH 5/9] close string --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 398a534..54f2146 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,8 +38,8 @@ jobs: java-version: 13 - name: Verify Outputs - run: "echo ${{ steps.vars.outputs.templateId }} - + run: "echo ${{ steps.vars.outputs.templateId }}" + - name: Build with Gradle run: ./gradlew build env: From 50734c93bdadca4373f6116e0e5c06193f1f5dbc Mon Sep 17 00:00:00 2001 From: Daniel Steuernol Date: Fri, 11 Dec 2020 12:32:12 -0800 Subject: [PATCH 6/9] adjust output param syntax --- .github/workflows/ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 54f2146..3c47011 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,6 +19,7 @@ jobs: token: ${{ secrets.MACHINES_SWU_TOKEN }} ref: master - name: Run api setup action + id: setup_action uses: ./ with: email: ${{ secrets.QA_USERNAME }} @@ -38,11 +39,11 @@ jobs: java-version: 13 - name: Verify Outputs - run: "echo ${{ steps.vars.outputs.templateId }}" + run: "echo templateId:${{ steps.setup_action.outputs.templateId }}" - name: Build with Gradle run: ./gradlew build env: DYSPATCH_API_KEY: ${{ secrets.DYSPATCH_API_KEY }} - DYSPATCH_TEMPLATE_ID: ${{ steps.vars.outputs.templateId }} - DYSPATCH_DRAFT_ID: ${{ steps.vars.outputs.draftId }} + DYSPATCH_TEMPLATE_ID: ${{ steps.setup_action.outputs.templateId }} + DYSPATCH_DRAFT_ID: ${{ steps.setup_action.outputs.draftId }} From b37e33b1386efa1571aef0c5c0e5ed3c43af67d9 Mon Sep 17 00:00:00 2001 From: Daniel Steuernol Date: Fri, 11 Dec 2020 12:34:46 -0800 Subject: [PATCH 7/9] protect against NPE --- src/test/java/io/dyspatch/client/api/IntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/io/dyspatch/client/api/IntegrationTest.java b/src/test/java/io/dyspatch/client/api/IntegrationTest.java index ae77d95..f62d6ed 100644 --- a/src/test/java/io/dyspatch/client/api/IntegrationTest.java +++ b/src/test/java/io/dyspatch/client/api/IntegrationTest.java @@ -24,7 +24,7 @@ public class IntegrationTest { public IntegrationTest() { client = Configuration.getDefaultApiClient(); String basePath = System.getenv("DYSPATCH_BASE_PATH"); - if (basePath.length() > 0) { + if (basePath != null && basePath.length() > 0) { client.setBasePath(basePath); } client.setApiKey(System.getenv("DYSPATCH_API_KEY")); From 8de3bedfada8b2a9831488c13d5f11c7fc19cc6e Mon Sep 17 00:00:00 2001 From: Daniel Steuernol Date: Fri, 11 Dec 2020 13:36:43 -0800 Subject: [PATCH 8/9] more tests over localizations --- .github/workflows/ci.yml | 5 +--- build.gradle | 19 +++++++------ gradle/wrapper/gradle-wrapper.properties | 5 ++-- .../dyspatch/client/api/IntegrationTest.java | 28 ++++++++++++++++--- 4 files changed, 38 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3c47011..c190107 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,10 +38,7 @@ jobs: with: java-version: 13 - - name: Verify Outputs - run: "echo templateId:${{ steps.setup_action.outputs.templateId }}" - - - name: Build with Gradle + - name: Build and Test with Gradle run: ./gradlew build env: DYSPATCH_API_KEY: ${{ secrets.DYSPATCH_API_KEY }} diff --git a/build.gradle b/build.gradle index 3152bcd..d21f0b3 100644 --- a/build.gradle +++ b/build.gradle @@ -107,15 +107,16 @@ if(hasProperty('target') && target == 'android') { } dependencies { - compile 'io.swagger:swagger-annotations:1.5.24' - compile "com.google.code.findbugs:jsr305:3.0.2" - compile 'com.squareup.okhttp3:okhttp:4.7.2' - compile 'com.squareup.okhttp3:logging-interceptor:4.7.2' - compile 'com.google.code.gson:gson:2.8.6' - compile 'io.gsonfire:gson-fire:1.8.4' - compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.10' - compile 'javax.annotation:javax.annotation-api:1.3.2' - testCompile 'junit:junit:4.13' + implementation 'io.swagger:swagger-annotations:1.5.24' + implementation "com.google.code.findbugs:jsr305:3.0.2" + implementation 'com.squareup.okhttp3:okhttp:4.7.2' + implementation 'com.squareup.okhttp3:logging-interceptor:4.7.2' + implementation 'com.google.code.gson:gson:2.8.6' + implementation 'io.gsonfire:gson-fire:1.8.4' + implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.10' + implementation 'javax.annotation:javax.annotation-api:1.3.2' + testImplementation 'junit:junit:4.13' + testImplementation 'org.hamcrest:hamcrest-library:1.3' } javadoc { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9492014..a6e70ba 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Fri Dec 11 12:53:21 PST 2020 +distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME diff --git a/src/test/java/io/dyspatch/client/api/IntegrationTest.java b/src/test/java/io/dyspatch/client/api/IntegrationTest.java index f62d6ed..4c35f1c 100644 --- a/src/test/java/io/dyspatch/client/api/IntegrationTest.java +++ b/src/test/java/io/dyspatch/client/api/IntegrationTest.java @@ -3,12 +3,16 @@ import io.dyspatch.client.ApiClient; import io.dyspatch.client.ApiException; import io.dyspatch.client.Configuration; -import io.dyspatch.client.auth.*; -import io.dyspatch.client.api.DraftsApi; -import io.dyspatch.client.api.TemplatesApi; - +import io.dyspatch.client.auth.ApiKeyAuth; import io.dyspatch.client.model.InlineObject; +import io.dyspatch.client.model.LocalizationKeyRead; +import io.dyspatch.client.model.LocalizationMetaRead; import org.junit.Test; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; + +import java.util.HashMap; +import java.util.List; /** * Integration tests. @@ -56,5 +60,21 @@ public void localizations() throws ApiException { InlineObject io = new InlineObject(); io.name("moonbeam"); drafts.saveLocalization(draftId, "en-CA", version, io); + List localizations = drafts.getLocalizationForDraft(draftId, version); + assertThat(localizations, hasSize(1)); + assertThat(localizations.get(0).getName(), equalTo("moonbeam")); + + HashMap values = new HashMap<>(); + values.put("test", "value"); + drafts.setTranslation(draftId, "en-CA", version, values); + + List keys = drafts.getDraftLocalizationKeys(draftId, version); + assertThat(keys, hasSize(0)); + + drafts.deleteLocalization(draftId, "en-CA", version); + localizations = drafts.getLocalizationForDraft(draftId, version); + assertThat(localizations, hasSize(0)); + + drafts.submitDraftForApproval(draftId, version); } } From 57a5e0f661009d0fe1542cbabd866c4b4324f170 Mon Sep 17 00:00:00 2001 From: Daniel Steuernol Date: Fri, 11 Dec 2020 13:39:22 -0800 Subject: [PATCH 9/9] update for vulnerability --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index d21f0b3..5b8abfe 100644 --- a/build.gradle +++ b/build.gradle @@ -115,7 +115,7 @@ dependencies { implementation 'io.gsonfire:gson-fire:1.8.4' implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.10' implementation 'javax.annotation:javax.annotation-api:1.3.2' - testImplementation 'junit:junit:4.13' + testImplementation 'junit:junit:4.13.1' testImplementation 'org.hamcrest:hamcrest-library:1.3' }