Skip to content

Commit

Permalink
Adjust tests for epocj-filtering Ceph.
Browse files Browse the repository at this point in the history
Fixes #1082

Signed-off-by: Gil Bregman <[email protected]>
  • Loading branch information
gbregman committed Feb 4, 2025
1 parent bda00ca commit 962392f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
13 changes: 9 additions & 4 deletions tests/test_dhchap.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest
from control.server import GatewayServer
import socket
from control.cli import main as cli
from control.cli import main_test as cli_test
from control.cephutils import CephUtils
Expand Down Expand Up @@ -66,7 +65,6 @@
hostpsk1 = "NVMeTLSkey-1:01:YzrPElk4OYy1uUERriPwiiyEJE/+J5ckYpLB+5NHMsR2iBuT:"
hostpsk2 = "NVMeTLSkey-1:01:vUrPe33Auz/sgAAcYctjI0oOOEFM5lheeLy7U+yTsD/LHm9q:"

host_name = socket.gethostname()
addr = "127.0.0.1"
config = "ceph-nvmeof.conf"

Expand All @@ -77,6 +75,8 @@ def gateway(config):

addr = config.get("gateway", "addr")
port = config.getint("gateway", "port")
config.config["gateway"]["name"] = "GW1"
config.config["gateway"]["override_hostname"] = "GW1"
config.config["gateway-logs"]["log_level"] = "debug"
config.config["gateway"]["group"] = ""
config.config["spdk"]["tgt_cmd_extra_args"] = "-m 0x01"
Expand Down Expand Up @@ -108,6 +108,7 @@ def gateway_encryption_disabled(config):
addr = config.get("gateway", "addr")
port = config.getint("gateway", "port") + 2
discport = config.getint("discovery", "port") + 1
config.config["gateway"]["name"] = "GW2"
config.config["gateway"]["override_hostname"] = "GW2"
config.config["gateway"]["port"] = f"{port}"
config.config["discovery"]["port"] = f"{discport}"
Expand Down Expand Up @@ -143,6 +144,7 @@ def gateway_no_encryption_key(config):
addr = config.get("gateway", "addr")
port = config.getint("gateway", "port") + 2
discport = config.getint("discovery", "port") + 1
config.config["gateway"]["name"] = "GW3"
config.config["gateway"]["override_hostname"] = "GW3"
config.config["gateway"]["port"] = f"{port}"
config.config["discovery"]["port"] = f"{discport}"
Expand Down Expand Up @@ -179,6 +181,7 @@ def gateway_no_key_encryption_disabled(config):
addr = config.get("gateway", "addr")
port = config.getint("gateway", "port") + 2
discport = config.getint("discovery", "port") + 1
config.config["gateway"]["name"] = "GW4"
config.config["gateway"]["override_hostname"] = "GW4"
config.config["gateway"]["port"] = f"{port}"
config.config["discovery"]["port"] = f"{discport}"
Expand Down Expand Up @@ -238,8 +241,9 @@ def test_setup(caplog, gateway):


def test_create_secure(caplog, gateway):
gw = gateway
caplog.clear()
cli(["listener", "add", "--subsystem", subsystem, "--host-name", host_name,
cli(["listener", "add", "--subsystem", subsystem, "--host-name", gw.gateway_name,
"-a", addr, "-s", "5001", "--secure"])
assert f"Adding {subsystem} listener at {addr}:5001: Successful" in caplog.text
caplog.clear()
Expand All @@ -263,8 +267,9 @@ def test_create_secure(caplog, gateway):


def test_create_not_secure(caplog, gateway):
gw = gateway
caplog.clear()
cli(["listener", "add", "--subsystem", subsystem, "--host-name", host_name,
cli(["listener", "add", "--subsystem", subsystem, "--host-name", gw.gateway_name,
"-a", addr, "-s", "5002"])
assert f"Adding {subsystem} listener at {addr}:5002: Successful" in caplog.text
caplog.clear()
Expand Down
14 changes: 9 additions & 5 deletions tests/test_psk.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest
from control.server import GatewayServer
import socket
from control.cli import main as cli
from control.cli import main_test as cli_test
from control.cephutils import CephUtils
Expand Down Expand Up @@ -50,7 +49,6 @@

hostdhchap1 = "DHHC-1:00:MWPqcx1Ug1debg8fPIGpkqbQhLcYUt39k7UWirkblaKEH1kE:"

host_name = socket.gethostname()
addr = "127.0.0.1"
config = "ceph-nvmeof.conf"

Expand All @@ -61,6 +59,8 @@ def gateway(config):

addr = config.get("gateway", "addr")
port = config.getint("gateway", "port")
config.config["gateway"]["name"] = "GW1"
config.config["gateway"]["override_hostname"] = "GW1"
config.config["gateway-logs"]["log_level"] = "debug"
config.config["gateway"]["group"] = ""
config.config["spdk"]["tgt_cmd_extra_args"] = "-m 0x03"
Expand Down Expand Up @@ -92,6 +92,7 @@ def gateway_no_encryption_key(config):
addr = config.get("gateway", "addr")
port = config.getint("gateway", "port") + 2
discport = config.getint("discovery", "port") + 1
config.config["gateway"]["name"] = "GW2"
config.config["gateway"]["override_hostname"] = "GW2"
config.config["gateway"]["port"] = f"{port}"
config.config["discovery"]["port"] = f"{discport}"
Expand Down Expand Up @@ -131,12 +132,13 @@ def test_setup(caplog, gateway):


def test_create_secure_with_any_host(caplog, gateway):
gw = gateway
caplog.clear()
cli(["host", "add", "--subsystem", subsystem, "--host-nqn", "*"])
assert f"Allowing open host access to {subsystem}: Successful" in caplog.text
caplog.clear()
cli(["listener", "add", "--subsystem", subsystem,
"--host-name", host_name, "-a", addr, "-s", "5001", "--secure"])
"--host-name", gw.gateway_name, "-a", addr, "-s", "5001", "--secure"])
assert "Secure channel is only allowed for subsystems in which " \
"\"allow any host\" is off" in caplog.text
caplog.clear()
Expand All @@ -145,9 +147,10 @@ def test_create_secure_with_any_host(caplog, gateway):


def test_create_secure(caplog, gateway):
gw = gateway
caplog.clear()
cli(["listener", "add", "--subsystem", subsystem,
"--host-name", host_name, "-a", addr, "-s", "5001", "--secure"])
"--host-name", gw.gateway_name, "-a", addr, "-s", "5001", "--secure"])
assert f"Adding {subsystem} listener at {addr}:5001: Successful" in caplog.text
caplog.clear()
cli(["host", "add", "--subsystem", subsystem, "--host-nqn", hostnqn1, "--psk", hostpsk1])
Expand All @@ -163,9 +166,10 @@ def test_create_secure(caplog, gateway):


def test_create_not_secure(caplog, gateway):
gw = gateway
caplog.clear()
cli(["listener", "add", "--subsystem", subsystem,
"--host-name", host_name, "-a", addr, "-s", "5002"])
"--host-name", gw.gateway_name, "-a", addr, "-s", "5002"])
assert f"Adding {subsystem} listener at {addr}:5002: Successful" in caplog.text
caplog.clear()
cli(["host", "add", "--subsystem", subsystem, "--host-nqn", hostnqn6])
Expand Down

0 comments on commit 962392f

Please sign in to comment.