當前位置: 首頁>>代碼示例>>Python>>正文


Python clc_firewall_policy.ClcFirewallPolicy類代碼示例

本文整理匯總了Python中clc_ansible_module.clc_firewall_policy.ClcFirewallPolicy的典型用法代碼示例。如果您正苦於以下問題:Python ClcFirewallPolicy類的具體用法?Python ClcFirewallPolicy怎麽用?Python ClcFirewallPolicy使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ClcFirewallPolicy類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_ensure_firewall_policy_present_pass

    def test_ensure_firewall_policy_present_pass(
        self,
        mock_get_policy_id_from_response,
        mock_update_firewall_policy,
        mock_get_firewall_policy,
        mock_compare_get_request_with_dict,
        mock_wait,
    ):
        source_account_alias = "WFAD"
        location = "VA1"
        firewall_dict = {"firewall_policy_id": "something"}

        mock_firewall_response = [{"name": "test", "id": "test"}]
        mock_get_policy_id_from_response.return_value = firewall_dict
        mock_update_firewall_policy.return_value = mock_firewall_response
        mock_get_firewall_policy.return_value = firewall_dict
        mock_compare_get_request_with_dict.return_value = True
        mock_wait.return_value = "OK"

        self.module.check_mode = False
        test_firewall = ClcFirewallPolicy(self.module)

        changed, policy_id, response = test_firewall._ensure_firewall_policy_is_present(
            source_account_alias, location, firewall_dict
        )

        self.assertFalse(self.module.fail_json.called)
        self.assertTrue(changed)
        self.assertEqual(policy_id, "something")
        mock_update_firewall_policy.assert_called_once_with(source_account_alias, location, "something", firewall_dict)
        mock_get_firewall_policy.assert_called_with(source_account_alias, location, "something")
開發者ID:cgeers,項目名稱:clc-ansible-module,代碼行數:31,代碼來源:test_clc_firewall_policy.py

示例2: test_set_clc_credentials_w_api_url

 def test_set_clc_credentials_w_api_url(self, mock_clc_sdk):
     with patch.dict('os.environ', {'CLC_V2_API_URL': 'dummyapiurl'}):
         under_test = ClcFirewallPolicy(self.module)
         under_test._set_clc_credentials_from_env()
         self.assertEqual(
             under_test.clc.defaults.ENDPOINT_URL_V2,
             'dummyapiurl')
開發者ID:Tier3,項目名稱:clc-ansible-module,代碼行數:7,代碼來源:test_clc_firewall_policy.py

示例3: test_process_request_state_absent

    def test_process_request_state_absent(self,
                                           mock_clc_sdk,
                                           mock_set_clc_creds,
                                           mock_ensure_absent):
        # Setup Test
        self.module.params = {
            'state': 'absent',
            'location': 'test',
            'source': ['1','2'],
            'destination': ['1','2'],
            'source_account_alias': 'alias',
            'destination_account_alias': 'alias',
            'wait': True
        }
        changed = False
        policy_id = None

        mock_ensure_absent.return_value = True, '123', {}
        # Test
        under_test = ClcFirewallPolicy(self.module)
        under_test.process_request()

        # Assert
        self.assertTrue(self.module.exit_json.called)
        self.module.exit_json.assert_called_once_with(changed=True, firewall_policy_id=None, firewall_policy=[])
        self.assertFalse(self.module.fail_json.called)
開發者ID:Tier3,項目名稱:clc-ansible-module,代碼行數:26,代碼來源:test_clc_firewall_policy.py

示例4: test_ensure_firewall_policy_absent_pass

    def test_ensure_firewall_policy_absent_pass(
            self,
            mock_delete_firewall_policy,
            mock_get_firewall_policy):
        source_account_alias = 'WFAD'
        location = 'WA1'
        firewall_dict = {'firewall_policy_id': 'something'}
        mock_firewall_response = [{'name': 'test', 'id': 'test'}]

        mock_get_firewall_policy.return_value = 'result'
        mock_delete_firewall_policy.return_value = mock_firewall_response
        self.module.check_mode = False

        test_firewall = ClcFirewallPolicy(self.module)
        changed, policy_id, response = test_firewall._ensure_firewall_policy_is_absent(
            source_account_alias, location, firewall_dict)
        self.assertTrue(changed, True)
        self.assertEqual(policy_id, 'something')
        self.assertEqual(response, mock_firewall_response)
        mock_get_firewall_policy.assert_called_once_with(
            source_account_alias,
            location,
            'something')
        mock_delete_firewall_policy.assert_called_once_with(
            source_account_alias,
            location,
            'something')
