diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml
index 5153fd3..5b9b41f 100644
--- a/.github/workflows/e2e.yml
+++ b/.github/workflows/e2e.yml
@@ -55,12 +55,14 @@ jobs:
secrets: |-
ZENDESK_EMAIL:cdapio-github-builds/ZENDESK_EMAIL
ZENDESK_API_TOKEN:cdapio-github-builds/ZENDESK_API_TOKEN
+ ZENDESK_PASSWORD:cdapio-github-builds/ZENDESK_PASSWORD
- name: Run tests
run: python3 e2e/src/main/scripts/run_e2e_test.py
env:
ZENDESK_EMAIL: ${{ steps.secrets.outputs.ZENDESK_EMAIL }}
ZENDESK_API_TOKEN: ${{ steps.secrets.outputs.ZENDESK_API_TOKEN }}
+ ZENDESK_PASSWORD: ${{ steps.secrets.outputs.ZENDESK_PASSWORD }}
- name: Upload report
uses: actions/upload-artifact@v3
diff --git a/pom.xml b/pom.xml
index 2f8609c..6a0329e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -572,6 +572,9 @@
${ZENDESK_API_TOKEN}
+
+ ${ZENDESK_PASSWORD}
+
@@ -631,9 +634,16 @@
io.cdap.tests.e2e
cdap-e2e-framework
- 0.1.0-SNAPSHOT
+ 0.2.0-SNAPSHOT
test
+
+
+ io.rest-assured
+ rest-assured
+ 5.1.1
+
+
diff --git a/src/e2e-test/features/zendesksource/RunTime.feature b/src/e2e-test/features/zendesksource/RunTime.feature
index 542d935..f220396 100644
--- a/src/e2e-test/features/zendesksource/RunTime.feature
+++ b/src/e2e-test/features/zendesksource/RunTime.feature
@@ -17,7 +17,7 @@
@Regression
Feature: Zendesk Source - Run time scenarios
- @TS-ZD-RNTM-01 @BQ_SINK @FILE_PATH @BQ_SINK_CLEANUP
+ @TS-ZD-RNTM-01 @BQ_SINK @BQ_SINK_CLEANUP @CREATE_GROUP @DELETE_GROUP
Scenario: Verify user should be able to preview and deploy the pipeline when plugin is configured for a Non hierarchical object
When Open Datafusion Project to configure pipeline
And Select plugin: "Zendesk" from the plugins list as: "Source"
@@ -38,6 +38,7 @@ Feature: Zendesk Source - Run time scenarios
And Enter input plugin property: "datasetProject" with value: "datasetprojectId"
And Enter input plugin property: "dataset" with value: "dataset"
And Enter input plugin property: "table" with value: "bqtarget.table"
+ And Replace input plugin property: "serviceFilePath" with value: "file.path"
And Validate "BigQuery" plugin properties
And Close the Plugin Properties page
And Preview and run the pipeline
@@ -52,9 +53,9 @@ Feature: Zendesk Source - Run time scenarios
And Open and capture logs
And Verify the pipeline status is "Succeeded"
And Close the pipeline logs
- Then Validate record created in Sink application for Single object is equal to expected output file "groupsTestOutputFile"
+ Then Validate record created in Sink application for Single object is equal to expected output file
- @TS-ZD-RNTM-02 @BQ_SINK @FILE_PATH @BQ_SINK_CLEANUP
+ @TS-ZD-RNTM-02 @BQ_SINK @BQ_SINK_CLEANUP @CREATE_GROUP @DELETE_GROUP
Scenario: Verify user should be able to preview and deploy the pipeline when plugin is configured for Advanced properties
When Open Datafusion Project to configure pipeline
And Select plugin: "Zendesk" from the plugins list as: "Source"
@@ -91,10 +92,10 @@ Feature: Zendesk Source - Run time scenarios
And Open and capture logs
And Verify the pipeline status is "Succeeded"
And Close the pipeline logs
- Then Validate record created in Sink application for Single object is equal to expected output file "groupsTestOutputFile"
+ Then Validate record created in Sink application for Single object is equal to expected output file
@TS-ZD-RNTM-03
- Scenario: Verify user should be able to preview and deploy and Run the pipeline when plugin is configured for a herarchical object with File Sink
+ Scenario: Verify user should be able to preview and deploy and Run the pipeline when plugin is configured for a hierarchical object with File Sink
When Open Datafusion Project to configure pipeline
And Select plugin: "Zendesk" from the plugins list as: "Source"
And Navigate to the properties page of plugin: "Zendesk"
diff --git a/src/e2e-test/features/zendesksource/RunTimeWithMacros.feature b/src/e2e-test/features/zendesksource/RunTimeWithMacros.feature
index 021d37a..97fbc58 100644
--- a/src/e2e-test/features/zendesksource/RunTimeWithMacros.feature
+++ b/src/e2e-test/features/zendesksource/RunTimeWithMacros.feature
@@ -17,7 +17,7 @@
@Regression
Feature: Zendesk Source - Run time scenarios
- @TS-ZD-RNTM-MACRO-01 @BQ_SINK @BQ_SINK_CLEANUP @FILE_PATH
+ @TS-ZD-RNTM-MACRO-01 @BQ_SINK @BQ_SINK_CLEANUP @CREATE_GROUP @DELETE_GROUP
Scenario: Verify user should be able to preview and deploy the pipeline when plugin is configured for a Non hierarchical Object with macros
When Open Datafusion Project to configure pipeline
And Select plugin: "Zendesk" from the plugins list as: "Source"
@@ -69,9 +69,9 @@ Feature: Zendesk Source - Run time scenarios
And Open and capture logs
And Verify the pipeline status is "Succeeded"
And Close the pipeline logs
- Then Validate record created in Sink application for Single object is equal to expected output file "groupsTestOutputFile"
+ Then Validate record created in Sink application for Single object is equal to expected output file
- @TS-ZD-RNTM-MACRO-02 @BQ_SINK @BQ_SINK_CLEANUP @FILE_PATH
+ @TS-ZD-RNTM-MACRO-02 @BQ_SINK @BQ_SINK_CLEANUP @CREATE_GROUP @DELETE_GROUP
Scenario: Verify user should be able to preview and deploy the pipeline when plugin is configured for Advanced Properties with macros
When Open Datafusion Project to configure pipeline
And Select plugin: "Zendesk" from the plugins list as: "Source"
@@ -116,7 +116,7 @@ Feature: Zendesk Source - Run time scenarios
And Open and capture logs
And Verify the pipeline status is "Succeeded"
And Close the pipeline logs
- Then Validate record created in Sink application for Single object is equal to expected output file "groupsTestOutputFile"
+ Then Validate record created in Sink application for Single object is equal to expected output file
@TS-ZD-RNTM-MACRO-03 @BQ_SINK @BQ_SINK_CLEANUP
Scenario: Verify pipeline failure message in logs when user provides invalid Credentials with Macros
diff --git a/src/e2e-test/java/io/cdap/plugin/tests/hooks/TestSetupHooks.java b/src/e2e-test/java/io/cdap/plugin/tests/hooks/TestSetupHooks.java
index c40f445..5507c3e 100644
--- a/src/e2e-test/java/io/cdap/plugin/tests/hooks/TestSetupHooks.java
+++ b/src/e2e-test/java/io/cdap/plugin/tests/hooks/TestSetupHooks.java
@@ -18,6 +18,7 @@
import com.google.cloud.bigquery.BigQueryException;
import io.cdap.e2e.utils.BigQueryClient;
import io.cdap.e2e.utils.PluginPropertyUtils;
+import io.cdap.plugin.zendesk.actions.DataValidationHelper;
import io.cucumber.java.After;
import io.cucumber.java.Before;
import org.apache.commons.lang3.RandomStringUtils;
@@ -26,12 +27,27 @@
import stepsdesign.BeforeActions;
import java.io.IOException;
import java.nio.file.Paths;
+import java.util.Base64;
/**
* Represents Test Setup and Clean up hooks.
*/
public class TestSetupHooks {
- private static boolean firstFileSinkTestFlag = true;
+ public static String groupResponse = "";
+ public static String credentials = "";
+
+
+ @Before(order = 1, value = "@CREATE_GROUP")
+ public void createGroup() {
+ Base64.Encoder encoder = Base64.getUrlEncoder();
+ String email = System.getenv("ZENDESK_EMAIL");
+ String password = System.getenv("ZENDESK_PASSWORD");
+ String auth = email + ":" + password;
+ String encodedAuth = encoder.encodeToString(auth.getBytes());
+ credentials = "Basic " + encodedAuth;
+ String jsonBody = "{\"group\": {\"name\": \"My Group" + RandomStringUtils.randomAlphanumeric(10) + "\"}}";
+ groupResponse = DataValidationHelper.createGroup(credentials, jsonBody);
+ }
@Before(order = 1, value = "@BQ_SINK")
public void setTempTargetBQDataset() {
@@ -77,19 +93,8 @@ public void deleteMultiSourceTargetBQTable() throws IOException, InterruptedExce
}
}
}
-
- @Before(order = 1, value = "@FILE_PATH")
- public static void setFileAbsolutePath() {
-
- if (firstFileSinkTestFlag) {
- PluginPropertyUtils.addPluginProp("groupsTestOutputFile", Paths.get(TestSetupHooks.class.getResource
- ("/" + PluginPropertyUtils.pluginProp("groupsTestOutputFile")).getPath()).toString());
- PluginPropertyUtils.addPluginProp("multiObjectsOutputFile", Paths.get(TestSetupHooks.class.getResource
- ("/" + PluginPropertyUtils.pluginProp("multiObjectsOutputFile")).getPath()).toString());
- PluginPropertyUtils.addPluginProp("multiObjectsOutputFile1", Paths.get(TestSetupHooks.class.getResource
- ("/" + PluginPropertyUtils.pluginProp("multiObjectsOutputFile1")).getPath()).toString());
-
- firstFileSinkTestFlag = false;
- }
+ @After(order = 2, value = "@DELETE_GROUP")
+ public void deleteGroup() {
+ DataValidationHelper.deleteGroup(credentials);
}
}
diff --git a/src/e2e-test/java/io/cdap/plugin/zendesk/actions/DataValidationHelper.java b/src/e2e-test/java/io/cdap/plugin/zendesk/actions/DataValidationHelper.java
new file mode 100644
index 0000000..b908d33
--- /dev/null
+++ b/src/e2e-test/java/io/cdap/plugin/zendesk/actions/DataValidationHelper.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright © 2022 Cask Data, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package io.cdap.plugin.zendesk.actions;
+
+import io.cdap.e2e.utils.PluginPropertyUtils;
+import io.restassured.http.ContentType;
+import io.restassured.response.Response;
+import io.restassured.response.ResponseBody;
+import static io.restassured.RestAssured.given;
+
+
+/**
+ * Zendesk utility - enhancements.
+ */
+public class DataValidationHelper {
+ private static String baseURI = PluginPropertyUtils.pluginProp("base.URI");
+ public static String createGroup(String cred, String jsonBody) {
+ Response response = given()
+ .header("authorization", cred)
+ .accept(ContentType.JSON)
+ .contentType(ContentType.JSON)
+ .and()
+ .body(jsonBody)
+ .when()
+ .post(baseURI + "/groups.json")
+ .then().extract().response();
+
+ ResponseBody responseBody = response;
+
+ return responseBody.asString();
+ }
+ public static void deleteGroup(String cred) {
+ Response response1 = given()
+ .header("authorization", cred)
+ .delete(baseURI + "/groups/" + ZendeskPropertiesPageActions.uniqueId + ".json");
+ }
+}
diff --git a/src/e2e-test/java/io/cdap/plugin/zendesk/actions/ZendeskPropertiesPageActions.java b/src/e2e-test/java/io/cdap/plugin/zendesk/actions/ZendeskPropertiesPageActions.java
index 3f79b85..00a3249 100644
--- a/src/e2e-test/java/io/cdap/plugin/zendesk/actions/ZendeskPropertiesPageActions.java
+++ b/src/e2e-test/java/io/cdap/plugin/zendesk/actions/ZendeskPropertiesPageActions.java
@@ -26,6 +26,7 @@
import io.cdap.e2e.utils.ElementHelper;
import io.cdap.e2e.utils.PluginPropertyUtils;
import io.cdap.e2e.utils.SeleniumHelper;
+import io.cdap.plugin.tests.hooks.TestSetupHooks;
import io.cdap.plugin.utils.enums.Subdomains;
import io.cdap.plugin.zendesk.locators.ZendeskPropertiesPage;
import org.junit.Assert;
@@ -49,6 +50,8 @@ public class ZendeskPropertiesPageActions {
private static Gson gson = new Gson();
private static List bigQueryrows = new ArrayList<>();
+ public static BigInteger uniqueId;
+
static {
SeleniumHelper.getPropertiesLocators(ZendeskPropertiesPage.class);
}
@@ -91,31 +94,19 @@ public static void selectDropdowWithMultipleOptionsForObjectsToSkip(List
ElementHelper.clickUsingActions(CdfPluginPropertiesLocators.pluginPropertiesPageHeader);
}
- public static void verifyIfRecordCreatedInSinkForSingleObjectIsCorrect(String expectedOutputFile)
+ public static void verifyIfRecordCreatedInSinkForSingleObjectIsCorrect()
throws IOException, InterruptedException {
- List expectedOutput = new ArrayList<>();
- try (BufferedReader bf1 = Files.newBufferedReader(Paths.get(PluginPropertyUtils.pluginProp(expectedOutputFile)))) {
- String line;
- while ((line = bf1.readLine()) != null) {
- expectedOutput.add(line);
- }
- }
-
- for (int expectedRow = 0; expectedRow < expectedOutput.size(); expectedRow++) {
- JsonObject expectedOutputAsJson = gson.fromJson(expectedOutput.get(expectedRow), JsonObject.class);
- BigInteger uniqueId = expectedOutputAsJson.get("id").getAsBigInteger();
+ JsonObject expectedOutputAsJson = gson.fromJson(TestSetupHooks.groupResponse, JsonObject.class);
+ JsonObject group = (JsonObject) expectedOutputAsJson.get("group");
+ uniqueId = group.get("id").getAsBigInteger();
getBigQueryTableData(PluginPropertyUtils.pluginProp("dataset"),
PluginPropertyUtils.pluginProp("bqtarget.table"), uniqueId);
-
- }
- for (int row = 0; row < bigQueryrows.size() && row < expectedOutput.size(); row++) {
- Assert.assertTrue(ZendeskPropertiesPageActions.compareValueOfBothResponses(expectedOutput.get(row),
- bigQueryrows.get(row)));
- }
+ Assert.assertTrue(ZendeskPropertiesPageActions.compareValueOfBothResponses(group.toString(),
+ bigQueryrows.get(0)));
}
public static void verifyIfRecordCreatedInSinkForMultipleObjectsAreCorrect(String expectedOutputFile)
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException {
List expectedOutput = new ArrayList<>();
try (BufferedReader bf1 = Files.newBufferedReader(Paths.get(PluginPropertyUtils.pluginProp(expectedOutputFile)))) {
String line;
@@ -123,25 +114,24 @@ public static void verifyIfRecordCreatedInSinkForMultipleObjectsAreCorrect(Strin
expectedOutput.add(line);
}
}
-
List bigQueryDatasetTables = new ArrayList<>();
TableResult tablesSchema = ZendeskPropertiesPageActions.getTableNamesFromDataSet
- (PluginPropertyUtils.pluginProp("dataset"));
+ (PluginPropertyUtils.pluginProp("dataset"));
tablesSchema.iterateAll().forEach(value -> bigQueryDatasetTables.add(value.get(0).getValue().toString()));
- System.out.println(bigQueryDatasetTables.size());
for (int expectedRow = 0; expectedRow < expectedOutput.size(); expectedRow++) {
JsonObject expectedOutputAsJson = gson.fromJson(expectedOutput.get(expectedRow), JsonObject.class);
BigInteger uniqueId = expectedOutputAsJson.get("id").getAsBigInteger();
getBigQueryTableData(PluginPropertyUtils.pluginProp("dataset"),
- bigQueryDatasetTables.get(0), uniqueId);
+ bigQueryDatasetTables.get(0), uniqueId);
}
for (int row = 0; row < bigQueryrows.size() && row < expectedOutput.size(); row++) {
Assert.assertTrue(ZendeskPropertiesPageActions.compareValueOfBothResponses(expectedOutput.get(row),
- bigQueryrows.get(row)));
+ bigQueryrows.get(row)));
}
}
+
static boolean compareValueOfBothResponses(String zendeskResponse, String bigQueryResponse) {
Type type = new TypeToken