Skip to content

Commit

Permalink
Fix remote_enrollment tests
Browse files Browse the repository at this point in the history
  • Loading branch information
palaciosjeremias committed Nov 4, 2021
1 parent 1101f8d commit 017a1d1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/integration/test_authd/test_authd_agents_ctx.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def register_agent_main_server(Name, Group=None, IP=None):

def register_agent_local_server(Name, Group=None, IP=None):
message = ('{"arguments":{"force":{"enabled":true,"disconnected_time":{"enabled":true,"value":"0"},'
'"key_mismatch":true,"after_registration_time":"0"}')
'"key_mismatch":true,"after_registration_time":"0"}')
message += ',"name":"{}"'.format(Name)
if Group:
message += ',"groups":"{}"'.format(Group)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_authd/test_authd_ssl_certs.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def callback_agentd_startup(line):
time.sleep(1)


def test_authd_ssl_certs(get_configuration, generate_ca_certificate):
def test_authd_ssl_certs(get_configuration, generate_ca_certificate, tear_down):
'''
description: Check if the 'wazuh-authd' daemon can manage 'SSL' connections with agents
and the 'host verification' feature is working properly. For this purpose,
Expand Down
14 changes: 11 additions & 3 deletions tests/integration/test_authd/test_remote_enrollment.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
cluster_socket_address = ('localhost', 1516)
remote_enrollment_address = ('localhost', 1515)

AGENT_ID = 0
AGENT_NAME = 'test_agent'
INPUT_MESSAGE = "OSSEC A:'{}_{}'"


@pytest.fixture(scope="module", params=configurations, ids=[f"{x['id']}" for x in metadata])
def get_configuration(request):
Expand All @@ -118,7 +122,7 @@ def not_raises(exception):
raise pytest.fail("DID RAISE {0}".format(exception))


def test_remote_enrollment(get_configuration, configure_environment, restart_authd):
def test_remote_enrollment(get_configuration, configure_environment, restart_authd, tear_down):
'''
description: Check if the 'wazuh-authd' daemon remote enrollment is enabled/disabled according
to the configuration. By default, remote enrollment is enabled. When disabled,
Expand All @@ -137,6 +141,9 @@ def test_remote_enrollment(get_configuration, configure_environment, restart_aut
- restart_authd:
type: fixture
brief: Restart the 'wazuh-authd' daemon, clear the 'ossec.log' file and start a new file monitor.
- tear_down:
type: fixture
brief: cleans the client.keys file
assertions:
- Verify that the port '1515' opens or closes depending on the value of the 'remote_enrollment' option.
Expand Down Expand Up @@ -180,8 +187,9 @@ def test_remote_enrollment(get_configuration, configure_environment, restart_aut

if test_metadata['node_type'] == 'worker':
expected_answer = 'ERROR: Cannot comunicate with master'

ssl_socket.send("OSSEC A:'user1'", size=False)
global AGENT_ID
ssl_socket.send(INPUT_MESSAGE.format(AGENT_NAME, AGENT_ID), size=False)
AGENT_ID = AGENT_ID + 1
response = ssl_socket.receive().decode()

assert expected_answer in response
Expand Down

0 comments on commit 017a1d1

Please sign in to comment.