Skip to content

Commit

Permalink
Merge pull request #97 from ELEVATE-Project/GetReviewerBranch
Browse files Browse the repository at this point in the history
added GetReviewerList api script
  • Loading branch information
gagannani authored Nov 8, 2024
2 parents fec3dbf + 5720492 commit a368e46
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 99 deletions.
3 changes: 0 additions & 3 deletions Elevate_QA_API.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,9 @@
<methods>
<include name="testAddingValidEntity"/>
<include name="testAddingInvalidEntity"/>


</methods>
</class>
</classes>
</test>
</suite>


6 changes: 6 additions & 0 deletions SanitySuiteSCP_API.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
</methods>
</class>

<class name="org.shikshalokam.backend.scp.TestGetReviewerList">
<methods>
<include name="testGetReviewerList"/>
</methods>
</class>

</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
3 changes: 3 additions & 0 deletions src/main/resources/config/automation_SCPAPI_QA.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ scp.update.entity.endpoint=/scp/v1/entities/update/
scp.delete.entity.endpoint=/scp/v1/entities/delete/
scp.read.entity.endpoint=/scp/v1/entities/read/
scp.delete.entitytype.endpoint=/scp/v1/entity-types/delete/
scp.getreviewer.id=Content_reviewer@guerrillamail.info
scp.getreviewer.pass=Password@123
scp.getreviewer.list.verify=all_rights@yopmail.com

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,4 @@ private Response findUserRoleExtension() {
return response;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package org.shikshalokam.backend.scp;

import static io.restassured.RestAssured.given;
import static org.shikshalokam.backend.PropertyLoader.*;
import static org.testng.Assert.*;

import io.restassured.response.Response;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

import java.net.URI;
import java.net.URISyntaxException;

public class TestGetReviewerList extends SelfCreationPortalBaseTest {
private static final Logger logger = LogManager.getLogger(TestGetReviewerList.class);

@BeforeTest
public void init() {
logger.info("Logging into the application:");
loginToScp(
PROP_LIST.get("scp.getreviewer.id").toString(),
PROP_LIST.get("scp.getreviewer.pass").toString()
);
}

@Test
public void testGetReviewerList() {
logger.info("Started calling the reviewerList API:");
URI endpoint;
try {
endpoint = new URI("https://scp-qa.elevate-apis.shikshalokam.org/scp/v1/projects/reviewerList");
} catch (URISyntaxException e) {
throw new RuntimeException("Error constructing URI for reviewerList API", e);
}

Response response = given()
.header("X-auth-token", "bearer " + X_AUTH_TOKEN)
.when()
.get(endpoint);

assertEquals(response.getStatusCode(), 200, "Status code failed for fetching reviewerList");

String responseBody = response.getBody().asString();
logger.info("Response: " + responseBody);

// Retrieve the expected email from the properties file with a null check
String expectedEmail = PROP_LIST.getProperty("scp.getreviewer.list.verify");
if (expectedEmail == null) {
throw new RuntimeException("Property 'scp.getreviewer.list.verify' is missing in the properties file.");
}

// Verify if the response contains the expected email
assertTrue(responseBody.contains(expectedEmail),
"Expected email '" + expectedEmail + "' not found in the response.");

logger.info("Verified that the expected email '" + expectedEmail + "' is present in the response.");
}
}

0 comments on commit a368e46

Please sign in to comment.