usr/src/test/python/client/test_connect.py
author Stephen Talley <stephen.talley@oracle.com>
Fri, 18 May 2012 11:08:12 -0400
changeset 862 f20f2afa6263
parent 849 e46ba1c7ace1
permissions -rw-r--r--
mod_xport -> mod
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
     1
#!/usr/bin/python2.6
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
     2
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
     3
# CDDL HEADER START
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
     4
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
     5
# The contents of this file are subject to the terms of the
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
     6
# Common Development and Distribution License (the "License").
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
     7
# You may not use this file except in compliance with the License.
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
     8
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
     9
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    10
# or http://www.opensolaris.org/os/licensing.
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    11
# See the License for the specific language governing permissions
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    12
# and limitations under the License.
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    13
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    14
# When distributing Covered Code, include this CDDL HEADER in each
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    15
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    16
# If applicable, add the following below this CDDL HEADER, with the
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    17
# fields enclosed by brackets "[]" replaced with your own identifying
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    18
# information: Portions Copyright [yyyy] [name of copyright owner]
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    19
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    20
# CDDL HEADER END
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    21
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    22
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    23
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    24
# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    25
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    26
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    27
import rad.client as rad
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    28
import rad.util as ru
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    29
import common.tests as tests
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    30
import pwd
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    31
import os
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    32
import shutil
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    33
import socket
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    34
import ssl
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    35
import subprocess
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    36
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    37
# some useful constants
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    38
TEST_DIRNAME = "/tmp/rad_connect_test"
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    39
REMOTE_TEST_DIRNAME = TEST_DIRNAME + "_remote"
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    40
CERT_FILENAME = "cert.pem"
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    41
KEY_FILENAME = "key.pem"
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    42
AFUNIX_FILENAME = "unix"
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    43
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    44
# read commonly used environment variables
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    45
LOCAL_PORT_TCP = os.environ["LOCAL_PORT_TCP"]
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    46
LOCAL_PORT_TLS = os.environ["LOCAL_PORT_TLS"]
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    47
REMOTE_HOST_IPV4 = os.environ["REMOTE_HOST_IPV4"]
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    48
REMOTE_HOST_IPV6 = os.environ["REMOTE_HOST_IPV6"]
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    49
REMOTE_PORT_TCP = int(os.environ["REMOTE_PORT_TCP"])
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    50
REMOTE_PORT_TLS = int(os.environ["REMOTE_PORT_TCP"])
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    51
RUN_REMOTE_IPV4_TESTS = os.environ["REMOTE_TEST_IPV4"] == "yes"
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    52
RUN_REMOTE_IPV6_TESTS = os.environ["REMOTE_TEST_IPV6"] == "yes"
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    53
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    54
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    55
# default implementation of RADCommon.get_modules() for all classes using the
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    56
# TCP transport.
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    57
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    58
class TCP(object):
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
    59
    def get_modules(self):
862
f20f2afa6263 mod_xport -> mod
Stephen Talley <stephen.talley@oracle.com>
parents: 849
diff changeset
    60
	return	["/usr/lib/rad/transport/mod_tcp.so"]
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    61
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    62
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    63
# default implementation of RADCommon.get_modules() for all classes using the
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    64
# TLS transport.
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    65
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    66
class TLS(object):
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
    67
    def get_modules(self):
862
f20f2afa6263 mod_xport -> mod
Stephen Talley <stephen.talley@oracle.com>
parents: 849
diff changeset
    68
	return	["/usr/lib/rad/transport/mod_tls.so"]
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    69
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    70
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    71
# Base class for all connection tests.
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    72
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    73
class ConnectTest(tests.RADTestObject):
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
    74
    def get_keys(self):
