Skip to content

Commit

Permalink
Starting cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
aiden3c committed Sep 4, 2024
1 parent c97a8cb commit 4012179
Showing 1 changed file with 19 additions and 27 deletions.
46 changes: 19 additions & 27 deletions tests/api2/test_550_vmware.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
#!/usr/bin/env python3

# Author: Eric Turgeon
# License: BSD

import pytest
import sys
import os
from pytest_dependency import depends
apifolder = os.getcwd()
sys.path.append(apifolder)
from functions import GET, POST, SSH_TEST
from auto_config import user, password

import pytest

try:
Reason = 'VMWARE credentials credential is missing'
Expand All @@ -26,19 +17,20 @@ def test_01_get_vmware_query():
assert isinstance(results.json(), list) is True


if vmw_credentials:
def test_02_create_vmware():
payload = {
'hostname': VMWARE_HOST,
'username': VMWARE_USERNAME,
'password': VMWARE_PASSWORD
}
results = POST('/vmware/get_datastores/', payload)
assert results.status_code == 200, results.text
assert isinstance(results.json(), list) is True, results.text

def test_03_verify_vmware_get_datastore_do_not_leak_password(request):
cmd = f"grep -R \"{os.environ['VMWARE_PASSWORD']}\" " \
"/var/log/middlewared.log"
results = SSH_TEST(cmd, user, password)
assert results['result'] is False, str(results['output'])
@pytest.mark.skipif(not vmw_credentials, reason='Test only valid with VM credentials')
def test_02_create_vmware():
payload = {
'hostname': VMWARE_HOST,
'username': VMWARE_USERNAME,
'password': VMWARE_PASSWORD
}
results = POST('/vmware/get_datastores/', payload)
assert results.status_code == 200, results.text
assert isinstance(results.json(), list) is True, results.text

@pytest.mark.skipif(not vmw_credentials, reason='Test only valid with VM credentials')
def test_03_verify_vmware_get_datastore_do_not_leak_password(request):
cmd = f"grep -R \"{os.environ['VMWARE_PASSWORD']}\" " \
"/var/log/middlewared.log"
results = SSH_TEST(cmd, user, password)
assert results['result'] is False, str(results['output'])

0 comments on commit 4012179

Please sign in to comment.