開發者ID:Tier3,項目名稱:clc-ansible-module,代碼行數:27,代碼來源:test_clc_firewall_policy.py

示例5: test_clc_set_credentials_w_creds

    def test_clc_set_credentials_w_creds(self):
        with patch.dict("os.environ", {"CLC_V2_API_USERNAME": "hansolo", "CLC_V2_API_PASSWD": "falcon"}):
            with patch.object(clc_firewall_policy, "clc_sdk") as mock_clc_sdk:
                under_test = ClcFirewallPolicy(self.module)
                under_test._set_clc_credentials_from_env()

        mock_clc_sdk.v2.SetCredentials.assert_called_once_with(api_username="hansolo", api_passwd="falcon")
開發者ID:cgeers,項目名稱:clc-ansible-module,代碼行數:7,代碼來源:test_clc_firewall_policy.py

示例6: test_set_clc_credentials_from_env

 def test_set_clc_credentials_from_env(self, mock_clc_sdk):
     with patch.dict("os.environ", {"CLC_V2_API_TOKEN": "dummyToken", "CLC_ACCT_ALIAS": "TEST"}):
         under_test = ClcFirewallPolicy(self.module)
         under_test._set_clc_credentials_from_env()
     self.assertEqual(under_test.clc._LOGIN_TOKEN_V2, "dummyToken")
     self.assertFalse(mock_clc_sdk.v2.SetCredentials.called)
     self.assertEqual(self.module.fail_json.called, False)
開發者ID:cgeers,項目名稱:clc-ansible-module,代碼行數:7,代碼來源:test_clc_firewall_policy.py

示例7: test_wait_for_requests_to_complete_active

 def test_wait_for_requests_to_complete_active(self, mock_get):
     mock_pending_status = {
         'status': 'active'
     }
     mock_get.return_value = mock_pending_status
     under_test = ClcFirewallPolicy(self.module)
     under_test._wait_for_requests_to_complete('alias', 'location', 'firewall_pol_id', 2)
     self.assertTrue(under_test._get_firewall_policy.called)
開發者ID:Tier3,項目名稱:clc-ansible-module,代碼行數:8,代碼來源:test_clc_firewall_policy.py

示例8: test_set_clc_credentials_from_env

 def test_set_clc_credentials_from_env(self, mock_clc_sdk):
     with patch.dict('os.environ', {'CLC_V2_API_TOKEN': 'dummyToken',
                                    'CLC_ACCT_ALIAS': 'TEST'}):
         under_test = ClcFirewallPolicy(self.module)
         under_test._set_clc_credentials_from_env()
     self.assertEqual(under_test.clc._LOGIN_TOKEN_V2, 'dummyToken')
     self.assertFalse(mock_clc_sdk.v2.SetCredentials.called)
     self.assertEqual(self.module.fail_json.called, False)
開發者ID:Tier3,項目名稱:clc-ansible-module,代碼行數:8,代碼來源:test_clc_firewall_policy.py

示例9: test_clc_set_credentials_w_creds

    def test_clc_set_credentials_w_creds(self):
        with patch.dict('os.environ', {'CLC_V2_API_USERNAME': 'hansolo', 'CLC_V2_API_PASSWD': 'falcon'}):
            with patch.object(clc_firewall_policy, 'clc_sdk') as mock_clc_sdk:
                under_test = ClcFirewallPolicy(self.module)
                under_test._set_clc_credentials_from_env()

        mock_clc_sdk.v2.SetCredentials.assert_called_once_with(
            api_username='hansolo',
            api_passwd='falcon')
開發者ID:Tier3,項目名稱:clc-ansible-module,代碼行數:9,代碼來源:test_clc_firewall_policy.py

示例10: test_update_policy_w_no_policy_exist

 def test_update_policy_w_no_policy_exist(self, mock_get):
     mock_get.return_value = None
     firewall_dict = {'firewall_policy_id': 'something'}
     under_test = ClcFirewallPolicy(self.module)
     under_test._ensure_firewall_policy_is_present(
         'alias',
         'location',
         firewall_dict)
     self.module.fail_json.assert_called_with(msg='Unable to find the firewall policy id : something')
開發者ID:Tier3,項目名稱:clc-ansible-module,代碼行數:9,代碼來源:test_clc_firewall_policy.py

