Updating Dockerfile, generic.resoscript, and removing assertions from the runRESOScript action. Gradle should be used for assertion testing. See README

This commit is contained in:
Joshua Darnell 2020-02-26 18:38:50 -08:00
parent 8fb7fb06ed
commit b84d62620a
9 changed files with 26 additions and 62 deletions

View File

@ -4,7 +4,7 @@ WORKDIR /home/gradle/project
ADD . ./
RUN gradle copyJarToOut
RUN gradle jar
RUN ls
@ -13,7 +13,7 @@ FROM alpine:latest
RUN apk add --update bash ca-certificates openjdk8-jre-base nss && \
rm -rf /var/cache/apk/*
COPY --from=builder /home/gradle/project/out/web-api-commander.jar ./
COPY --from=builder /home/gradle/project/build/libs/web-api-commander.jar ./
ENTRYPOINT ["java","-jar","/web-api-commander.jar"]
CMD ["--help"]

View File

@ -296,7 +296,6 @@ The XML DTD for this schema is as follows:
<!ELEMENT Requests (Request)*>
<!ELEMENT Request (#PCDATA)*>
<!ATTLIST Request
AssertResponseCode CDATA #IMPLIED
Capability CDATA #REQUIRED
MetallicLevel CDATA #REQUIRED
OutputFile CDATA #REQUIRED

View File

@ -8,7 +8,6 @@ plugins {
// Define the main class for the application
mainClassName = 'org.reso.commander.Main'
version = "0.1.1"
sourceCompatibility = 1.8
targetCompatibility = 1.8

Binary file not shown.

View File

@ -27,7 +27,6 @@
<!ELEMENT Requests (Request)*>
<!ELEMENT Request (#PCDATA)*>
<!ATTLIST Request
AssertResponseCode CDATA #IMPLIED
Capability CDATA #REQUIRED
MetallicLevel CDATA #REQUIRED
OutputFile CDATA #REQUIRED
@ -204,7 +203,6 @@
WebAPIReference="2.4.1"
OutputFile="REQ-WA103-QR1.select.uniqueId.json"
Url="*ClientSettings_WebAPIURI*/*Parameter_EndpointResource*(*Parameter_UniqueIDValue*)?$select=*Parameter_UniqueID*"
AssertResponseCode="200"
/>
<Request
@ -238,47 +236,43 @@
/>
<Request
TestDescription="Query Support: $select case-sensitivity"
TestDescription="Query Support: $select case-sensitivity. Expect 400 response on OData 4.0"
RequirementId="REQ-WA103-QO1.select.case"
MetallicLevel="Core"
Capability="Core"
WebAPIReference="2.4.4"
OutputFile="REQ-WA103-QO1.select.case.json"
Url="*ClientSettings_WebAPIURI*/*Parameter_EndpointResource*?$top=*Parameter_TopCount*&amp;$SeLeCt=*Parameter_SelectList*&amp;$filter=*Parameter_FilterIntegerField* eq *Parameter_FilterIntegerValueLow**Parameter_RequiredParameters*"
AssertResponseCode="400"
/>
<Request
TestDescription="Query Support: $filter case-sensitivity"
TestDescription="Query Support: $filter case-sensitivity. Expect 400 response on OData 4.0"
RequirementId="REQ-WA103-QO1.filter.case"
MetallicLevel="Core"
Capability="Core"
WebAPIReference="2.4.4"
OutputFile="REQ-WA103-QO1.filter.case.json"
Url="*ClientSettings_WebAPIURI*/*Parameter_EndpointResource*?$top=*Parameter_TopCount*&amp;$select=*Parameter_SelectList*&amp;$FiLtEr=*Parameter_FilterIntegerField* eq *Parameter_FilterIntegerValueLow**Parameter_RequiredParameters*"
AssertResponseCode="400"
/>
<Request
TestDescription="Query Support: $orderby asc case-sensitivity"
TestDescription="Query Support: $orderby asc case-sensitivity. Expect 400 response on OData 4.0"
RequirementId="REQ-WA103-QO1.orderby.asc.case"
MetallicLevel="Core"
Capability="Core"
WebAPIReference="2.4.4"
OutputFile="REQ-WA103-QO1.orderby.asc.case.json"
Url="*ClientSettings_WebAPIURI*/*Parameter_EndpointResource*?$top=*Parameter_SortCount*&amp;$select=*Parameter_FilterIntegerField*&amp;$filter=*Parameter_FilterIntegerField* gt *Parameter_FilterIntegerValueLow**Parameter_RequiredParameters*&amp;$OrDeRbY=*Parameter_FilterIntegerField* asc"
AssertResponseCode="400"
/>
<Request
TestDescription="Query Support: $orderby desc case-sensitivity"
TestDescription="Query Support: $orderby desc case-sensitivity. Expect 400 response on OData 4.0"
RequirementId="REQ-WA103-QO1.orderby.desc.case"
MetallicLevel="Core"
Capability="Core"
WebAPIReference="2.4.4"
OutputFile="REQ-WA103-QO1.orderby.desc.case.json"
Url="*ClientSettings_WebAPIURI*/*Parameter_EndpointResource*?$top=*Parameter_SortCount*&amp;$select=*Parameter_FilterIntegerField*&amp;$filter=*Parameter_FilterIntegerField* gt *Parameter_FilterIntegerValueLow**Parameter_RequiredParameters*&amp;$oRdErBy=*Parameter_FilterIntegerField* desc"
AssertResponseCode="400"
/>
<Request
@ -764,58 +758,53 @@
<!-- RESPONSE CODE SUPPORT -->
<Request
TestDescription="Assert 200 OK Request"
TestDescription="200 OK Request"
RequirementId="REQ-WA103-RC3"
MetallicLevel="Core"
Capability="Core"
WebAPIReference="2.5.2"
OutputFile="REQ-WA103-RC05_200OKRequest.json"
Url="ClientSettings_WebAPIURI*/*Parameter_200_OK*"
AssertResponseCode="200"
/>
<Request
TestDescription="Assert 400 Bad Request"
TestDescription="400 Bad Request"
RequirementId="REQ-WA103-RC5"
MetallicLevel="Core"
Capability="Core"
WebAPIReference="2.5.2"
OutputFile="REQ-WA103-RC05_400BadRequest.json"
Url="ClientSettings_WebAPIURI*/*Parameter_400BadRequest*"
AssertResponseCode="400"
/>
<Request
TestDescription="Assert 403 Forbidden Request"
TestDescription="403 Forbidden Request"
RequirementId="REQ-WA103-RC06"
MetallicLevel="Core"
Capability="Core"
WebAPIReference="2.5.2"
OutputFile="REQ-WA103-RC06_403Forbidden_Generic.json"
Url="ClientSettings_WebAPIURI*/*Parameter_403Forbidden*"
AssertResponseCode="403"
/>
<Request
TestDescription="Assert 404 Not Found Request"
TestDescription="404 Not Found Request"
RequirementId="REQ-WA103-RC07"
MetallicLevel="Core"
Capability="Core"
WebAPIReference="2.5.2"
OutputFile="REQ-WA103-RC07_404NotFound.json"
Url="*ClientSettings_WebAPIURI*/*Parameter_404NotFound*"
AssertResponseCode="404"
/>
<Request
TestDescription="Assert 501 Not Implemented Request"
TestDescription="501 Not Implemented Request"
RequirementId="REQ-WA103-RC11"
MetallicLevel="Core"
Capability="Core"
WebAPIReference="2.5.2"
OutputFile="REQ-WA103-RC11_501NotImplemented.json"
Url="*ClientSettings_WebAPIURI*/*Parameter_501NotImplemented*"
AssertResponseCode="501"
/>
</Requests>