833
d41a5ad2fa96 api renaming to conform to dev-guide BP
devjani.ray@oracle.com <devjani.ray@oracle.com>
parents: 826
diff changeset
    75
	return [("type", "Authentication")]
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
    76
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
    77
    def get_name(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
    78
	domain = "com.oracle.solaris.rad.pam"
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
    79
	return rad.Name(domain, self.get_keys())
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    80
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
    81
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
    82
    # given a RadConnection object test its validity by retrieving the
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
    83
    # Authentication object and reading the Connection Timeout value. This
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
    84
    # value should be greater than zero. The default value is 180 seconds.
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
    85
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
    86
    def verify_connection(self, rad_conn):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
    87
	""" verify that both the server and client report the same
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
    88
	    connected user."""
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    89
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
    90
	auth = rad_conn.get_object(self.get_name())
849
e46ba1c7ace1 7161014 Python client improvements are requested
Gary Pennington <gary.pennington@oracle.com>
parents: 833
diff changeset
    91
	co = auth.connectionTimeout
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
    92
	# co should be greater than zero, the default value is 180
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
    93
	if (co <= 0):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
    94
	    self.fail("unable to connect to RAD")
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    95
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
    96
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
    97
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
    98
    # Create a socket connection to the given host and port. This function
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
    99
    # supports both IPv4 and IPv6 socket connection. Hosts must be either
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   100
    # a) IP addresses or b) resolvable to the appropriate type (v4/v6) of
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   101
    # addess. When in doubt, go with (a).
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   102
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   103
    def _create_socket(self, host, port):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   104
	addrinfo = socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   105
	family = addrinfo[0][0]
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   106
	address = addrinfo[0][4]
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   107
	s = socket.socket(family, socket.SOCK_STREAM)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   108
	s.connect(address)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   109
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   110
	return s
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   111
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   112
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   113
    # A private function to create a TCP connection.
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   114
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   115
    def _connect_tcp(self, host, port):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   116
	return self._create_socket(host, port)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   117
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   118
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   119
    # A private function to create a TLS connection.
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   120
    #
849
e46ba1c7ace1 7161014 Python client improvements are requested
Gary Pennington <gary.pennington@oracle.com>
parents: 833
diff changeset
   121
    def _connect_tls(self, host, port, keyfile, certfile):
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   122
	s = self._connect_tcp(host, port)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   123
	return ssl.wrap_socket(s, keyfile, certfile)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   124
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   125
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   126
    # A public function to create a TCP connection.
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   127
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   128
    def connect_tcp(self, host, port, locale = None):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   129
	s = self._connect_tcp(host, port)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   130
	return rad.RadConnection(s, locale = locale)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   131
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   132
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   133
    # A public function to create a TLS connection.
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   134
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   135
    def connect_tls(self, host, port, keyfile, certfile, locale = None):
849
e46ba1c7ace1 7161014 Python client improvements are requested
Gary Pennington <gary.pennington@oracle.com>
parents: 833
diff changeset
   136
	s = self._connect_tls(host, port, keyfile, certfile)
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   137
	return rad.RadConnection(s, locale = locale)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   138
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   139
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   140
# Base class for all local connection tests.
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   141
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   142
class ConnectTestLocal(ConnectTest):
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   143
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   144
    # override setUp.
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   145
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   146
    def setUp(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   147
	self.create_test_dir()
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   148
	super(ConnectTestLocal, self).setUp()
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   149
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   150
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   151
    # override tearDown
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   152
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   153
    def tearDown(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   154
	super(ConnectTestLocal, self).tearDown()
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   155
	self.delete_test_dir()
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   156
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   157
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   158
    # prepare the temporary test directory.
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   159
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   160
    def create_test_dir(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   161
	if not os.path.exists(TEST_DIRNAME):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   162
	    os.makedirs(TEST_DIRNAME)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   163
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   164
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   165
    # cleanup the temporary test directory.
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   166
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   167
    def delete_test_dir(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   168
	if os.path.exists(TEST_DIRNAME):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   169
	    shutil.rmtree(TEST_DIRNAME)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   170
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   171
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   172
# Base class for all local AF_UNIX connection tests.
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   173
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   174
class ConnectTestLocalAFUNIX(ConnectTestLocal):
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   175
    def get_modules(self):
862
f20f2afa6263 mod_xport -> mod
Stephen Talley <stephen.talley@oracle.com>
parents: 849
diff changeset
   176
	return ["/usr/lib/rad/transport/mod_unix.so"]
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   177
849
e46ba1c7ace1 7161014 Python client improvements are requested
Gary Pennington <gary.pennington@oracle.com>
parents: 833
diff changeset
   178
    def get_unix_path(self):
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   179
	return os.path.join(TEST_DIRNAME, AFUNIX_FILENAME)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   180
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   181
    # This function verifies the connection and retrieves the logged used
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   182
    def get_server_username(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   183
	# verify that RAD is up and running
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   184
	self.verify_connection(self._rc)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   185
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   186
	# connect to RAD using UDS
849
e46ba1c7ace1 7161014 Python client improvements are requested
Gary Pennington <gary.pennington@oracle.com>
parents: 833
diff changeset
   187
	rad_conn = ru.connect_unix(self.get_unix_path())
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   188
	self.verify_connection(rad_conn)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   189
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   190
	# retrieve and return the server username
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   191
	auth = rad_conn.get_object(self.get_name())
849
e46ba1c7ace1 7161014 Python client improvements are requested
Gary Pennington <gary.pennington@oracle.com>
parents: 833
diff changeset
   192
	svr_user = auth.user
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   193
	rad_conn.close()
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   194
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   195
	return svr_user
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   196
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   197
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   198
# Test RAD on the local machine using an AF_UNIX socket and peercred=true,
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   199
# the default.
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   200
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   201
class ConnectTestLocalAFUNIXauth(ConnectTestLocalAFUNIX):
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   202
    def get_auxargs(self):
849
e46ba1c7ace1 7161014 Python client improvements are requested
Gary Pennington <gary.pennington@oracle.com>
parents: 833
diff changeset
   203
	transport = "unix:path=" + self.get_unix_path()
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   204
	return ["-t", transport]
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   205
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   206
    def connectLocalAFUNIXauth(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   207
	clnt_user = pwd.getpwuid(os.getuid()).pw_name
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   208
	svr_user = self.get_server_username()
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   209
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   210
	if clnt_user != svr_user:
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   211
	    self.fail("peercred failed. The client user should " \
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   212
		"be the same as the server user.")
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   213
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   214
    def test_connectLocalAFUNIXauth(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   215
	""" connect to a local rad daemon using an af_unix socket """
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   216
	self.connectLocalAFUNIXauth()
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   217
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   218
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   219
# Test RAD on the local machine using an AF_UNIX socket and peercred=false
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   220
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   221
class ConnectTestLocalAFUNIXunauth(ConnectTestLocalAFUNIX):
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   222
    def get_auxargs(self):
849
e46ba1c7ace1 7161014 Python client improvements are requested
Gary Pennington <gary.pennington@oracle.com>
parents: 833
diff changeset
   223
	transport = "unix:path=" + self.get_unix_path() +\
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   224
	    ",peercred=false"
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   225
	return ["-t", transport]
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   226
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   227
    def connectLocalAFUNIXunauth(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   228
	clnt_user = pwd.getpwuid(os.getuid()).pw_name
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   229
	svr_user = self.get_server_username()
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   230
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   231
	if clnt_user == svr_user:
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   232
	    self.fail("peercred failed. The client user should " \
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   233
		"not be the same as the server user.")
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   234
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   235
    def test_connectLocalAFUNIXunauth(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   236
	""" connect to a local rad daemon using an af_unix socket and
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   237
	    peercred=false """
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   238
	self.connectLocalAFUNIXunauth()
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   239
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   240
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   241
# Test RAD on the local machine using the TCP transport.
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   242
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   243
class ConnectTestLocalTCP(TCP, ConnectTestLocal):
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   244
    def get_auxargs(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   245
	transport = "tcp:localonly=false,port=" + str(LOCAL_PORT_TCP)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   246
	return ["-t", transport]
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   247
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   248
    def connectLocalTCP(self, host):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   249
	# verify that RAD is up and running
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   250
	self.verify_connection(self._rc)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   251
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   252
	rad_conn = self.connect_tcp(host, LOCAL_PORT_TCP)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   253
	self.verify_connection(rad_conn)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   254
	rad_conn.close()
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   255
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   256
    def test_connectLocalTCP4(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   257
	""" Connect to a local RAD daemon using IPv4 loopback """
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   258
	self.connectLocalTCP("127.0.0.1")
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   259
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   260
    def test_connectLocalTCP6(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   261
	""" Connect to a local RAD daemon using IPv6 loopback """
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   262
	self.connectLocalTCP("::1")
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   263
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   264
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   265
# Test RAD on the local machine using the TLS transport.
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   266
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   267
class ConnectTestLocalTLS(TLS, ConnectTestLocal):
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   268
    def get_auxargs(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   269
	certfile = os.path.join(TEST_DIRNAME, CERT_FILENAME)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   270
	keyfile = os.path.join(TEST_DIRNAME, KEY_FILENAME)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   271
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   272
	transport = "tls:localonly=false,port=" + \
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   273
	    str(LOCAL_PORT_TLS) + \
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   274
	    ",certificate=" + certfile + \
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   275
	    ",privatekey=" + keyfile + \
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   276
	    ",generate=true"
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   277
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   278
	return ["-t", transport]
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   279
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   280
    def connectLocalTLS(self, host):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   281
	# verify that RAD is up and running.
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   282
	self.verify_connection(self._rc)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   283
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   284
	certfile = os.path.join(TEST_DIRNAME, CERT_FILENAME)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   285
	keyfile = os.path.join(TEST_DIRNAME, KEY_FILENAME)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   286
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   287
	rad_conn = self.connect_tls(host, LOCAL_PORT_TLS,
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   288
	    keyfile, certfile)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   289
	self.verify_connection(rad_conn)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   290
	rad_conn.close()
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   291
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   292
    def test_connectLocalTLS4(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   293
	""" Connect to a local RAD daemon using TLS over IPV4 loopback
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   294
	"""
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   295
	self.connectLocalTLS("127.0.0.1")
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   296
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   297
    def test_connectLocalTLS6(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   298
	""" Connect to a local RAD daemon using TLS over IPV6 loopback
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   299
	"""
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   300
	self.connectLocalTLS("::1")
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   301
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   302
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   303
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   304
# Base class for all remote connection tests.
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   305
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   306
class ConnectTestRemote(ConnectTest):
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   307
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   308
    # override the setUp method.
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   309
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   310
    def setUp(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   311
	if RUN_REMOTE_IPV4_TESTS or RUN_REMOTE_IPV6_TESTS:
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   312
	    # ssh to a remote machine and start a private copy of
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   313
	    # RAD.
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   314
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   315
	    cmd = ru.build_rad_cmd(modules = self.get_modules(),
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   316
		debug = False, root = REMOTE_TEST_DIRNAME,
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   317
		auxargs = self.get_auxargs())
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   318
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   319
	    host = "%s@%s" % (pwd.getpwuid(os.getuid()).pw_name,
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   320
		REMOTE_HOST_IPV4)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   321
	    args = ["/usr/bin/ssh", "-q", "-e", "none","-o",
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   322
		"BatchMode yes", REMOTE_HOST_IPV4]
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   323
	    args.extend(cmd)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   324
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   325
	    p = subprocess.Popen(args, 0, None,
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   326
		subprocess.PIPE, subprocess.PIPE)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   327
826
bb0bf4c5f059 7154768 - module documentation should include examples
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents: 813
diff changeset
   328
	    rad_conn = rad.RadConnection(ru.ProcessPseudoSocket(p), None)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   329
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   330
	    self._rc = rad_conn
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   331
	    name = self.get_name()
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   332
	    if name is not None:
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   333
		self._obj = self._rc.get_object(name)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   334
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   335
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   336
# Test a remote RAD using the TCP transport.
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   337
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   338
class ConnectTestRemoteTCP(TCP, ConnectTestRemote):
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   339
    def get_auxargs(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   340
	transport = "tcp:localonly=false,port=" + str(REMOTE_PORT_TCP)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   341
	return ["-t", transport]
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   342
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   343
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   344
    # Connect to a remote RAD using TCP.
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   345
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   346
    def connectRemoteTCP(self, host):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   347
	# verify that RAD is up and running
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   348
	self.verify_connection(self._rc)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   349
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   350
	rad_conn = self.connect_tcp(host, REMOTE_PORT_TCP)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   351
	self.verify_connection(rad_conn)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   352
	rad_conn.close()
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   353
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   354
    def test_connectRemoteTCP4(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   355
	""" Connect to a remote RAD daemon using IPv4 """
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   356
	if RUN_REMOTE_IPV4_TESTS:
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   357
	    self.connectRemoteTCP(REMOTE_HOST_IPV4)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   358
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   359
    def test_connectRemoteTCP6(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   360
	""" Connect to a remote RAD daemon using IPv6 """
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   361
	if RUN_REMOTE_IPV6_TESTS:
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   362
	    self.connectRemoteTCP(REMOTE_HOST_IPV6)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   363
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   364
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   365
# Test a remote RAD using the TLS transport.
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   366
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   367
class ConnectTestRemoteTLS(TLS, ConnectTestRemote):
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   368
    def get_auxargs(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   369
	certfile = os.path.join(REMOTE_TEST_DIRNAME, CERT_FILENAME)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   370
	keyfile = os.path.join(REMOTE_TEST_DIRNAME, KEY_FILENAME)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   371
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   372
	transport = "tls:localonly=false,port=" + \
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   373
	    str(REMOTE_PORT_TLS) + \
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   374
	    ",certificate=" + certfile + \
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   375
	    ",privatekey=" + keyfile
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   376
	return ["-t", transport]
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   377
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   378
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   379
    # Connect to a remote RAD using the TLS transport.
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   380
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   381
    def connectRemoteTLS(self, host):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   382
	certfile = os.path.join(REMOTE_TEST_DIRNAME, CERT_FILENAME)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   383
	keyfile = os.path.join(REMOTE_TEST_DIRNAME, KEY_FILENAME)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   384
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   385
	# verify that RAD is up and running
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   386
	self.verify_connection(self._rc)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   387
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   388
	rad_conn = self.connect_tls(host, REMOTE_PORT_TLS,
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   389
	    keyfile, certfile)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   390
	self.verify_connection(rad_conn)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   391
	rad_conn.close()
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   392
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   393
    def test_connectRemoteTLS4(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   394
	""" Connect to a remote RAD daemon using IPv4 """
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   395
	if RUN_REMOTE_IPV4_TESTS:
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   396
	    self.connectRemoteTLS(REMOTE_HOST_IPV4)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   397
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   398
    def test_connectRemoteTLS6(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   399
	""" Connect to a remote RAD daemon using IPv6 """
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   400
	if RUN_REMOTE_IPV6_TESTS:
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   401
	    self.connectRemoteTLS(REMOTE_HOST_IPV6)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   402
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   403
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   404
# Test a remote RAD started with localonly=true using the TCP transport.
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   405
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   406
class ConnectTestRemoteTCPlocalonly(TCP, ConnectTestRemote):
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   407
    def get_auxargs(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   408
	transport = "tcp:localonly=true,port=" + str(REMOTE_PORT_TCP)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   409
	return ["-t", transport]
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   410
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   411
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   412
    # Connect to a remote RAD, started with localonly=true, using TCP
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   413
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   414
    def connectRemoteTCPlocalonly(self, host):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   415
	# verify that RAD is up and running
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   416
	self.verify_connection(self._rc)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   417
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   418
	# verify that the server does not accept remote connections
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   419
	try:
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   420
	    conn = self.connect_tcp(host, REMOTE_PORT_TCP)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   421
	    self.verify_connection(conn)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   422
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   423
	    # We should not get here
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   424
	    self.fail("Connection to a remote server started " \
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   425
		"with 'localonly=true' erroneously successful.")
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   426
	except IOError:
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   427
	    # Expected behavior.
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   428
	    pass
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   429
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   430
    def test_connectRemoteTCP4localonly(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   431
	""" Connect to a remote RAD daemon using IPv4 with
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   432
	localonly=true """
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   433
	if RUN_REMOTE_IPV4_TESTS:
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   434
	    self.connectRemoteTCPlocalonly(REMOTE_HOST_IPV4)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   435
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   436
    def test_connectRemoteTCP6localonly(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   437
	""" Connect to a rmeote RAD daemon using IPV6 with
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   438
	localonly=true """
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   439
	if RUN_REMOTE_IPV6_TESTS:
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   440
	    self.connectRemoteTCPlocalonly(REMOTE_HOST_IPV6)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   441
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   442
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   443
# Test a remote RAD started with localonly=true using the TLS transport.
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   444
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   445
class ConnectTestRemoteTLSlocalonly(TLS, ConnectTestRemote):
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   446
    def get_auxargs(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   447
	certfile = os.path.join(REMOTE_TEST_DIRNAME, CERT_FILENAME)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   448
	keyfile = os.path.join(REMOTE_TEST_DIRNAME, KEY_FILENAME)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   449
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   450
	transport = "tls:localonly=true,port=" + \
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   451
	    str(REMOTE_PORT_TLS) + \
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   452
	    ",certificate=" + certfile + \
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   453
	    ",privatekey=" + keyfile
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   454
	return ["-t", transport]
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   455
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   456
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   457
    # Connect to a remote RAD, started with localonly=true, using TLS
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   458
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   459
    def connectRemoteTLSlocalonly(self, host):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   460
	certfile = os.path.join(REMOTE_TEST_DIRNAME, CERT_FILENAME)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   461
	keyfile = os.path.join(REMOTE_TEST_DIRNAME, KEY_FILENAME)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   462
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   463
	# verify that RAD is up and running
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   464
	self.verify_connection(self._rc)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   465
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   466
	# verify that the server does not accept remote connections
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   467
	try:
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   468
	    conn = self.connect_tls(host, REMOTE_PORT_TLS,
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   469
		certfile, keyfile)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   470
	    self.fail("Connection to a remote server started " \
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   471
		"with localonly=true erroneously successful.")
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   472
	except IOError:
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   473
	    # Expected behavior.
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   474
	    pass
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   475
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   476
    def test_connectRemoteTLS4localonly(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   477
	""" Connect to a remote RAD daemon using TLS over IPv4 with
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   478
	localonly=true. """
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   479
	if RUN_REMOTE_IPV4_TESTS:
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   480
	    self.connectRemoteTLSlocalonly(REMOTE_HOST_IPV4)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   481
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   482
    def test_connectRemoteTLS6localonly(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   483
	""" Connect to a remote RAD daemon using TLS over IPv6 with
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   484
	localonly=true. """
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   485
	if RUN_REMOTE_IPV6_TESTS:
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   486
	    self.connectRemoteTLSlocalonly(REMOTE_HOST_IPV6)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   487
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   488
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   489
# Test a remote RAD using the TLS transport and a bad certificate.
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   490
#
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   491
class ConnectTestRemoteTLSbadcert(TLS, ConnectTestRemote):
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   492
    def get_auxargs(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   493
	certfile = os.path.join(REMOTE_TEST_DIRNAME, CERT_FILENAME)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   494
	keyfile = os.path.join(REMOTE_TEST_DIRNAME, KEY_FILENAME)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   495
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   496
	transport = "tls:localonly=false,port=" + \
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   497
	    str(REMOTE_PORT_TLS) + \
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   498
	    ",certificate=" + certfile + \
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   499
	    ",privatekey=" + keyfile
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   500
	return	["-t", transport]
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   501
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   502
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   503
    # Connect to a remote RAD using TLS and a bad certificate
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   504
    #
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   505
    def connectRemoteTLSbadcert(self, host):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   506
	# start rad on the local machine using tls to generate 'bad'
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   507
	# certificate/key files
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   508
	badcert = os.path.join(REMOTE_TEST_DIRNAME, "bad_cert.pem")
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   509
	badkey = os.path.join(REMOTE_TEST_DIRNAME, "bad_key.pem")
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   510
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   511
	if not os.path.exists(badcert) and not os.path.exists(badkey):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   512
	    transport = "tls:localonly=false,port=" + \
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   513
		str(LOCAL_PORT_TLS) + \
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   514
		",certificate=" + badcert + \
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   515
		",privatekey=" + badkey + \
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   516
		",generate=true"
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   517
	    auxargs = ["-t", transport]
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   518
	    conn = ru.connect_private(modules = self.get_modules(),
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   519
		root = os.getenv("ROOT"), auxargs = auxargs)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   520
	    conn.close()
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   521
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   522
	# start remote rad tls with good remote cert/key files
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   523
	certfile = os.path.join(REMOTE_TEST_DIRNAME, CERT_FILENAME)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   524
	keyfile = os.path.join(REMOTE_TEST_DIRNAME, KEY_FILENAME)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   525
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   526
	# verify that RAD is up and running
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   527
	self.verify_connection(self._rc)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   528
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   529
	# verify remote connection works with good cert/key files
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   530
	rad_conn = self.connect_tls(host, REMOTE_PORT_TLS,
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   531
	    keyfile, certfile)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   532
	self.verify_connection(rad_conn)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   533
	rad_conn.close()
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   534
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   535
	# verify remote connection fails with 'bad' cert/key files
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   536
	try:
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   537
	    conn = self.connect_tls(host, REMOTE_PORT_TLS,
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   538
		badcert, badkey)
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   539
	    self.fail("Connection with bad ceritificate " \
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   540
		"erroneously succeeded.")
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   541
	except ssl.SSLError:
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   542
	    # Expected behavior.
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   543
	    pass
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   544
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   545
    def test_connectRemoteTLS4badcert(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   546
	""" Connect to a remote RAD daemon using TLS over IPv4 with an
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   547
	unrecognized certificate. """
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   548
	if RUN_REMOTE_IPV4_TESTS:
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   549
	    self.connectRemoteTLSbadcert(REMOTE_HOST_IPV4)
804
806e7738af00 7130703 - Add python tests for the RAD connection assertions.
Shadrack Kilemba <Shadrack.Kilemba@Oracle.COM>
parents:
diff changeset
   550
813
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   551
    def test_connectRemoteTLS6badcert(self):
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   552
	""" Connect to a remote RAD daemon using TLS over IPv6 with an
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   553
	unrecognized certificate. """
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   554
	if RUN_REMOTE_IPV6_TESTS:
1eaf6a6d9af0 7154768 module documentation should include examples
Stephen Talley <stephen.talley@oracle.com>
parents: 811
diff changeset
   555
	    self.connectRemoteTLSbadcert(REMOTE_HOST_IPV6)