示例11: test_create_firewall_policy_fail

 def test_create_firewall_policy_fail(self, mock_clc_sdk):
     source_account_alias = "WFAD"
     location = "VA1"
     payload = {"destinationAccount": "wfas", "source": "12345", "destination": "12345", "ports": "any"}
     error = APIFailedResponse()
     error.response_text = "Mock failure message"
     mock_clc_sdk.v2.API.Call.side_effect = error
     test_firewall_policy = ClcFirewallPolicy(self.module)
     test_firewall_policy._create_firewall_policy(source_account_alias, location, payload)
     self.module.fail_json.assert_called_with(msg="Unable to create firewall policy. Mock failure message")
開發者ID:cgeers,項目名稱:clc-ansible-module,代碼行數:10,代碼來源:test_clc_firewall_policy.py

示例12: test_update_firewall_policy_pass

    def test_update_firewall_policy_pass(self, mock_clc_sdk):
        mock_firewall_response = [{"name": "test", "id": "test"}]
        mock_clc_sdk.v2.API.Call.return_value = mock_firewall_response
        firewall_dict = {"source": "12345", "destination": "12345", "ports": "any", "destination_account_alias": "wfas"}

        test_firewall = ClcFirewallPolicy(self.module)
        response = test_firewall._update_firewall_policy(
            source_account_alias="WFAD", location="WA1", firewall_policy_id="fake_policy", firewall_dict=firewall_dict
        )
        self.assertFalse(self.module.fail_json.called)
        self.assertEqual(response, mock_firewall_response)
        assert test_firewall.clc.v2.API.Call.call_count == 1
開發者ID:cgeers,項目名稱:clc-ansible-module,代碼行數:12,代碼來源:test_clc_firewall_policy.py

示例13: test_delete_firewall_policy_fail

 def test_delete_firewall_policy_fail(self, mock_clc_sdk):
     source_account_alias = "WFAD"
     location = "wa1"
     firewall_policy_id = "this_is_not_a_real_policy"
     error = APIFailedResponse()
     error.response_text = "Mock failure message"
     mock_clc_sdk.v2.API.Call.side_effect = error
     test_firewall_policy = ClcFirewallPolicy(self.module)
     test_firewall_policy._delete_firewall_policy(source_account_alias, location, firewall_policy_id)
     self.module.fail_json.assert_called_with(
         msg="Unable to delete the firewall policy id : this_is_not_a_real_policy. Mock failure message"
     )
開發者ID:cgeers,項目名稱:clc-ansible-module,代碼行數:12,代碼來源:test_clc_firewall_policy.py

示例14: test_create_policy_w_changed

 def test_create_policy_w_changed(self, mock_create, mock_get, mock_wait):
     mock_create.return_value = "SUCCESS"
     mock_get.return_value = "policy1"
     mock_wait.return_value = "OK"
     firewall_dict = {"firewall_policy_id": None}
     self.module.check_mode = False
     under_test = ClcFirewallPolicy(self.module)
     changed, firewall_policy_id, response = under_test._ensure_firewall_policy_is_present(
         "alias", "location", firewall_dict
     )
     self.assertEqual(changed, True)
     self.assertEqual(firewall_policy_id, "policy1")
     self.assertEqual(response, "OK")
開發者ID:cgeers,項目名稱:clc-ansible-module,代碼行數:13,代碼來源:test_clc_firewall_policy.py

示例15: test_get_firewall_policy_pass

    def test_get_firewall_policy_pass(self, mock_clc_sdk):
        mock_firewall_response = [{"name": "test", "id": "test"}]
        mock_clc_sdk.v2.API.Call.return_value = mock_firewall_response
        source_account_alias = "WFAD"
        location = "WA1"
        firewall_policy = "test_policy"

        test_firewall = ClcFirewallPolicy(self.module)
        response = test_firewall._get_firewall_policy(source_account_alias, location, firewall_policy)
        self.assertEqual(response, mock_firewall_response)
        test_firewall.clc.v2.API.Call.assert_called_once_with(
            "GET", "/v2-experimental/firewallPolicies/WFAD/WA1/test_policy"
        )
開發者ID:cgeers,項目名稱:clc-ansible-module,代碼行數:13,代碼來源:test_clc_firewall_policy.py


注:本文中的clc_ansible_module.clc_firewall_policy.ClcFirewallPolicy類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。