View File

@ -170,12 +170,12 @@ public class App {
//TODO: create dynamic JUnit (or similar) test runner
LOG.info(SMALL_DIVIDER);
LOG.info("Assertion: #" + (i + 1));
LOG.info("Request: #" + (i + 1));
LOG.info(SMALL_DIVIDER);
LOG.info("Assertion Name: " + request.getName());
LOG.info("Request Name: " + request.getName());
//TODO: function-ize the property test
LOG.info("Assertion Description: " + (request.getTestDescription().length() > 0 ? request.getTestDescription() : "Not Specified"));
LOG.info("Description: " + (request.getTestDescription().length() > 0 ? request.getTestDescription() : "Not Specified"));
LOG.info("Requirement Id: " + (request.getRequirementId().length() > 0 ? request.getRequirementId() : "Not Specified"));
LOG.info("Metallic Level: " + (request.getMetallicLevel().length() > 0 ? request.getMetallicLevel() : "Not Specified"));
LOG.info("Capability: " + (request.getCapability().length() > 0 ? request.getCapability() : "Not Specified"));
@ -200,6 +200,8 @@ public class App {
if (responseCode == HttpStatus.SC_OK) {
STATS.updateRequest(request, Request.Status.SUCCEEDED);
} else {
STATS.updateRequest(request, Request.Status.FAILED);
}
if (request.getOutputFile().toLowerCase().contains(EDMX_EXTENSION.toLowerCase())) {
@ -210,16 +212,9 @@ public class App {
LOG.error("Error: Invalid metadata retrieved. Cannot continue!!");
System.exit(NOT_OK);
}
} else if (responseCode != null && request.getAssertResponseCode() != null) {
if (responseCode == Integer.parseInt(request.getAssertResponseCode())) {
LOG.info("Assert Response Code " + request.getAssertResponseCode() + " passed!");
} else {
LOG.error("Request " + request.getName() + " Failed!");
STATS.updateRequest(request, Request.Status.FAILED);
}
}
} else {
LOG.info("Request " + request.getRequirementId() + " has an empty URL. Skipping...");
STATS.updateRequest(request, Request.Status.SKIPPED);
}
} catch (Exception ex) {
@ -228,10 +223,6 @@ public class App {
LOG.error("Stack trace:");
Arrays.stream(ex.getStackTrace()).forEach(stackTraceElement -> LOG.error(stackTraceElement.toString()));
} finally {
if (request != null && STATS.getRequests().size() > 0) {
LOG.info("Request " + STATS.getRequests().get(request).getStatus().toString().toLowerCase() + "!");
}
if (resolvedUrl != null && resolvedUrl.length() > 0) {
LOG.info("Elapsed Time: " + String.format("%.2f", (STATS.getRequests().get(request).getElapsedTimeMillis() / 1000.0)) + "s");
}
@ -443,7 +434,7 @@ public class App {
numIncomplete = stats.getRequestCount(Request.Status.STARTED);
reportBuilder.append("\n\n" + DIVIDER);
reportBuilder.append("\nAssertion Statistics");
reportBuilder.append("\nRequest Statistics");
reportBuilder.append("\n" + DIVIDER);
reportBuilder.append(generateTotalsReport(stats.totalRequestCount(), numSucceeded, numFailed, numSkipped, numIncomplete));
@ -462,7 +453,7 @@ public class App {
numSkipped = stats.filterByMetallicCertification(metallicKey, stats.filterByStatus(Request.Status.SKIPPED)).size();
numIncomplete = stats.filterByMetallicCertification(metallicKey, stats.filterByStatus(Request.Status.STARTED)).size();
reportBuilder.append("\n\n").append(metallicKey).append(numSucceeded > 0 && numSucceeded == (requestCount - numSkipped) ? " - REQUESTS SUCCEEDED!" : "");
reportBuilder.append("\n\n").append(metallicKey).append(numSucceeded > 0 && numSucceeded == (requestCount - numSkipped) ? " - ALL REQUESTS SUCCEEDED!" : "");
reportBuilder.append(generateTotalsReport(requestCount, numSucceeded, numFailed, numSkipped, numIncomplete));
}
@ -477,7 +468,7 @@ public class App {
numSkipped = stats.filterByCapability(capabilityKey, stats.filterByStatus(Request.Status.SKIPPED)).size();
numIncomplete = stats.filterByCapability(capabilityKey, stats.filterByStatus(Request.Status.STARTED)).size();
reportBuilder.append("\n\n").append(capabilityKey).append(numSucceeded > 0 && numSucceeded == (requestCount - numSkipped) ? " - REQUESTS SUCCEEDED!" : "");
reportBuilder.append("\n\n").append(capabilityKey).append(numSucceeded > 0 && numSucceeded == (requestCount - numSkipped) ? " - ALL REQUESTS SUCCEEDED!" : "");
reportBuilder.append(generateTotalsReport(requestCount, numSucceeded, numFailed, numSkipped, numIncomplete));
}
reportBuilder.append("\n" + DIVIDER + "\n");

View File

@ -24,7 +24,6 @@ public class Request {
private String metallicLevel;
private String capability;
private String webApiReference;
private String assertResponseCode;
private Request request;
private Status status;
@ -41,7 +40,7 @@ public class Request {
* @param url
*/
public Request(String requirementId, String outputFile, String url, String testDescription, String metallicLevel,
String capability, String webApiReference, String assertResponseCode) {
String capability, String webApiReference) {
//TODO: add Builder
setRequirementId(requirementId);
@ -51,7 +50,6 @@ public class Request {
setMetallicLevel(metallicLevel);
setCapability(capability);
setWebApiReference(webApiReference);
setAssertResponseCode(assertResponseCode);
}
@ -123,8 +121,7 @@ public class Request {
String expression = "/OutputScript/" + REQUESTS_KEY + "/node()";
NodeList nodes = (NodeList) xPath.compile(expression).evaluate(xmlDocument, XPathConstants.NODESET);
Node node;
String name, outputFile, url, testDescription, requirementId, metallicLevel, capability, webApiReference,
assertResponseCode;
String name, outputFile, url, testDescription, requirementId, metallicLevel, capability, webApiReference;
Request request;
for (int i = 0; i < nodes.getLength(); i++) {
@ -138,9 +135,8 @@ public class Request {
metallicLevel = safeGetNamedItem(FIELDS.METALLIC_LEVEL, node);
capability = safeGetNamedItem(FIELDS.CAPABILITY, node);
webApiReference = safeGetNamedItem(FIELDS.WEB_API_REFERENCE, node);
assertResponseCode = safeGetNamedItem(FIELDS.ASSERT_RESPONSE_CODE, node);
request = new Request(requirementId, outputFile, url, testDescription, metallicLevel, capability, webApiReference, assertResponseCode);
request = new Request(requirementId, outputFile, url, testDescription, metallicLevel, capability, webApiReference);
name = safeGetNamedItem(FIELDS.NAME, node);
request.setName(name == null ? outputFile : name);
@ -249,14 +245,6 @@ public class Request {
this.webApiReference = webApiReference;
}
public String getAssertResponseCode() {
return assertResponseCode;
}
public void setAssertResponseCode(String assertResponseCode) {
this.assertResponseCode = assertResponseCode;
}
private static final class FIELDS {
static final String NAME = "Name";
static final String OUTPUT_FILE = "OutputFile";
@ -266,6 +254,5 @@ public class Request {
static final String METALLIC_LEVEL = "MetallicLevel";
static final String CAPABILITY = "Capability";
static final String WEB_API_REFERENCE = "WebAPIReference";
static final String ASSERT_RESPONSE_CODE = "AssertResponseCode";
}
}

View File

@ -59,7 +59,7 @@ public class Settings {
public static Request resolveParameters(Request request, Settings settings) {
//calls to resolve nested parameters
return new Request(request.getRequirementId(), request.getOutputFile(), resolveParametersString(request.getUrl(), settings), request.getTestDescription(),
request.getMetallicLevel(), request.getCapability(), request.getWebApiReference(), request.getAssertResponseCode());
request.getMetallicLevel(), request.getCapability(), request.getWebApiReference());
}
/**

View File

@ -6,8 +6,7 @@ package org.reso.commander;
import org.junit.Test;
public class AppTest {
@Test public void testAppHasAGreeting() {
App classUnderTest = new App();
//assertNotNull("app should have a greeting", classUnderTest.getGreeting());
@Test public void testParameterDeserialization() {
//TODO
}
}