mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 05:17:13 +02:00
703rc/fix port size (#802)
* validate port numbers in client * validate port numbers created at virtual servers and receiver process as tcp ports
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
#include "sls/Detector.h"
|
||||
#include "sls/file_utils.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
#include "test-CmdProxy-global.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <sstream>
|
||||
@ -76,7 +77,13 @@ TEST_CASE("hostname", "[.cmd]") {
|
||||
REQUIRE_NOTHROW(proxy.Call("hostname", {}, -1, GET));
|
||||
}
|
||||
|
||||
// virtual: not testing
|
||||
TEST_CASE("virtual", "[.cmd]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
REQUIRE_THROWS(proxy.Call("virtual", {}, -1, GET));
|
||||
test_valid_port("virtual", {"1"}, -1, PUT);
|
||||
test_valid_port("virtual", {"3", "65534"}, -1, PUT, 65536);
|
||||
}
|
||||
|
||||
TEST_CASE("versions", "[.cmd]") {
|
||||
Detector det;
|
||||
@ -2618,6 +2625,13 @@ TEST_CASE("udp_dstport", "[.cmd]") {
|
||||
proxy.Call("udp_dstport", {"50084"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "udp_dstport 50084\n");
|
||||
}
|
||||
test_valid_port("udp_dstport", {}, -1, PUT);
|
||||
test_valid_port("udp_dstport", {}, 0, PUT);
|
||||
// should fail for the second module
|
||||
if (det.size() > 1) {
|
||||
test_valid_port("udp_dstport", {"65535"}, -1, PUT, 65536);
|
||||
}
|
||||
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setDestinationUDPPort(prev_val[i], {i});
|
||||
}
|
||||
@ -2702,8 +2716,18 @@ TEST_CASE("udp_dstport2", "[.cmd]") {
|
||||
proxy.Call("udp_dstport2", {"50084"}, -1, PUT, oss);
|
||||
REQUIRE(oss.str() == "udp_dstport2 50084\n");
|
||||
}
|
||||
|
||||
test_valid_port("udp_dstport2", {}, -1, PUT);
|
||||
test_valid_port("udp_dstport2", {}, 0, PUT);
|
||||
// should fail for the second module
|
||||
if (det.size() > 1) {
|
||||
test_valid_port("udp_dstport2", {"65535"}, -1, PUT, 65536);
|
||||
}
|
||||
|
||||
for (int i = 0; i != det.size(); ++i) {
|
||||
det.setDestinationUDPPort2(prev_val[i], {i});
|
||||
if (prev_val[i] != 0) {
|
||||
det.setDestinationUDPPort2(prev_val[i], {i});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
REQUIRE_THROWS(proxy.Call("udp_dstport2", {}, -1, GET));
|
||||
@ -2922,6 +2946,13 @@ TEST_CASE("zmqport", "[.cmd]") {
|
||||
std::to_string(port + i * socketsperdetector) +
|
||||
'\n');
|
||||
}
|
||||
test_valid_port("zmqport", {}, -1, PUT);
|
||||
test_valid_port("zmqport", {}, 0, PUT);
|
||||
// should fail for the second module
|
||||
if (det.size() > 1) {
|
||||
test_valid_port("zmqport", {"65535"}, -1, PUT, 65536);
|
||||
}
|
||||
|
||||
if (det_type == defs::JUNGFRAU) {
|
||||
det.setNumberofUDPInterfaces(prev);
|
||||
}
|
||||
@ -3266,6 +3297,13 @@ TEST_CASE("port", "[.cmd]") {
|
||||
proxy.Call("port", {}, 0, GET, oss);
|
||||
REQUIRE(oss.str() == "port 1942\n");
|
||||
}
|
||||
test_valid_port("port", {}, -1, PUT);
|
||||
test_valid_port("port", {}, 0, PUT);
|
||||
// should fail for the second module
|
||||
if (det.size() > 1) {
|
||||
test_valid_port("port", {"65536"}, -1, PUT, 65536);
|
||||
}
|
||||
|
||||
det.setControlPort(prev_val, {0});
|
||||
}
|
||||
|
||||
@ -3283,6 +3321,12 @@ TEST_CASE("stopport", "[.cmd]") {
|
||||
proxy.Call("stopport", {}, 0, GET, oss);
|
||||
REQUIRE(oss.str() == "stopport 1942\n");
|
||||
}
|
||||
test_valid_port("stopport", {}, -1, PUT);
|
||||
test_valid_port("stopport", {}, 0, PUT);
|
||||
// should fail for the second module
|
||||
if (det.size() > 1) {
|
||||
test_valid_port("stopport", {"65536"}, -1, PUT, 65536);
|
||||
}
|
||||
det.setStopPort(prev_val, {0});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user