Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

Commit

Permalink
Updating testcase scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
dgaikwad committed Jan 3, 2020
1 parent 2918250 commit b91d397
Showing 1 changed file with 40 additions and 67 deletions.
107 changes: 40 additions & 67 deletions cfme/tests/cli/test_appliance_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,34 +49,6 @@
]


def parseIPV6(ap_ipv6_line):
"""This function will accept IPV6 line from appliance console as a string and will return
IPV6 address from that line as a string
input
- string
Example: "IPv6 Address: 2620:52:0:8c4:21a:4aff:fe42:1b27/64"
return:
- string
Example "2620:52:0:8c4:21a:4aff:fe42:1b27"
"""
return ap_ipv6_line.strip().split()[-1].split("/")[0] if ap_ipv6_line != "" else False


def parseIPV4(ap_ipv4_line):
"""This function will accept IPV4 line from appliance console as a string and will return
IPV4 address from that line as a string
input
- string
Example: "IPv4 Address: 10.8.196.252/255.255.252.0"
return:
- string
Example "10.8.196.252"
"""
return ap_ipv4_line.strip().split()[-1].split("/")[0] if ap_ipv4_line != "" else False


@pytest.mark.rhel_testing
@pytest.mark.smoke
@pytest.mark.tier(2)
Expand Down Expand Up @@ -1022,55 +994,56 @@ def test_appliance_console_network_conf_negative(temp_appliance_preconfig_modsco
1. 'ap' launches appliance_console.
2. RETURN clears info screen.
3. '1' configure network.
4. '2' configure static IPv4.
5. Set invalid IPv4 address.
6. '3' configure static IPv6.
7. Set invalid IPv6 address.
4. '1' Set DHCP Network Configuration
5. provide invalid input for IPv4 network
6. provide invalid input for IPv6 network
7. 4) Test Network Configuration
8. enter invalid ipv4
9. enter invalid hostname
10. 5) Set Hostname
11. enter incorrect hostname
expectedResults:
1.
2.
3.
4.
5. Check network failure with IPv4.
6.
7. Check network failure with IPv6.
5. verify response
6. verify response
7.
8. verify response
9. verify response
10.
11. verify response
"""
appliance = temp_appliance_preconfig_modscope
old_config_file = fauxfactory.gen_alphanumeric(start="test_", length=10)
command_set = (f"ap | tee -a /tmp/{old_config_file}", RETURN)
appliance.appliance_console.run_commands(command_set, timeout=30)
old_data = appliance.ssh_client.run_command(f"cat /tmp/{old_config_file}")
assert old_data.success
old_data = old_data.output.split("\n")
logger.info(f"\'ap\' command's output before test run:{old_data}")

original_ipv4 = parseIPV4("".join([i for i in old_data if "IPv4 Address:" in i]))
invalid_ipv4 = original_ipv4 + ".0"
command_set = ("ap", RETURN, "1", "2", invalid_ipv4)
dhcp_invalid_input = "jdn3e3"
command_set = ("ap", RETURN, "1", "1", dhcp_invalid_input)
result = appliance.appliance_console.run_commands(command_set, timeout=30, output=True)
assert "Please provide a valid IP Address." in result[-1]
assert 'Please enter "yes" or "no".' in result[-1], (
"Not getting error message for invalid error for dhcp IPV4")

original_ipv6 = parseIPV6("".join([i for i in old_data if "IPv6 Address:" in i]))
assert original_ipv6
invalid_ipv6 = original_ipv6 + ":11"
command_set = ("ap", RETURN, "1", "3", invalid_ipv6)
command_set = ("ap", RETURN, "1", "1", "Y", dhcp_invalid_input)
result = appliance.appliance_console.run_commands(command_set, timeout=30, output=True)
assert "Please provide a valid IP Address." in result[-1]

new_config_file = fauxfactory.gen_alphanumeric(start="test_", length=10)
command_set = (f"ap | tee -a /tmp/{new_config_file}", RETURN)
appliance.appliance_console.run_commands(command_set, timeout=30)
command_set = (f"cat /tmp/{new_config_file}")
new_data = appliance.ssh_client.run_command(command_set)
assert new_data.success
new_data = new_data.output.split("\n")
logger.info(f"\'ap\' command's output after test:{new_data}")

assert [i for i in new_data if "IPv4 Address:" in i and original_ipv4 in i] != [], (
f"old {original_ipv4} IPV4 is not found on console appliance ")

assert [i for i in new_data if "IPv6 Address:" in i and original_ipv6 in i] != [], (
f"old {original_ipv6} IPV6 is not found on console appliance")
assert 'Please enter "yes" or "no".' in result[-1], (
"Not getting error message for invalid error for dhcp IPV6")

invalid_hostname = fauxfactory.gen_alphanumeric(start="1test_", length=10)
# TODO(BZ-1785257) remove this condition once this BZ got fixed
if not BZ(1785257, forced_streams=['5.10', "5.11"]).blocks:
command_set = ("ap", RETURN, "1", "4", invalid_hostname)
result = appliance.appliance_console.run_commands(command_set, timeout=30, output=True)
assert "Please provide a valid Hostname or IP Address." in result[-1], (
"Not getting error message for invalid error for IPV6")

command_set = ("ap", RETURN, "1", "5", invalid_hostname)
appliance.appliance_console.run_commands(command_set, timeout=30)

command_set = ("ap", RETURN)
result = appliance.appliance_console.run_commands(command_set, timeout=30, output=True)
logger.info('"ap" command output:%s' % result)

assert [i for i in result if invalid_hostname in result] == [], (
"Should not able to set incorrect hostname")


@pytest.mark.manual
Expand Down

0 comments on commit b91d397

Please sign in to comment.