Esempio n. 1
0
    def test_ssl_bindings_not_called_for_non_ssl_service(self):
        set_module_args(dict(
            nitro_user='******',
            nitro_pass='******',
            nsip='192.0.2.1',
            state='present',
            save_config=False,
            servicetype='HTTP',
        ))
        from ansible_collections.notmintest.not_a_real_collection.plugins.modules import netscaler_lb_vserver

        lb_vserver_proxy_mock = Mock()
        ssl_sync_mock = Mock()

        client_mock = Mock()

        with patch.multiple(
            'ansible_collections.notmintest.not_a_real_collection.plugins.modules.netscaler_lb_vserver',
            get_nitro_client=Mock(return_value=client_mock),
            lb_vserver_exists=Mock(side_effect=[True, True]),
            lb_vserver_identical=Mock(side_effect=[False, True]),
            servicegroup_bindings_identical=Mock(side_effect=[True, True]),
            service_bindings_identical=Mock(side_effect=[True, True]),
            ssl_certkey_bindings_identical=Mock(side_effect=[False, True]),
            ssl_certkey_bindings_sync=ssl_sync_mock,
            ConfigProxy=Mock(return_value=lb_vserver_proxy_mock),
            ensure_feature_is_enabled=Mock(return_value=True),
            do_state_change=Mock(return_value=Mock(errorcode=0)),
            get_immutables_intersection=(Mock(return_value=[])),
        ):
            self.module = netscaler_lb_vserver
            result = self.exited()
            ssl_sync_mock.assert_not_called()
            self.assertTrue(result['changed'])
Esempio n. 2
0
    def test_present_key_identical_flow(self):
        set_module_args(dict(
            nitro_user='******',
            nitro_pass='******',
            nsip='192.0.2.1',
            state='present',
        ))
        from ansible_collections.notmintest.not_a_real_collection.plugins.modules import netscaler_ssl_certkey

        client_mock = Mock()

        m = Mock(return_value=client_mock)

        ssl_certkey_proxy_attrs = {
            'diff_object.return_value': {},
        }
        ssl_certkey_proxy_mock = Mock()
        ssl_certkey_proxy_mock.configure_mock(**ssl_certkey_proxy_attrs)
        config_proxy_mock = Mock(return_value=ssl_certkey_proxy_mock)

        with patch.multiple(
            'ansible_collections.notmintest.not_a_real_collection.plugins.modules.netscaler_ssl_certkey',
            get_nitro_client=m,
            diff_list=Mock(return_value={}),
            get_immutables_intersection=Mock(return_value=[]),
            key_exists=Mock(side_effect=[True, True]),
            key_identical=Mock(side_effect=[True, True]),
            ConfigProxy=config_proxy_mock,
        ):
            self.module = netscaler_ssl_certkey
            self.exited()
            ssl_certkey_proxy_mock.assert_not_called()
Esempio n. 3
0
    def test_absent_gslb_vserver_noop_flow(self):
        set_module_args(
            dict(
                nitro_user='******',
                nitro_pass='******',
                nsip='192.0.2.1',
                state='absent',
            ))
        from ansible_collections.notmintest.not_a_real_collection.plugins.modules import netscaler_gslb_vserver

        client_mock = Mock()

        m = Mock(return_value=client_mock)

        glsb_service_proxy_attrs = {
            'diff_object.return_value': {},
        }
        gslb_service_proxy_mock = Mock()
        gslb_service_proxy_mock.configure_mock(**glsb_service_proxy_attrs)
        config_proxy_mock = Mock(return_value=gslb_service_proxy_mock)

        with patch.multiple(
                'ansible_collections.notmintest.not_a_real_collection.plugins.modules.netscaler_gslb_vserver',
                get_nitro_client=m,
                diff_list=Mock(return_value={}),
                get_immutables_intersection=Mock(return_value=[]),
                gslb_vserver_exists=Mock(side_effect=[False, False]),
                gslb_vserver_identical=Mock(side_effect=[False, False]),
                nitro_exception=self.MockException,
                ensure_feature_is_enabled=Mock(),
                ConfigProxy=config_proxy_mock,
        ):
            self.module = netscaler_gslb_vserver
            self.exited()
            gslb_service_proxy_mock.assert_not_called()
    def test_present_cs_vserver_identical_flow(self):
        set_module_args(
            dict(
                nitro_user='******',
                nitro_pass='******',
                nsip='192.0.2.1',
                state='present',
            ))
        from ansible_collections.notmintest.not_a_real_collection.plugins.modules import netscaler_cs_vserver

        client_mock = Mock()

        m = Mock(return_value=client_mock)

        server_proxy_attrs = {
            'diff_object.return_value': {},
        }
        cs_vserver_proxy_mock = Mock()
        cs_vserver_proxy_mock.configure_mock(**server_proxy_attrs)
        config_proxy_mock = Mock(return_value=cs_vserver_proxy_mock)

        with patch.multiple(
                'ansible_collections.notmintest.not_a_real_collection.plugins.modules.netscaler_cs_vserver',
                get_nitro_client=m,
                diff_list=Mock(return_value={}),
                get_immutables_intersection=Mock(return_value=[]),
                cs_vserver_exists=Mock(side_effect=[True, True]),
                cs_vserver_identical=Mock(side_effect=[True, True]),
                ensure_feature_is_enabled=Mock(return_value=True),
                do_state_change=Mock(return_value=Mock(errorcode=0)),
                ConfigProxy=config_proxy_mock,
        ):
            self.module = netscaler_cs_vserver
            self.exited()
            cs_vserver_proxy_mock.assert_not_called()