Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ services:
working_dir: /tests
volumes:
- ../tests:/tests
- /var/run/docker.sock:/var/run/docker.sock
environment:
- KNOX_GATEWAY_URL=https://knox:8443/
command: >
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
requests==2.32.4
docker==7.1.0
pytest==8.3.4
requests==2.32.4
44 changes: 44 additions & 0 deletions .github/workflows/tests/test_knox_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to you under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest
from util.knox import Knox

class TestKnoxCLI(unittest.TestCase):
def setUp(self):
self.knox = Knox("compose-knox-1")
self.knox_cli_path = "/knox-runtime/bin/knoxcli.sh"

def test_knox_cli_create_list_aliases(self):
"""
Validating creating and listing of aliases for multiple cluster

Step:
- Execute:
knoxcli.sh create-list-aliases --alias aliasx1 --value value --alias aliasx2 --value value --cluster clusterX
--alias aliasy1 --value value --alias aliasy2 --value value --cluster clusterY

Result:
all Alias in the clusters should be created and listed
:return:
"""
print(f"\nTesting create-list-aliases command")
cmd = ("{} create-list-aliases --alias aliasx1 --value value --alias aliasx2 --value value --cluster clusterX"
" --alias aliasy1 --value value --alias aliasy2 --value value --cluster clusterY").format(self.knox_cli_path)
cmd_output = self.knox.run_knox_cmd(cmd)
self.assertIn("Listing aliases for: clusterX", cmd_output)
self.assertIn("Listing aliases for: clusterY", cmd_output)
self.assertIn("2 alias(es) have been successfully created: [aliasx1, aliasx2]", cmd_output)
self.assertIn("2 alias(es) have been successfully created: [aliasy1, aliasy2]", cmd_output)
print(f"Verified command output contains aliases")
2 changes: 1 addition & 1 deletion .github/workflows/tests/test_knox_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def setUp(self):
self.base_url += "/"
self.non_existent_path = self.base_url + "gateway/not-exists"

def test_auth_service_guest(self):
def test_global_hsts_header(self):
"""
Verifies header is present with the correct value
"""
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/tests/util/knox.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to you under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import requests
import docker

class Knox:

def __init__(self, container_name):
"""
:param container_name:
"""
client = docker.from_env()
self.knox_container = client.containers.get(container_name)

def run_knox_cmd(self, knox_cmd):
"""
:param knox_cmd:
:return:
"""
result = self.knox_container.exec_run(f"{knox_cmd}", stream=False)
output = result.output.decode()
print(f"\n[CMD={knox_cmd}] OUTPUT:\n{output}")
return output

Loading