From c4ff47cc5e07c724772314b1f462fd0e5a886d50 Mon Sep 17 00:00:00 2001 From: Jeff Fry Date: Sun, 25 Oct 2020 21:21:08 -0700 Subject: [PATCH] Updated RT and Xray default versions. Removed obsolete pipeline tests. --- .../roles/artifactory/defaults/main.yml | 4 +- .../installers/roles/xray/defaults/main.yml | 4 +- .../test/groovy/steps/SecuritytSteps.groovy | 196 ------ .../src/test/groovy/steps/XraySteps.groovy | 585 ------------------ Ansible/test/tests/src/test/groovy/testng.xml | 15 - .../test/groovy/tests/RepositoryTest.groovy | 302 --------- .../src/test/groovy/tests/SecurityTest.groovy | 153 ----- .../src/test/groovy/tests/XrayTest.groovy | 332 ---------- 8 files changed, 4 insertions(+), 1587 deletions(-) delete mode 100644 Ansible/test/tests/src/test/groovy/steps/SecuritytSteps.groovy delete mode 100644 Ansible/test/tests/src/test/groovy/steps/XraySteps.groovy delete mode 100644 Ansible/test/tests/src/test/groovy/tests/RepositoryTest.groovy delete mode 100644 Ansible/test/tests/src/test/groovy/tests/SecurityTest.groovy delete mode 100644 Ansible/test/tests/src/test/groovy/tests/XrayTest.groovy diff --git a/Ansible/ansible_collections/jfrog/installers/roles/artifactory/defaults/main.yml b/Ansible/ansible_collections/jfrog/installers/roles/artifactory/defaults/main.yml index 5cdaab6..64a426c 100644 --- a/Ansible/ansible_collections/jfrog/installers/roles/artifactory/defaults/main.yml +++ b/Ansible/ansible_collections/jfrog/installers/roles/artifactory/defaults/main.yml @@ -4,7 +4,7 @@ ansible_marketplace: standalone # The version of Artifactory to install -artifactory_version: 7.7.8 +artifactory_version: 7.10.2 # licenses file - specify a licenses file or specify up to 5 licenses artifactory_license1: @@ -49,4 +49,4 @@ service_list: group_name: "{{ artifactory_group }}" # if this is an upgrade -artifactory_upgrade_only: false \ No newline at end of file +artifactory_upgrade_only: false diff --git a/Ansible/ansible_collections/jfrog/installers/roles/xray/defaults/main.yml b/Ansible/ansible_collections/jfrog/installers/roles/xray/defaults/main.yml index 9306290..fd674bf 100644 --- a/Ansible/ansible_collections/jfrog/installers/roles/xray/defaults/main.yml +++ b/Ansible/ansible_collections/jfrog/installers/roles/xray/defaults/main.yml @@ -4,7 +4,7 @@ ansible_marketplace: standalone # The version of xray to install -xray_version: 3.8.6 +xray_version: 3.10.3 # whether to enable HA xray_ha_enabled: true @@ -26,4 +26,4 @@ xray_group: xray # if this is an upgrade xray_upgrade_only: false -xray_system_yaml_template: system.yaml.j2 \ No newline at end of file +xray_system_yaml_template: system.yaml.j2 diff --git a/Ansible/test/tests/src/test/groovy/steps/SecuritytSteps.groovy b/Ansible/test/tests/src/test/groovy/steps/SecuritytSteps.groovy deleted file mode 100644 index 4450b39..0000000 --- a/Ansible/test/tests/src/test/groovy/steps/SecuritytSteps.groovy +++ /dev/null @@ -1,196 +0,0 @@ -package steps - -import org.testng.annotations.DataProvider - -import static io.restassured.RestAssured.given - - -class SecuritytSteps { - - def createUser(usernameRt, emailRt, passwordRt) { - return given() - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .body("{\n" + - " \"email\" : \"${emailRt}\",\n" + - " \"password\": \"${passwordRt}\"\n" + - "}") - .when() - .put("/api/security/users/${usernameRt}") - .then() - .extract().response() - } - - def getUserDetails(usernameRt) { - return given() - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .when() - .get("/api/security/users/${usernameRt}") - .then() - .extract().response() - } - - def deleteUser(usernameRt) { - return given() - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .when() - .delete("/api/security/users/${usernameRt}") - .then() - .extract().response() - } - - def generateAPIKey(usernameRt, passwordRt) { - return given() - .auth() - .preemptive() - .basic("${usernameRt}", "${passwordRt}") - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .when() - .post("/api/security/apiKey") - .then() - .extract().response() - } - - def getAPIKey(usernameRt, passwordRt) { - return given() - .auth() - .preemptive() - .basic("${usernameRt}", "${passwordRt}") - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .when() - .get("/api/security/apiKey") - .then() - .extract().response() - } - - def regenerateAPIKey(usernameRt, passwordRt) { - return given() - .auth() - .preemptive() - .basic("${usernameRt}", "${passwordRt}") - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .when() - .put("/api/security/apiKey") - .then() - .extract().response() - } - - def createGroup(groupName) { - return given() - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .body("{\"name\": \"${groupName}\"}") - .when() - .put("/api/security/groups/${groupName}") - .then() - .extract().response() - } - - def getGroup(groupName) { - return given() - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .body("{\"name\": \"${groupName}\"}") - .when() - .get("/api/security/groups/${groupName}") - .then() - .extract().response() - } - - def deleteGroup(groupName) { - return given() - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .when() - .delete("/api/security/groups/${groupName}") - .then() - .extract().response() - } - - def createPermissions(permissionName, repository, user1, user2, - group1, group2, action1, action2, action3) { - return given() - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .body("{\n" + - " \"name\": \"${permissionName}\",\n" + - " \"repo\": {\n" + - " \"repositories\": [ \"${repository}\" ],\n" + - " \"actions\": {\n" + - " \"users\" : {\n" + - " \"${user1}\": [ \"${action1}\",\"${action2}\",\"${action3}\" ], \n" + - " \"${user2}\" : [ \"${action1}\",\"${action2}\",\"${action3}\" ]\n" + - " },\n" + - " \"groups\" : {\n" + - " \"${group1}\" : [ \"${action1}\",\"${action2}\",\"${action3}\" ],\n" + - " \"${group2}\" : [ \"${action1}\",\"${action2}\" ]\n" + - " }\n" + - " }\n" + - " }\n" + - "}") - .when() - .put("/api/v2/security/permissions/testPermission") - .then() - .extract().response() - } - - def getPermissions( permissionName) { - return given() - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .when() - .get("/api/v2/security/permissions/${permissionName}") - .then() - .extract().response() - } - - def deletePermissions(permissionName) { - return given() - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .when() - .delete("/api/v2/security/permissions/${permissionName}") - .then() - .extract().response() - } - - - // Data providers - - @DataProvider(name="users") - public Object[][] users() { - return new Object[][]{ - ["testuser0", "email0@jfrog.com", "password123"], - ["testuser1", "email1@jfrog.com", "password123"], - ["testuser2", "email2@jfrog.com", "password123"], - ["testuser3", "email3@jfrog.com", "password123"], - ["testuser4", "email4@jfrog.com", "password123"], - ["testuser5", "email5@jfrog.com", "password123"], - ["testuser6", "email6@jfrog.com", "password123"], - ["testuser7", "email7@jfrog.com", "password123"], - ["testuser8", "email8@jfrog.com", "password123"], - ["testuser9", "email9@jfrog.com", "password123"] - } - } - - @DataProvider(name="groups") - public Object[][] groups() { - return new Object[][]{ - ["test-group-0"], - ["test-group-1"], - ["test-group-2"], - ["test-group-3"], - ["test-group-4"], - ["test-group-5"], - ["test-group-6"], - ["test-group-7"], - ["test-group-8"], - ["test-group-9"] - } - } -} diff --git a/Ansible/test/tests/src/test/groovy/steps/XraySteps.groovy b/Ansible/test/tests/src/test/groovy/steps/XraySteps.groovy deleted file mode 100644 index 552ba93..0000000 --- a/Ansible/test/tests/src/test/groovy/steps/XraySteps.groovy +++ /dev/null @@ -1,585 +0,0 @@ -package steps - -import org.testng.annotations.DataProvider - -import static io.restassured.RestAssured.given - -class XraySteps { - - def createIssueEvent(issueID, cve, summary, description, username, password) { - return given() - .auth() - .preemptive() - .basic("${username}", "${password}") - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .body("{\n" + - " \"id\": \"${issueID}\",\n" + - " \"type\": \"Security\",\n" + - " \"provider\": \"JFrog\",\n" + - " \"package_type\": \"maven\",\n" + - " \"severity\": \"High\",\n" + - " \"components\": [\n" + - " {\n" + - " \"id\": \"aero:aero\",\n" + - " \"vulnerable_versions\": [\n" + - " \"[0.2.3]\"\n" + - " ]\n" + - " }\n" + - " ],\n" + - " \"cves\": [\n" + - " {\n" + - " \"cve\": \"${cve}\",\n" + - " \"cvss_v2\": \"2.4\"\n" + - " }\n" + - " ],\n" + - " \"summary\": \"${summary}\",\n" + - " \"description\": \"${description}\",\n" + - " \"sources\": [\n" + - " {\n" + - " \"source_id\": \"${cve}\"\n" + - " }\n" + - " ]\n" + - "}") - .when() - .post("/v1/events") - .then() - .extract().response() - } - - def updateIssueEvent(issueID, cve, summary, description, username, password) { - return given() - .auth() - .preemptive() - .basic("${username}", "${password}") - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .body("{\n" + - " \"type\": \"Security\",\n" + - " \"provider\": \"JFrog\",\n" + - " \"package_type\": \"maven\",\n" + - " \"severity\": \"High\",\n" + - " \"components\": [\n" + - " {\n" + - " \"id\": \"aero:aero\",\n" + - " \"vulnerable_versions\": [\n" + - " \"[0.2.3]\"\n" + - " ]\n" + - " }\n" + - " ],\n" + - " \"cves\": [\n" + - " {\n" + - " \"cve\": \"${cve}\",\n" + - " \"cvss_v2\": \"2.4\"\n" + - " }\n" + - " ],\n" + - " \"summary\": \"${summary}\",\n" + - " \"description\": \"${description}\",\n" + - " \"sources\": [\n" + - " {\n" + - " \"source_id\": \"${cve}\"\n" + - " }\n" + - " ]\n" + - "}") - .when() - .put("/v1/events/${issueID}") - .then() - .extract().response() - } - - def createPolicy(policyName, username, password) { - return given() - .auth() - .preemptive() - .basic("${username}", "${password}") - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .body("{\n" + - " \"name\": \"${policyName}\",\n" + - " \"type\": \"security\",\n" + - " \"description\": \"some description\",\n" + - " \"rules\": [\n" + - " {\n" + - " \"name\": \"securityRule\",\n" + - " \"priority\": 1,\n" + - " \"criteria\": {\n" + - " \"min_severity\": \"High\"\n" + - " },\n" + - " \"actions\": {\n" + - " \"mails\": [\n" + - " \"mail1@example.com\",\n" + - " \"mail2@example.com\"\n" + - " ],\n" + - " \"fail_build\": true,\n" + - " \"block_download\": {\n" + - " \"unscanned\": true,\n" + - " \"active\": true\n" + - " }\n" + - " }\n" + - " }\n" + - " ]\n" + - "}") - .when() - .post("/v1/policies") - .then() - .extract().response() - } - - def updatePolicy(policyName, description, username, password) { - return given() - .auth() - .preemptive() - .basic("${username}", "${password}") - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .body("{\n" + - " \"name\": \"${policyName}\",\n" + - " \"type\": \"security\",\n" + - " \"description\": \"${description}\",\n" + - " \"rules\": [\n" + - " {\n" + - " \"name\": \"securityRule\",\n" + - " \"priority\": 1,\n" + - " \"criteria\": {\n" + - " \"min_severity\": \"High\"\n" + - " },\n" + - " \"actions\": {\n" + - " \"mails\": [\n" + - " \"mail1@example.com\",\n" + - " \"mail2@example.com\"\n" + - " ],\n" + - " \"fail_build\": true,\n" + - " \"block_download\": {\n" + - " \"unscanned\": true,\n" + - " \"active\": true\n" + - " }\n" + - " }\n" + - " }\n" + - " ]\n" + - "}") - .when() - .put("/v1/policies/${policyName}") - .then() - .extract().response() - } - - def getPolicy(policyName, username, password) { - return given() - .auth() - .preemptive() - .basic("${username}", "${password}") - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .when() - .get("/v1/policies/${policyName}") - .then() - .extract().response() - } - - def getPolicies(username, password) { - return given() - .auth() - .preemptive() - .basic("${username}", "${password}") - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .when() - .get("/v1/policies") - .then() - .extract().response() - } - - def deletePolicy(policyName, username, password) { - return given() - .auth() - .preemptive() - .basic("${username}", "${password}") - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .when() - .delete("/v1/policies/${policyName}") - .then() - .extract().response() - } - - def getIssueEvent(issueID, username, password) { - return given() - .auth() - .preemptive() - .basic("${username}", "${password}") - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .when() - .get("/v1/events/${issueID}") - .then() - .extract().response() - } - - def createWatchEvent(watchName, policyName, username, password) { - return given() - .auth() - .preemptive() - .basic("${username}", "${password}") - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .body("{\n" + - " \"general_data\": {\n" + - " \"name\": \"${watchName}\",\n" + - " \"description\": \"This is a new watch created using API V2\",\n" + - " \"active\": true\n" + - " },\n" + - " \"project_resources\": {\n" + - " \"resources\": [\n" + - " {\n" + - " \"type\": \"all-repos\",\n" + - " \"filters\": [\n" + - " {\n" + - " \"type\": \"package-type\",\n" + - " \"value\": \"Docker\"\n" + - " },\n" + - " {\n" + - " \"type\": \"package-type\",\n" + - " \"value\": \"Debian\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - " },\n" + - " \"assigned_policies\": [\n" + - " {\n" + - " \"name\": \"${policyName}\",\n" + - " \"type\": \"security\"\n" + - " }\n" + - " ]\n" + - "}") - .when() - .post("/v2/watches") - .then() - .extract().response() - } - - def updateWatchEvent(watchName, description, policyName, username, password) { - return given() - .auth() - .preemptive() - .basic("${username}", "${password}") - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .body("{\n" + - " \"general_data\": {\n" + - " \"name\": \"${watchName}\",\n" + - " \"description\": \"${description}\",\n" + - " \"active\": true\n" + - " },\n" + - " \"project_resources\": {\n" + - " \"resources\": [\n" + - " {\n" + - " \"type\": \"all-repos\",\n" + - " \"filters\": [\n" + - " {\n" + - " \"type\": \"package-type\",\n" + - " \"value\": \"Docker\"\n" + - " },\n" + - " {\n" + - " \"type\": \"package-type\",\n" + - " \"value\": \"Debian\"\n" + - " }\n" + - " ]\n" + - " }\n" + - " ]\n" + - " },\n" + - " \"assigned_policies\": [\n" + - " {\n" + - " \"name\": \"${policyName}\",\n" + - " \"type\": \"security\"\n" + - " }\n" + - " ]\n" + - "}") - .when() - .put("/v2/watches/${watchName}") - .then() - .extract().response() - } - - def getWatchEvent(watchName, username, password) { - return given() - .auth() - .preemptive() - .basic("${username}", "${password}") - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .when() - .get("/v2/watches/${watchName}") - .then() - .extract().response() - } - - def deleteWatchEvent(watchName, username, password) { - return given() - .auth() - .preemptive() - .basic("${username}", "${password}") - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .when() - .delete("/v2/watches/${watchName}") - .then() - .extract().response() - } - - def assignPolicy(watchName, policyName, username, password) { - return given() - .auth() - .preemptive() - .basic("${username}", "${password}") - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .body("{\n" + - " \"watches\": [\n" + - " \"${watchName}\"\n" + - " ]\n" + - "}") - .when() - .post("/v1/policies/${policyName}/assign") - .then() - .extract().response() - } - - def getIntegrationConfiguration(username, password) { - return given() - .auth() - .preemptive() - .basic("${username}", "${password}") - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .when() - .get("/v1/integration") - .then() - .extract().response() - } - - def addtIntegrationConfiguration(username, password, vendorName) { - return given() - .auth() - .preemptive() - .basic("${username}", "${password}") - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .body("{\n" + - " \"vendor\": \"${vendorName}\",\n" + - " \"api_key\": \"12345\",\n" + - " \"enabled\": true,\n" + - " \"context\": \"project_id\",\n" + - " \"url\": \"https://saas.whitesourcesoftware.com/xray\",\n" + - " \"description\": \"WhiteSource provides a simple yet powerful open source security and licenses management solution. More details at http://www.whitesourcesoftware.com.\",\n" + - " \"test_url\": \"https://saas.whitesourcesoftware.com/xray/api/checkauth\"\n" + - "}") - .when() - .post("/v1/integration") - .then() - .extract().response() - } - - def postSystemParameters(username, password, body) { - return given() - .auth() - .preemptive() - .basic("${username}", "${password}") - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .body(body) - .when() - .put("/v1/configuration/systemParameters") - .then() - .extract().response() - } - - def getSystemParameters(username, password) { - return given() - .auth() - .preemptive() - .basic("${username}", "${password}") - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .when() - .get("/v1/configuration/systemParameters") - .then() - .extract().response() - } - - def getBinaryManager(username, password) { - return given() - .auth() - .preemptive() - .basic("${username}", "${password}") - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .when() - .get("/v1/binMgr/default") - .then() - .extract().response() - } - - - def getIndexingConfiguration(username, password) { - return given() - .auth() - .preemptive() - .basic("${username}", "${password}") - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .when() - .get("/v1/binMgr/default/repos") - .then() - .extract().response() - } - - def updateIndexingConfiguration(username, password) { - return given() - .auth() - .preemptive() - .basic("${username}", "${password}") - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .body("{\n" + - " \"indexed_repos\": [\n" + - " {\n" + - " \"name\": \"docker-local\",\n" + - " \"type\": \"local\",\n" + - " \"pkg_type\": \"Docker\"\n" + - " },\n" + - " {\n" + - " \"name\": \"generic-dev-local\",\n" + - " \"type\": \"local\",\n" + - " \"pkg_type\": \"Generic\"\n" + - " }\n" + - " ],\n" + - " \"non_indexed_repos\": []\n" + - "}") - .when() - .put("/v1/binMgr/default/repos") - .then() - .extract().response() - } - - - - def startScan(username, password, componentID) { - return given() - .auth() - .preemptive() - .basic("${username}", "${password}") - .header("Cache-Control", "no-cache") - .header("Content-Type", "application/json") - .body("{\n" + - " \"componentID\": \"${componentID}\"\n" + - "}") - .when() - .post("/v1/scanArtifact") - .then() - .extract().response() - } - - - def artifactSummary(username, password, artifactPath) { - return given() - .auth() - .preemptive() - .basic("${username}", "${password}") - .header("Cache-Control", "no-cache") - .header("content-Type", "application/json") - .body("{\n" + - " \"checksums\": [\n" + - " \"\"\n" + - " ],\n" + - " \"paths\": [\n" + - " \"${artifactPath}\"\n" + - " ]\n" + - "}") - .when() - .post("/v1/summary/artifact") - .then() - .extract().response() - } - - def createSupportBundle(username, password, name, startDate, endDate) { - return given() - .auth() - .preemptive() - .basic("${username}", "${password}") - .header("Cache-Control", "no-cache") - .header("Content-Type", "application/json") - .body("{ \n" + - " \"name\":\"${name}\",\n" + - " \"description\":\"desc\",\n" + - " \"parameters\":{ \n" + - " \"configuration\": true,\n" + - " \"system\": true, \n" + - " \"logs\":{ \n" + - " \"include\": true, \n" + - " \"start_date\":\"${startDate}\",\n" + - " \"end_date\":\"${endDate}\"\n" + - " },\n" + - " \"thread_dump\":{ \n" + - " \"count\": 1,\n" + - " \"interval\": 0\n" + - " }\n" + - " }\n" + - "}") - .when() - .post("/v1/system/support/bundle") - .then() - .extract().response() - - } - - def getSystemMonitoringStatus(username, password) { - return given() - .auth() - .preemptive() - .basic("${username}", "${password}") - .header("Cache-Control", "no-cache") - .header("Content-Type", "application/json") - .when() - .get("/v1/monitor") - .then() - .extract().response() - } - - def xrayPingRequest(username, password) { - return given() - .auth() - .preemptive() - .basic("${username}", "${password}") - .header("Cache-Control", "no-cache") - .header("Content-Type", "application/json") - .when() - .get("/v1/system/ping") - .then() - .extract().response() - } - - def xrayGetVersion(username, password) { - return given() - .auth() - .preemptive() - .basic("${username}", "${password}") - .header("Cache-Control", "no-cache") - .header("Content-Type", "application/json") - .when() - .get("/v1/system/version") - .then() - .extract().response() - } - - // Data providers - - @DataProvider(name = "issueEvents") - public Object[][] issueEvents() { - return new Object[][]{ - ["XRAY-", "CVE-2017-2000386", "A very important custom issue", "A very important custom issue"] - - } - } - -} \ No newline at end of file diff --git a/Ansible/test/tests/src/test/groovy/testng.xml b/Ansible/test/tests/src/test/groovy/testng.xml index 5342660..cee4eb7 100644 --- a/Ansible/test/tests/src/test/groovy/testng.xml +++ b/Ansible/test/tests/src/test/groovy/testng.xml @@ -7,19 +7,4 @@ - - - - - - - - - - - - - - - diff --git a/Ansible/test/tests/src/test/groovy/tests/RepositoryTest.groovy b/Ansible/test/tests/src/test/groovy/tests/RepositoryTest.groovy deleted file mode 100644 index 3deb72a..0000000 --- a/Ansible/test/tests/src/test/groovy/tests/RepositoryTest.groovy +++ /dev/null @@ -1,302 +0,0 @@ -package tests - -import io.restassured.RestAssured -import io.restassured.path.json.JsonPath -import io.restassured.response.Response -import org.hamcrest.Matchers -import org.testng.Reporter -import org.testng.annotations.BeforeTest -import org.testng.annotations.Test -import org.yaml.snakeyaml.Yaml -import steps.RepositorySteps - -import java.time.LocalDate - -import static org.hamcrest.Matchers.containsString -import static org.hamcrest.Matchers.containsStringIgnoringCase -import static org.hamcrest.Matchers.equalTo -import static org.hamcrest.Matchers.equalToIgnoringCase -import static org.hamcrest.Matchers.greaterThanOrEqualTo - - -class RepositoryTest extends RepositorySteps{ - Yaml yaml = new Yaml() - def configFile = new File("./src/test/resources/testenv.yaml") - def repoListHA = new File("./src/test/resources/repositories/CreateDefault.yaml") - def repoListJCR = new File("./src/test/resources/repositories/CreateJCR.yaml") - def artifact = new File("./src/test/resources/repositories/artifact.zip") - def config = yaml.load(configFile.text) - def artifactoryURL - def username - def password - - @BeforeTest(groups=["jcr", "pro"]) - def setUp() { - artifactoryURL = config.artifactory.external_ip - username = config.artifactory.rt_username - password = config.artifactory.rt_password - RestAssured.baseURI = "http://${artifactoryURL}/artifactory" - RestAssured.authentication = RestAssured.basic(username, password); - RestAssured.useRelaxedHTTPSValidation(); - } - - - @Test(priority=1, groups=["pro"], testName = "Delete sample repositories") - void deleteReposTest(){ - Response getRepoResponse = getRepos() - JsonPath jsonPathEvaluator = getRepoResponse.jsonPath() - List repoNames = jsonPathEvaluator.getList("key", String.class) - for (int i = 0; i < repoNames.size(); i ++){ - Response delete = deleteRepository(repoNames[i], username, password) - delete.then().statusCode(200) - } - - Reporter.log("- Delete sample HA repositories. All repositories were successfully deleted", true) - } - - @Test(priority=1, groups=["jcr",], testName = "Delete sample repositories JCR") - void deleteDefaultJCRReposTest(){ - Response getRepoResponse = getRepos() - JsonPath jsonPathEvaluator = getRepoResponse.jsonPath() - List repoNames = jsonPathEvaluator.getList("key", String.class) - for (int i = 0; i < repoNames.size(); i ++){ - Response delete = deleteRepository(repoNames[i], username, password) - delete.then().statusCode(400).body("errors[0].message", - containsStringIgnoringCase("This REST API is available only in Artifactory Pro")) - } - - Reporter.log("- Delete sample JCR repositories. " + - "Verified - this REST API is available only in Artifactory Pro", true) - } - - @Test(priority=2, groups=["pro"], testName = "Create a list of repositories for HA, specified in YAML file") - void createDefaultHAReposTest(){ - def body - def expectedMessage - body = repoListHA - expectedMessage = "383 changes to config merged successfully" - Response response = createRepositories(body, username, password) - response.then().assertThat().statusCode(200) - .body(Matchers.hasToString(expectedMessage)) - .log().body() - - Reporter.log("- Create repositories for HA distribution. Successfully created", true) - } - - @Test(priority=2, groups=["jcr"], testName = "Create a list of repositories for JCR, specified in YAML file") - void createDefaultJCRReposTest(){ - def body - def expectedMessage - body = repoListJCR - expectedMessage = "82 changes to config merged successfully" - Response response = createRepositories(body, username, password) - response.then().assertThat().statusCode(200) - .body(Matchers.hasToString(expectedMessage)) - .log().body() - - Reporter.log("- Create repositories for JCR. Successfully created", true) - } - - @Test(priority=3, groups=["pro"], testName = "Verify HA repositories were created successfully") - void checkDefaultHAReposTest(){ - Response response = getRepos() - def numberOfRepos = response.then().extract().path("size()") - def expectedReposNumber = 84 - println("Number of created repositories is ${numberOfRepos}") - response.then().assertThat().statusCode(200) - .body("size()", greaterThanOrEqualTo(expectedReposNumber)) - - Reporter.log("- Verify HA repos were created. ${numberOfRepos} repositories were created", true) - } - - @Test(priority=3, groups=["jcr"], testName = "Verify JCR repositories were created successfully") - void checkDefaultJCRReposTest(){ - Response response = getRepos() - def numberOfRepos = response.then().extract().path("size()") - def expectedReposNumber = 17 - response.then().assertThat().statusCode(200) - .body("size()", greaterThanOrEqualTo(expectedReposNumber)) - - Reporter.log("- Verify JCR repos were created. ${numberOfRepos} repositories were created", true) - } - - /*@Test(priority=4, groups=["jcr","pro"], testName = "Create a directory in generic repo") - void createDirectoryTest(){ - def repoName = "generic-dev-local" - def directoryName = "test-directory/" - Response response = createDirectory(repoName, directoryName) - response.then().assertThat().statusCode(201) - .body("repo", equalTo(repoName)) - .body("path", equalTo("/" + directoryName)) - .body("uri", equalTo("http://" + artifactoryURL + ":80/artifactory/" + repoName + "/" + directoryName)) - - Reporter.log("- Create folder. Folder successfully created", true) - } - - @Test(priority=5, groups=["jcr","pro"], testName = "Deploy file to generic repo") - void deployArtifactToGenericTest(){ - def repoName = "generic-dev-local" - def directoryName = "test-directory" - def filename = "artifact.zip" - Response response = deployArtifact(repoName, directoryName, artifact, filename) - response.then().assertThat().statusCode(201) - .body("repo", equalTo(repoName)) - .body("path", equalTo("/" + directoryName + "/" + filename)) - .body("downloadUri", equalTo("http://" + artifactoryURL + ":80/artifactory/" + repoName + "/" - + directoryName + "/" + filename)) - - Reporter.log("- Deploy artifact. Artifact successfully deployed", true) - } - - @Test(priority=6, groups=["jcr", "pro"], testName = "Get the artifact info") - void getArtifactinfoTest(){ - def repoName = "generic-dev-local" - def directoryName = "test-directory" - def filename = "artifact.zip" - Response response = getInfo(repoName, directoryName, artifact, filename) - response.then().assertThat().statusCode(200) - .body("repo", equalTo(repoName)) - .body("path", equalTo("/" + directoryName + "/" + filename)) - .body("downloadUri", equalTo("http://" + artifactoryURL + ":80/artifactory/" + repoName + "/" - + directoryName + "/" + filename)) - - Reporter.log("- Get the artifact info. Artifact info is successfully returned", true) - }*/ - -/* @Test(priority=7, groups=["jcr", "pro"], testName = "Delete item") - void deleteJCRItemTest(){ - def repoName = "generic-dev-local" - def directoryName = "test-directory" - def filename = "artifact.zip" - Response response = deleteItem(repoName, directoryName, artifact, filename) - response.then().assertThat().statusCode(204) - - Response verification = getInfo(repoName, directoryName, artifact, filename) - verification.then().statusCode(404) - .body("errors[0].message", equalToIgnoringCase("Unable to find item")) - - Reporter.log("- Delete item. File has been deleted successfully", true) - }*/ - - /*@Test(priority=8, groups=["pro"], testName = "Create support bundle") - void createSupportBundleHATest(){ - def name = "Support Bundle" - LocalDate startDate = LocalDate.now().minusDays(5) - LocalDate endDate = LocalDate.now() - Response response = createSupportBundle(name, startDate, endDate) - response.then().assertThat().statusCode(200) - .body("artifactory.bundle_url", containsString(artifactoryURL)) - - Reporter.log("- Create support bundle. Successfully created", true) - }*/ - - @Test(priority=8, groups=["jcr"], testName = "Create support bundle") - void createSupportBundleJCATest(){ - def name = "Support Bundle" - LocalDate startDate = LocalDate.now().minusDays(5) - LocalDate endDate = LocalDate.now() - Response response = createSupportBundle(name, startDate, endDate) - response.then().assertThat().statusCode(400) - .body("errors[0].message", - containsStringIgnoringCase("This REST API is available only in Artifactory Pro")) - - Reporter.log("- Create support bundle, JCR. " + - "Call is not supported in JCR version, error message is correct", true) - } - - @Test(priority=9, groups=["pro"], testName = "Delete created repositories") - void deleteDefaultReposTest(){ - Response getRepoResponse = getRepos() - JsonPath jsonPathEvaluator = getRepoResponse.jsonPath() - List repoNames = jsonPathEvaluator.getList("key", String.class) - for (int i = 0; i < repoNames.size(); i ++){ - Response delete = deleteRepository(repoNames[i], username, password) - delete.then().statusCode(200) - } - - Reporter.log("- Delete HA repositories. All repositories were successfully deleted", true) - } - - @Test(priority=9, groups=["jcr",], testName = "Delete sample repositories JCR") - void deleteJCRReposTest(){ - Response getRepoResponse = getRepos() - JsonPath jsonPathEvaluator = getRepoResponse.jsonPath() - List repoNames = jsonPathEvaluator.getList("key", String.class) - for (int i = 0; i < repoNames.size(); i ++){ - Response delete = deleteRepository(repoNames[i], username, password) - delete.then().statusCode(400).body("errors[0].message", - containsStringIgnoringCase("This REST API is available only in Artifactory Pro")) - } - - Reporter.log("- Delete sample JCR repositories. All repositories were successfully deleted", true) - } - - @Test(priority=10, groups=["pro"], testName = "Verify repositories were deleted successfully") - void checkReposAreDeleted(){ - Response response = getRepos() - def numberOfRepos = response.then().extract().path("size()") - def expectedReposNumber = 0 - response.then().assertThat().statusCode(200) - .body("size()", equalTo(expectedReposNumber)) - - Reporter.log("- Verify repo were deleted. ${numberOfRepos} repositories remain", true) - } - - @Test(priority=11, groups=["pro"], testName = "Re-Create a list of repositories, for the next tests") - void reCreateDefaultHAReposTest(){ - def body - def expectedMessage - body = repoListHA - expectedMessage = "383 changes to config merged successfully" - Response response = createRepositories(body, username, password) - response.then().assertThat().statusCode(200) - .body(Matchers.hasToString(expectedMessage)) - .log().body() - - Reporter.log("- Re-create repositories for HA distribution. Successfully created", true) - } - - @Test(priority=12, groups=["jcr"], testName = "Re-Create a list of repositories, for the next tests") - void reCreateDefaultJCRReposTest(){ - def body - def expectedMessage - body = repoListJCR - expectedMessage = "82 changes to config merged successfully" - Response response = createRepositories(body, username, password) - response.then().assertThat().statusCode(200) - .body(Matchers.hasToString(expectedMessage)) - .log().body() - - Reporter.log("- Re-create repositories for JCR distribution. Successfully created", true) - } - -/* @Test(priority=13, groups=["jcr","pro"], testName = "Create a directory in generic repo") - void reCreateDirectoryTest(){ - def repoName = "generic-dev-local" - def directoryName = "test-directory/" - Response response = createDirectory(repoName, directoryName) - response.then().assertThat().statusCode(201) - .body("repo", equalTo(repoName)) - .body("path", equalTo("/" + directoryName)) - .body("uri", equalTo("http://" + artifactoryURL + ":80/artifactory/" + repoName + "/" + directoryName)) - - Reporter.log("- Create folder. Folder successfully created", true) - }*/ - -/* @Test(priority=14, groups=["jcr","pro"], testName = "Deploy file to generic repo") - void reDeployArtifactToGenericTest(){ - def repoName = "generic-dev-local" - def directoryName = "test-directory" - def filename = "artifact.zip" - Response response = deployArtifact(repoName, directoryName, artifact, filename) - response.then().assertThat().statusCode(201) - .body("repo", equalTo(repoName)) - .body("path", equalTo("/" + directoryName + "/" + filename)) - .body("downloadUri", equalTo("http://" + artifactoryURL + ":80/artifactory/" + repoName + "/" - + directoryName + "/" + filename)) - - Reporter.log("- Deploy artifact. Artifact successfully deployed", true) - }*/ - - -} diff --git a/Ansible/test/tests/src/test/groovy/tests/SecurityTest.groovy b/Ansible/test/tests/src/test/groovy/tests/SecurityTest.groovy deleted file mode 100644 index a166cd0..0000000 --- a/Ansible/test/tests/src/test/groovy/tests/SecurityTest.groovy +++ /dev/null @@ -1,153 +0,0 @@ -package tests - -import io.restassured.RestAssured -import io.restassured.response.Response -import org.hamcrest.Matchers -import org.junit.Assert -import org.testng.Reporter -import org.testng.annotations.BeforeSuite -import org.testng.annotations.Test -import org.yaml.snakeyaml.Yaml -import steps.SecuritytSteps - - -class SecurityTest extends SecuritytSteps{ - - Yaml yaml = new Yaml() - def configFile = new File("./src/test/resources/testenv.yaml") - def config = yaml.load(configFile.text) - def artifactoryURL - def distribution - def username - def password - - @BeforeSuite(groups=["jcr","pro"]) - def setUp() { - artifactoryURL = config.artifactory.external_ip - distribution = config.artifactory.distribution - username = config.artifactory.rt_username - password = config.artifactory.rt_password - RestAssured.baseURI = "http://${artifactoryURL}/artifactory" - RestAssured.authentication = RestAssured.basic(username, password); - RestAssured.useRelaxedHTTPSValidation(); - } - - @Test(priority=1, groups=["pro"], dataProvider = "users", testName = "Create users") - void createUsersTest(usernameRt, emailRt, passwordRt){ - Response response = createUser(usernameRt, emailRt, passwordRt) - response.then().statusCode(201) - - Reporter.log("- Create users. User ${usernameRt} created successfully", true) - } - - @Test(priority=2, groups=["pro"], dataProvider = "users", testName = "Verify users were created successfully") - void verifyUsersTest(usernameRt, emailRt, passwordRt){ - Response response = getUserDetails(usernameRt) - response.then().statusCode(200). - body("name", Matchers.equalTo(usernameRt)). - body("email", Matchers.equalTo(emailRt)). - body("admin", Matchers.equalTo(false)). - body("groups[0]", Matchers.equalTo("readers")) - - Reporter.log("- Verify created users. User ${usernameRt} was successfully verified", true) - } - - @Test(priority=3, groups=["pro"], dataProvider = "users", testName = "Generate API keys") - void generateAPIKeysTest(usernameRt, emailRt, passwordRt) { - Response createKey = generateAPIKey(usernameRt, passwordRt) - def errorMessage = createKey.then().extract().path("error") - if (errorMessage == null) { - def key = createKey.then().extract().path("apiKey") - Response getKey = getAPIKey(usernameRt, passwordRt) - def keyVerification = getKey.then().extract().path("apiKey") - Assert.assertTrue(key == keyVerification) - Reporter.log("- Generate API keys. Key for ${usernameRt} created successfully", true) - } else if (errorMessage.toString().contains("Api key already exists for user:")){ - Reporter.log("- Generate API keys. Key for ${usernameRt} already exists, skipped", true) - } - } - - @Test(priority=4, groups=["pro"], dataProvider = "users", testName = "Re-generate API keys") - void regenerateAPIKeysTest(usernameRt, emailRt, passwordRt){ - Response regenerated = regenerateAPIKey(usernameRt, passwordRt) - regenerated.then().statusCode(200) - def key = regenerated.then().extract().path("apiKey") - Response getKey = getAPIKey(usernameRt, passwordRt) - getKey.then().statusCode(200) - def keyVerification = getKey.then().extract().path("apiKey") - Assert.assertTrue(key == keyVerification) - - Reporter.log("- Re-generate API keys. Key for ${usernameRt} re-generated successfully", true) - } - - @Test(priority=5, groups=["pro"], dataProvider = "groups", testName = "Create a group") - void createGroupTest(groupName){ - Response create = createGroup(groupName) - create.then().statusCode(201) - - Response get = getGroup(groupName) - get.then().statusCode(200) - def name = get.then().extract().path("name") - def adminPrivileges = get.then().extract().path("adminPrivileges") - Assert.assertTrue(name == groupName) - Assert.assertTrue(adminPrivileges == false) - - Reporter.log("- Create group. Group ${groupName} was successfully created", true) - } - - @Test(priority=6, groups=["pro"], testName = "Create and verify permissions") - void createPermissionsTest(){ - def permissionName = "testPermission" - def repository = "ANY" - def user1 = "testuser0" - def user2 = "testuser1" - def group1 = "test-group-0" - def group2 = "test-group-1" - def action1 = "read" - def action2 = "write" - def action3 = "manage" - Response create = createPermissions(permissionName, repository, user1, user2, - group1, group2, action1, action2, action3) - create.then().statusCode(200) - - Response get = getPermissions(permissionName) - get.then().statusCode(200) - Assert.assertTrue(permissionName == get.then().extract().path("name")) - Assert.assertTrue(repository == get.then().extract().path("repo.repositories[0]")) - Assert.assertTrue(action1 == get.then().extract().path("repo.actions.users.${user1}[0]")) - Assert.assertTrue(action2 == get.then().extract().path("repo.actions.users.${user1}[1]")) - Assert.assertTrue(action3 == get.then().extract().path("repo.actions.users.${user1}[2]")) - Assert.assertTrue(action1 == get.then().extract().path("repo.actions.users.${user2}[0]")) - Assert.assertTrue(action2 == get.then().extract().path("repo.actions.users.${user2}[1]")) - Assert.assertTrue(action3 == get.then().extract().path("repo.actions.users.${user2}[2]")) - Assert.assertTrue(action1 == get.then().extract().path("repo.actions.groups.${group1}[0]")) - Assert.assertTrue(action2 == get.then().extract().path("repo.actions.groups.${group2}[1]")) - Assert.assertTrue(action1 == get.then().extract().path("repo.actions.groups.${group2}[0]")) - Assert.assertTrue(action2 == get.then().extract().path("repo.actions.groups.${group2}[1]")) - - Reporter.log("- Create permissions. Permissions successfully created and verified", true) - } - - @Test(priority=7, groups=["pro"], testName = "Delete permissions") - void deletePermissionsTest(){ - def permissionName = "testPermission" - Response delete = deletePermissions(permissionName) - delete.then().statusCode(200) - Reporter.log("- Delete permissions. User ${permissionName} has been removed successfully", true) - } - - @Test(priority=8, groups=["pro"], dataProvider = "users", testName = "Delete non-default users") - void deleteUserTest(usernameRt, email, passwordRt){ - Response delete = deleteUser(usernameRt) - delete.then().statusCode(200).body(Matchers.containsString("${usernameRt}")) - Reporter.log("- Delete user. User ${usernameRt} has been removed successfully", true) - } - - @Test(priority=9, groups=["pro"], dataProvider = "groups", testName = "Delete non-default groups") - void deleteGroupTest(groupName){ - Response delete = deleteGroup(groupName) - delete.then().statusCode(200).body(Matchers.containsString("${groupName}")) - Reporter.log("- Delete group. Group ${groupName} has been removed successfully", true) - } - -} diff --git a/Ansible/test/tests/src/test/groovy/tests/XrayTest.groovy b/Ansible/test/tests/src/test/groovy/tests/XrayTest.groovy deleted file mode 100644 index ef6e4c4..0000000 --- a/Ansible/test/tests/src/test/groovy/tests/XrayTest.groovy +++ /dev/null @@ -1,332 +0,0 @@ -package tests - -import io.restassured.RestAssured -import io.restassured.response.Response -import org.testng.Assert -import org.testng.Reporter -import org.testng.annotations.BeforeSuite -import org.testng.annotations.BeforeTest -import org.testng.annotations.Test -import org.yaml.snakeyaml.Yaml -import steps.XraySteps - -import java.time.LocalDate - -import static org.hamcrest.Matchers.containsStringIgnoringCase -import static org.hamcrest.Matchers.emptyArray -import static org.hamcrest.Matchers.equalTo -import static org.hamcrest.Matchers.hasItem -import static org.hamcrest.Matchers.is -import static org.hamcrest.Matchers.isA -import static org.hamcrest.Matchers.not -import static org.hamcrest.Matchers.notNullValue -import static org.hamcrest.Matchers.nullValue - - -class XrayTest extends XraySteps{ - - Yaml yaml = new Yaml() - def configFile = new File("./src/test/resources/testenv.yaml") - def config = yaml.load(configFile.text) - def artifactoryURL - def distribution - def username - def password - def randomIndex - def policyName - def watchName - - @BeforeSuite(groups=["xray"]) - def setUp() { - artifactoryURL = config.artifactory.external_ip - distribution = config.artifactory.distribution - username = config.artifactory.rt_username - password = config.artifactory.rt_password - RestAssured.authentication = RestAssured.basic(username, password) - RestAssured.useRelaxedHTTPSValidation() - Random random = new Random() - randomIndex = random.nextInt(10000000) - policyName = "security_policy_${randomIndex}" - watchName = "all-repositories_${randomIndex}" - } - @BeforeTest(groups=["xray"]) - def testSetUp() { - RestAssured.baseURI = "http://${artifactoryURL}/xray/api" - } - - @Test(priority=1, groups=["xray"], dataProvider = "issueEvents", testName = "Create Issue Event") - void createIssueEventTest(issueID, cve, summary, description){ - Response create = createIssueEvent(issueID+randomIndex, cve, summary, description, username, password) - create.then().statusCode(201) - Response get = getIssueEvent(issueID+randomIndex, username, password) - get.then().statusCode(200) - def issueIDverification = get.then().extract().path("id") - def cveVerification = get.then().extract().path("source_id") - def summaryVerification = get.then().extract().path("summary") - def descriptionVerification = get.then().extract().path("description") - Assert.assertTrue(issueID+randomIndex == issueIDverification) - Assert.assertTrue(cve == cveVerification) - Assert.assertTrue(summary == summaryVerification) - Assert.assertTrue(description == descriptionVerification) - - Reporter.log("- Create issue event. Issue event with ID ${issueID+randomIndex} created and verified successfully", true) - } - - @Test(priority=2, groups=["xray"], dataProvider = "issueEvents", testName = "Update Issue Event", - dependsOnMethods = "createIssueEventTest") - void updateIssueEventTest(issueID, cve, summary, description){ - cve = "CVE-2017-0000000" - summary = "Updated" - description = "Updated" - Response update = updateIssueEvent(issueID+randomIndex, cve, summary, description, username, password) - update.then().statusCode(200) - Response get = getIssueEvent(issueID+randomIndex, username, password) - get.then().statusCode(200) - def cveVerification = get.then().extract().path("source_id") - def summaryVerification = get.then().extract().path("summary") - def descriptionVerification = get.then().extract().path("description") - Assert.assertTrue(cve == cveVerification) - Assert.assertTrue(summary == summaryVerification) - Assert.assertTrue(description == descriptionVerification) - - Reporter.log("- Update issue event. Issue event with ID ${issueID+randomIndex} updated and verified successfully", true) - } - - @Test(priority=3, groups=["xray"], testName = "Create policy") - void createPolicyTest(){ - Response create = createPolicy(policyName, username, password) - create.then().statusCode(201) - - Response get = getPolicy(policyName, username, password) - get.then().statusCode(200) - def policyNameVerification = get.then().extract().path("name") - Assert.assertTrue(policyName == policyNameVerification) - - Reporter.log("- Create policy. Policy with name ${policyName} created and verified successfully", true) - } - - @Test(priority=4, groups=["xray"], testName = "Update policy", dependsOnMethods = "createPolicyTest") - void updatePolicyTest(){ - def description = "Updated description" - Response update = updatePolicy(policyName, description, username, password) - update.then().statusCode(200) - - Response get = getPolicy(policyName, username, password) - get.then().statusCode(200) - def descriptionVerification = get.then().extract().path("description") - Assert.assertTrue(description == descriptionVerification) - - Reporter.log("- Update policy. Policy with name ${policyName} updated and verified successfully", true) - } - - @Test(priority=4, groups=["xray"], testName = "Get policies") - void getPoliciesTest(){ - Response response = getPolicies(username, password) - response.then().statusCode(200) - .body("name", notNullValue()) - .body("type", notNullValue()) - .body("description", notNullValue()) - .body("author", notNullValue()) - .body("rules", notNullValue()) - .body("created", notNullValue()) - .body("modified", notNullValue()) - def policies = response.then().extract().path("name") - Reporter.log("- Get policies. Policies list is returned successfully. " + - "Policies returned: ${policies}", true) - } - - @Test(priority=5, groups=["xray"], testName = "Create watch for the repositories", dependsOnMethods = "createPolicyTest") - void createWatchTest(){ - Response create = createWatchEvent(watchName, policyName, username, password) - create.then().statusCode(201) - .body("info", - equalTo("Watch has been successfully created")) - - Response get = getWatchEvent(watchName, username, password) - get.then().statusCode(200) - .body("general_data.name", equalTo((watchName).toString())) - - Reporter.log("- Create watch. Watch with name ${watchName} has been created and verified successfully", true) - } - - @Test(priority=6, groups=["xray"], testName = "Update watch for the repositories", dependsOnMethods = "createWatchTest") - void updateWatchTest(){ - def description = "Updated watch" - Response create = updateWatchEvent(watchName, description, policyName, username, password) - create.then().statusCode(200) - .body("info", - equalTo("Watch was successfully updated")) - - Response get = getWatchEvent(watchName, username, password) - get.then().statusCode(200) - .body("general_data.description", equalTo(description)) - - Reporter.log("- Update watch. Watch with name ${watchName} has been updated and verified successfully", true) - } - - @Test(priority=7, groups=["xray"], testName = "Assign policy to watches") - void assignPolicyToWatchTest(){ - Response response = assignPolicy(watchName, policyName, username, password) - response.then().statusCode(200) - .body("result.${watchName}", - equalTo("Policy assigned successfully to Watch")) - - Reporter.log("- Assign policy to watch. Policy assigned successfully to Watch", true) - } - - @Test(priority=8, groups=["xray"], testName = "Delete watch") - void deleteWatchTest(){ - Response response = deleteWatchEvent(watchName, username, password) - response.then().statusCode(200) - .body("info", - equalTo("Watch was deleted successfully")) - - Reporter.log("- Delete watch. Watch ${watchName} has been successfully deleted", true) - } - - @Test(priority=9, groups=["xray"], testName = "Delete policy") - void deletePolicyTest(){ - - Response response = deletePolicy(policyName, username, password) - response.then().statusCode(200) - .body("info", - equalTo(("Policy ${policyName} was deleted successfully").toString())) - - Reporter.log("- Delete policy. Policy ${policyName} has been successfully deleted", true) - } - -/* @Test(priority=10, groups=["xray"], testName = "Start scan") - void startScanTest(){ - def artifactPath = "default/generic-dev-local/test-directory/artifact.zip" - Response getSha = artifactSummary(username, password, artifactPath) - def componentID = getSha.then().extract().path("artifacts[0].licenses[0].components[0]") - - Response scan = startScan(username, password, componentID) - scan.then().statusCode(200) - .body("info", - equalTo(("Scan of artifact is in progress").toString())) - - Reporter.log("- Start scan. Scan of ${componentID} has been started successfully", true) - }*/ - - @Test(priority=11, groups=["xray"], testName = "Create and get integration configuration") - void integrationConfigurationTest(){ - def vendorName = "vendor_${randomIndex}" - Response post = addtIntegrationConfiguration(username, password, vendorName) - post.then().statusCode(200) - - Response get = getIntegrationConfiguration(username, password) - int bodySize = get.body().jsonPath().getList(".").size() - get.then().statusCode(200) - .body("[" + (bodySize-1) + "].vendor", equalTo(vendorName.toString())) - - Reporter.log("- Integration configuration. " + - "Configuration for vendor ${vendorName} has been successfully added and verified", true) - } - - @Test(priority=12, groups=["xray"], testName = "Enable TLS for RabbitMQ") - void enableTLSRabbitMQTest(){ - File body = new File("./src/test/resources/enableRabbitMQ.json") - Response post = postSystemParameters(username, password, body) - post.then().statusCode(200) - - Response get = getSystemParameters(username, password) - get.then().statusCode(200).body("enableTlsConnectionToRabbitMQ", equalTo(true)) - - Reporter.log("- Enable TLS for RabbitMQ. TLS for RabbitMQ has been successfully enabled and verified", true) - } - - @Test(priority=13, groups=["xray"], testName = "Get binary manager") - void getBinaryManagerTest(){ - Response response = getBinaryManager(username, password) - response.then().statusCode(200) - .body("binMgrId", equalTo("default")) - .body("license_valid", equalTo(true)) - .body("binMgrId", equalTo("default")) - def version = response.then().extract().path("version") - - Reporter.log("- Get binary manager. Binary manager is verified, connected RT version: ${version}", true) - } - - @Test(priority=14, groups=["xray"], testName = "Get repo indexing configuration") - void getIndexingConfigurationTest(){ - Response response = getIndexingConfiguration(username, password) - response.then().statusCode(200) - .body("bin_mgr_id", equalTo("default")) - .body("indexed_repos.name", hasItem("generic-dev-local")) - - Reporter.log("- Get repo indexing configuration.", true) - } - - @Test(priority=15, groups=["xray"], testName = "Update repo indexing configuration") - void updateIndexingConfigurationTest(){ - Response response = updateIndexingConfiguration(username, password) - response.then().statusCode(200) - .body("info", equalTo("Repositories list has been successfully sent to Artifactory")) - - Reporter.log("- Update repo indexing configuration. Successfully updated", true) - } - - // Force reindex test, add in latest versions of X-ray - -/* @Test(priority=16, groups=["xray"], testName = "Get artifact summary") - void artifactSummaryTest(){ - def artifactPath = "default/generic-dev-local/test-directory/artifact.zip" - Response post = artifactSummary(username, password, artifactPath) - post.then().statusCode(200) - .body("artifacts[0].general.path", equalTo(artifactPath)) - - Reporter.log("- Get artifact summary. Artifact summary has been returned successfully", true) - }*/ - - @Test(priority=17, groups=["xray"], testName = "Create support bundle") - void createSupportBundleTest(){ - def name = "Support Bundle" - LocalDate startDate = LocalDate.now().minusDays(5) - LocalDate endDate = LocalDate.now() - Response response = createSupportBundle(username, password, name, startDate, endDate) - def bundle_url = response.then().extract().path("artifactory.bundle_url") - if ((bundle_url.toString()).contains(artifactoryURL)) { - Reporter.log("- Create support bundle. Successfully created using X-ray API", true) - } else if (((bundle_url.toString()).contains("localhost"))){ - Reporter.log("- Create support bundle. Created with a bug, localhost instead of the hostname", true) - } - } - - @Test(priority=18, groups=["xray"], testName = "Get system monitoring status") - void getSystemMonitoringTest(){ - Response response = getSystemMonitoringStatus(username, password) - response.then().statusCode(200) - - Reporter.log("- Get system monitoring status. Data returned successfully", true) - } - - @Test(priority=19, groups=["xray"], testName = "X-ray ping request") - void xrayPingRequestTest(){ - Response response = xrayPingRequest(username, password) - response.then().statusCode(200) - .body("status", equalTo("pong")) - - Reporter.log("- Get system monitoring status. Data returned successfully", true) - } - - @Test(priority=20, groups=["xray"], testName = "X-ray version") - void xrayGetVersionTest(){ - Response response = xrayGetVersion(username, password) - response.then().statusCode(200) - .body("xray_version", notNullValue()) - .body("xray_revision", notNullValue()) - def version = response.then().extract().path("xray_version") - def revision = response.then().extract().path("xray_revision") - - Reporter.log("- Get X-ray version. Version: ${version}, revision: ${revision}", true) - } - - - - -} - - - -