示例#1
0
    def _basic_connectivity_s1s2(self, port_type, ip_version=4):
        """
        @summary: Testing ping and SSH connectivity from server 1 to server 2
        @param port_type: pnet (public), snet (service), inet (isolated)
        @type port_type: str
        @param ip_version: IP address version to test, 4 or 6.
        @type ip_version: int
        """
        conn = Connectivity(self.sp1, self.sp2)

        # Testing icmp is available from  server 1 to 2 via isolated IPv4
        self.icmp_args.update(port_type=port_type, ip_version=ip_version)
        rp = conn.verify_personas_conn(**self.icmp_args)
        result = rp[0]
        ping_res = result[self.connection]
        self.assertTrue(ping_res, rp)

        # Testing SSH is available on server 2
        label = '{0}_fix_ipv{1}'.format(port_type, ip_version)
        fixed_ips = getattr(self.sp2, label)
        public_ip = fixed_ips[0]
        rc1 = self.sp1.remote_client
        ssh = conn.scan_tcp_port(sender_client=rc1, listener_ip=public_ip,
                                 ip_version=ip_version)
        ssh_res = ssh[self.connection]
        self.assertTrue(ssh_res, ssh)
 def _test_remote_ping(self, port_type):
     """Testing remote ping on servers"""
     conn = Connectivity(self.server_persona2, self.server_persona1)
     icmp_basic = dict(port_type=port_type, protocol='icmp', ip_version=4)
     rp = conn.verify_personas_conn(**icmp_basic)
     result = rp[0]
     ping_result = result['connection']
     self.assertTrue(ping_result, rp)
 def _test_remote_ping(self, port_type):
     """
     Testing no remote ping on servers from another server
     which doesn't have private or isolated networks.
     """
     conn = Connectivity(self.sp2, self.sp1)
     icmp_basic = dict(port_type=port_type, protocol='icmp', ip_version=4)
     rp = conn.verify_personas_conn(**icmp_basic)
     result = rp[0]
     ping_result = result['connection']
     self.assertFalse(ping_result,
                      self.msg.format(self.network2, self.network1, rp))
示例#4
0
    def test_pnet_auto_port_update_s1s2_udp(self):
        """
        @summary: Testing public IPv4 auto port update from server 1 to 2 (UDP)
        """
        conn = Connectivity(self.sp1, self.sp2)

        udp_args = dict(port_type=PortTypes.PUBLIC, protocol=self.UDP,
                        ip_version=4, port1='750')

        # Checking there is no UDP connectivity available
        conn_resp = conn.verify_personas_conn(**udp_args)
        udp_res = conn_resp[0][self.connection]
        self.assertFalse(udp_res, conn_resp)

        # Adding the UDP rule
        udp_rule = self.sec.behaviors.add_rule(
            security_groups=self.sec_groups_s2, version=4, protocol=self.UDP,
            ports=750, ingress=True, egress=False)

        log_msg = 'Created udp rule: {0}'.format(udp_rule)
        self.fixture_log.info(log_msg)

        # Checking the auto port update Job was created
        resp = udp_rule[0][self.ingress_rule_request].response.json()

        log_msg = 'udp rule create request response: {0}'.format(resp)
        self.fixture_log.info(log_msg)

        job_id = resp[self.job_id]
        msg = 'udp rule create response missing job ID: {0}'.format(resp)
        self.assertTrue(job_id, msg)

        # Auto port update data plane delay
        self.fixture_log.debug(self.data_plane_delay_msg)
        time.sleep(self.data_plane_delay)

        # Checking there is UDP connectivity available
        conn_resp = conn.verify_personas_conn(**udp_args)
        udp_res = conn_resp[0][self.connection]
        self.assertTrue(udp_res, conn_resp)
示例#5
0
    def _auto_port_update_s1s3(self, port_type, ip_version=4):
        """
        @summary: Testing auto port update connectivity from server 1 to 3.
        @param port_type: pnet (public), snet (service), inet (isolated)
        @type port_type: str
        @param version: IP address version to test, 4 or 6.
        @type version: int
        """
        conn = Connectivity(self.sp1, self.sp3)
        self.icmp_args.update(port_type=port_type, ip_version=ip_version)

        # Auto port update data plane delay
        self.fixture_log.debug(self.data_plane_delay_msg)
        time.sleep(self.data_plane_delay)

        # Update on Isolated networks may require more time
        if port_type == PortTypes.ISOLATED:
            time.sleep(self.data_plane_delay)

        # Testing icmp is not available
        rp = conn.verify_personas_conn(**self.icmp_args)
        result = rp[0]
        ping_res = result[self.connection]
        self.assertFalse(ping_res, rp)

        # Testing SSH is not available
        label = '{0}_fix_ipv{1}'.format(port_type, ip_version)
        fixed_ips = getattr(self.sp3, label)
        public_ip = fixed_ips[0]
        rc1 = self.sp1.remote_client
        ssh = conn.scan_tcp_port(sender_client=rc1, listener_ip=public_ip,
                                 ip_version=ip_version)
        ssh_res = ssh[self.connection]
        self.assertFalse(ssh_res, ssh)

        # ADD ICMP and TCP rules to group
        icmp_rules = self.sec.behaviors.add_rule(
            security_groups=self.sec_groups_s3, version=ip_version,
            protocol=self.ICMP, ingress=True, egress=True)
        log_msg = 'Created icmp rules: {0}'.format(icmp_rules)
        self.fixture_log.info(log_msg)

        # ADD TCP 22 rule
        tcp_rule = self.sec.behaviors.add_rule(
            security_groups=self.sec_groups_s3, version=ip_version,
            protocol=self.TCP, ports=22, ingress=True, egress=False)
        log_msg = 'Created tcp rules: {0}'.format(tcp_rule)
        self.fixture_log.info(log_msg)

        # Auto port update data plane delay
        self.fixture_log.debug(self.data_plane_delay_msg)
        time.sleep(self.data_plane_delay)

        if port_type == PortTypes.ISOLATED:
            time.sleep(self.data_plane_delay)

        # Testing icmp is now available
        rp = conn.verify_personas_conn(**self.icmp_args)
        result = rp[0]
        ping_res = result[self.connection]
        self.assertTrue(ping_res, rp)

        # Testing SSH is now available
        rc1 = self.sp1.remote_client
        ssh = conn.scan_tcp_port(sender_client=rc1, listener_ip=public_ip,
                                 ip_version=ip_version)
        ssh_res = ssh[self.connection]
        self.assertTrue(ssh_res, ssh)