Skip to content

Commit

Permalink
Revert "Adapt test case for glue:R0036 to replacement requirement glu…
Browse files Browse the repository at this point in the history
…e:R0036_0" (#32)

Reverts #17

Reason is that R0036_0 is broken on main now and the implementation can
not work conceptionally i.e. it requires full refactoring.
  • Loading branch information
maximilianpilz committed Nov 9, 2022
1 parent 0292d4a commit 91487ab
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 231 deletions.
3 changes: 0 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- test for biceps:5-4-7_12_0
- test for biceps:5-4-7_14

### Changed
- updated test case for glue:R0036 to glue:R0036_0

### Fixed
- missing request bodies in glue:R0036 test
- some vulnerabilities due to old dependencies
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ The test tool has the following limitations. If the DUT falls under these limita

| **Requirement** | **T2IAPI Manipulation** |
|-----------------|-------------------------|
| R0036_0 | SetLocationDetail |
| R0036 | SetLocationDetail |


## Notices
Expand Down
2 changes: 1 addition & 1 deletion configuration/test_configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ R0011=true
R0012_0_0=true
R0013=true
R0034_0=true
R0036_0=true
R0036=true
R0042_0=true
R0072=true
R0080=true
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public final class EnabledTestConfig {
public static final String GLUE_R0012_0_0 = GLUE + "R0012_0_0";
public static final String GLUE_R0013 = GLUE + "R0013";
public static final String GLUE_R0034_0 = GLUE + "R0034_0";
public static final String GLUE_R0036_0 = GLUE + "R0036_0";
public static final String GLUE_R0036 = GLUE + "R0036";
public static final String GLUE_R0042_0 = GLUE + "R0042_0";
public static final String GLUE_R0072 = GLUE + "R0072";
public static final String GLUE_R0080 = GLUE + "R0080";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.somda.sdc.biceps.model.participant.LocationDetail;
import org.somda.sdc.biceps.model.participant.Mdib;
import org.somda.sdc.biceps.model.participant.MdsDescriptor;
import org.somda.sdc.dpws.CommunicationLog;
import org.somda.sdc.dpws.factory.CommunicationLogFactory;
import org.somda.sdc.dpws.http.HttpServerRegistry;
import org.somda.sdc.dpws.service.HostedServiceProxy;
Expand All @@ -43,7 +42,6 @@
import org.somda.sdc.dpws.soap.RequestResponseClient;
import org.somda.sdc.dpws.soap.SoapMessage;
import org.somda.sdc.dpws.soap.SoapUtil;
import org.somda.sdc.dpws.soap.exception.MalformedSoapMessageException;
import org.somda.sdc.dpws.soap.exception.MarshallingException;
import org.somda.sdc.dpws.soap.exception.SoapFaultException;
import org.somda.sdc.dpws.soap.exception.TransportException;
Expand All @@ -58,13 +56,11 @@
import org.somda.sdc.dpws.soap.wseventing.model.DeliveryType;
import org.somda.sdc.dpws.soap.wseventing.model.FilterType;
import org.somda.sdc.dpws.soap.wseventing.model.Subscribe;
import org.somda.sdc.dpws.soap.wseventing.model.SubscribeResponse;
import org.somda.sdc.glue.common.ActionConstants;
import org.somda.sdc.glue.common.WsdlConstants;

import javax.xml.namespace.QName;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -105,7 +101,6 @@ public class DirectSubscriptionHandlingTest extends InjectorTestBase {
private WsAddressingUtil wsaUtil;
private WsEventingEventSinkFactory eventSinkFactory;
private String adapterAddress;
private CommunicationLog commLog;

@BeforeEach
void setUp() {
Expand All @@ -123,9 +118,6 @@ void setUp() {
this.adapterAddress = getInjector().getInstance(
Key.get(String.class, Names.named(TestSuiteConfig.NETWORK_INTERFACE_ADDRESS))
);
this.commLog = testClient.getInjector().getInstance(CommunicationLogFactory.class)
.createCommunicationLog();

}

@Test
Expand Down Expand Up @@ -182,14 +174,11 @@ private void checkServiceConformance(final QName targetQName) {
}

@Test
@TestIdentifier(EnabledTestConfig.GLUE_R0036_0)
@DisplayName("An SDC SERVICE PROVIDER SHALL terminate a subscription if the delivery of one MESSAGE"
+ " related to that subscription failed.")
@TestDescription("Subscribes to all Reports, checks that all Subscriptions are active, then"
+ " triggers an EpisodicContextReport and intentionally fails to receive it. Afterwards,"
+ " it checks that the Subscription to the EpisodicContextReport has been cancelled by"
+ " the provider while all other subscriptions are still active.")
void testRequirementR00360() throws InterruptedException {
@TestIdentifier(EnabledTestConfig.GLUE_R0036)
@TestDescription("Subscribes to all Reports, checks that all Subscriptions are active, then triggers"
+ " an EpisodicContextReport and intentionally fails to receive it. Afterwards, it checks that all"
+ " Subscriptions have been cancelled by the provider.")
void testRequirementR0036() throws InterruptedException {

// preparation
final LocationContextState locationContext = getOrCreateLocationContextState();
Expand All @@ -216,7 +205,8 @@ void testRequirementR00360() throws InterruptedException {
}
manipulations.setLocationDetail(locationDetail);
});
final List<ReportTestData> otherReports = List.of(
final List<ReportTestData> reports = List.of(
triggerableReport,
new ReportTestData(
WsdlConstants.OPERATION_OPERATION_INVOKED_REPORT,
ActionConstants.ACTION_OPERATION_INVOKED_REPORT,
Expand Down Expand Up @@ -303,28 +293,14 @@ void testRequirementR00360() throws InterruptedException {
// does not need to be triggered in this test.
})
);
final List<ReportTestData> reports = new ArrayList<>();
reports.add(triggerableReport);
reports.addAll(otherReports);

subscribeToAllReports(reports);

checkSubscriptionsAreActive(reports);

triggerReportAndIntentionallyFailReceivingIt(triggerableReport);

checkThatSubscriptionsHaveBeenCancelled(List.of(triggerableReport));
checkThatOtherSubscriptionsHaveNotBeenCancelled(otherReports);
}

private void checkThatOtherSubscriptionsHaveNotBeenCancelled(final List<ReportTestData> reports) {
for (ReportTestData report : reports) {
if (report.getSubscription() != null) {
final Duration status = getSubscriptionStatus(report);
assertNotNull(status, "Subscription for report " + report.getReportName()
+ " has been unexpectedly cancelled.");
}
}
checkThatAllSubscriptionsAreCancelled(reports);
}

private void subscribeToAllReports(final List<ReportTestData> reports) {
Expand Down Expand Up @@ -368,8 +344,7 @@ private void nanoWait(final Object syncPoint, final long duration) throws Interr
syncPoint.wait(millis, (int) nanos);
}

private void checkThatSubscriptionsHaveBeenCancelled(final List<ReportTestData> reports)
throws InterruptedException {
private void checkThatAllSubscriptionsAreCancelled(final List<ReportTestData> reports) throws InterruptedException {
final long timeoutWaitingForCancellations = System.nanoTime() + TIMEOUT_NANOS;
final HashSet<ReportTestData> uncancelledSubscriptions = new HashSet<>(reports);
while (!uncancelledSubscriptions.isEmpty() && System.nanoTime() < timeoutWaitingForCancellations) {
Expand All @@ -385,7 +360,7 @@ private void checkThatSubscriptionsHaveBeenCancelled(final List<ReportTestData>
.map(ReportTestData::getReportName)
.collect(Collectors.toList());
fail("Reports " + String.join(", ", subscriptions) + " have not been cancelled by the provider"
+ " although they should have been according to glue:R0036_0.");
+ " although they should have been according to glue:R0036.");
}
}

Expand Down Expand Up @@ -570,34 +545,12 @@ private void subscribeToReportWithTheAbilityToFail(final String baseURI,
soapResponse = requestResponseClient.sendRequestResponse(subscribeRequest);
if (soapResponse.isFault()) {
throw new RuntimeException("Could not subscribe to " + reportName + ".");
} else {
final SubscribeResponse responseBody = soapUtil
.getBody(soapResponse, SubscribeResponse.class)
.orElseThrow(() -> new MalformedSoapMessageException("Cannot read WS-Eventing Subscribe response"));

reportTestData.setSubscription(
new SubscribeResult(determineSubscriptionIdForAction(action), responseBody.getExpires()));
final EventSink eventSink =
eventSinkFactory.createWsEventingEventSink(requestResponseClient, baseURI, commLog);
reportTestData.setEventSink(eventSink);

}
} catch (SoapFaultException | MarshallingException | TransportException | InterceptorException e) {
fail("encountered Exception while subscribing to " + reportName, e);
}
}

/**
* Determine SubscriptionId for a report with the given action.
* This method exists so a test case can override it and set the subscriptionId
* according to its needs.
* @param action the name of the report for which the context suffix should be determined.
* @return the context suffix.
*/
public String determineSubscriptionIdForAction(final String action) {
return UUID.randomUUID().toString();
}

private String getLocalBaseURI() {
return String.format("https://%s:0", this.adapterAddress);
}
Expand Down
Loading

0 comments on commit 91487ab

Please sign in to comment.