def test_create_client_ssl_inter_passphrase_profile(self): bigip = mock.MagicMock() bigip.tm.ltm.profile.client_ssls.client_ssl = mock.MagicMock() bigip.tm.ltm.profile.client_ssls.client_ssl.exists.side_effect =\ self.exists_parent SSLProfileHelper.create_client_ssl_profile( bigip, 'testprofile', 'testcert', 'testkey', key_passphrase='password', parent_profile="testparentprofile", intermediates='inter') bigip.tm.ltm.profile.client_ssls.client_ssl.create.assert_called_with( name='testprofile', partition='Common', certKeyChain=[{ 'name': 'testprofile', 'cert': '/Common/testprofile.crt', 'chain': '/Common/testprofile_inter.crt', 'key': '/Common/testprofile.key', 'passphrase': 'password' }], sniDefault=False, defaultsFrom=None, )
def test_create_client_ssl_profile(): # set of valid and invalid parent profile names test_parents = [ None, "", "INVALID", "clientssl", "clientssl-insecure-compatible" ] bigip = ManagementRoot('10.190.7.235', 'admin', 'admin') for parent in test_parents: name = random_name('Project_', 16) # create client ssl profile SSLProfileHelper.create_client_ssl_profile(bigip, name, FAKE_CERT, FAKE_KEY, parent_profile=parent) # created? client_ssl = bigip.tm.ltm.profile.client_ssls.client_ssl assert client_ssl.exists(name=name, partition='Common') # parent set correctly? sp = client_ssl.load(name=name, partition='Common') if not parent or parent == "INVALID": path = '/Common/' + 'clientssl' else: path = '/Common/' + parent assert sp.defaultsFrom == path # clean up sp.delete()
def test_create_client_ssl_profile_raises(self): err = Exception() bigip = mock.MagicMock() bigip.tm.ltm.profile.client_ssls.client_ssl = mock.MagicMock() bigip.tm.ltm.profile.client_ssls.client_ssl.exists.return_value = False bigip.tm.ltm.profile.client_ssls.client_ssl.create =\ mock.MagicMock(side_effect=err) with pytest.raises(SSLProfileError): SSLProfileHelper.create_client_ssl_profile( bigip, 'testprofile', 'testcert', 'testkey', parent_profile="parentprofile" )
def test_create_client_ssl_profile_raises(self): err = Exception() bigip = mock.MagicMock() bigip.tm.ltm.profile.client_ssls.client_ssl = mock.MagicMock() bigip.tm.ltm.profile.client_ssls.client_ssl.exists.return_value = False bigip.tm.ltm.profile.client_ssls.client_ssl.create =\ mock.MagicMock(side_effect=err) with pytest.raises(SSLProfileError): SSLProfileHelper.create_client_ssl_profile( bigip, 'testprofile', 'testcert', 'testkey', parent_profile="parentprofile")
def test_create_client_ssl_profile_exists(self): bigip = mock.MagicMock() bigip.tm.ltm.profile.client_ssls.client_ssl =\ mock.MagicMock(return_value=True) rv = SSLProfileHelper.create_client_ssl_profile( bigip, 'testprofile', 'testcert', 'testkey') assert(rv is None)
def test_create_client_ssl_profile_exists(self): bigip = mock.MagicMock() bigip.tm.ltm.profile.client_ssls.client_ssl =\ mock.MagicMock(return_value=True) rv = SSLProfileHelper.create_client_ssl_profile( bigip, 'testprofile', 'testcert', 'testkey') assert (rv is None)
def test_create_client_ssl_profile_parent_none(self): bigip = mock.MagicMock() bigip.tm.ltm.profile.client_ssls.client_ssl = mock.MagicMock() bigip.tm.ltm.profile.client_ssls.client_ssl.exists.return_value = False SSLProfileHelper.create_client_ssl_profile( bigip, 'testprofile', 'testcert', 'testkey', parent_profile=None) bigip.tm.ltm.profile.client_ssls.client_ssl.create.assert_called_with( name='testprofile', partition='Common', certKeyChain=[ {'name': 'testprofile', 'cert': '/Common/testprofile.crt', 'key': '/Common/testprofile.key'} ], sniDefault=False, defaultsFrom=None, )
def test_create_client_ssl_profile_parent(self): bigip = mock.MagicMock() bigip.tm.ltm.profile.client_ssls.client_ssl = mock.MagicMock() bigip.tm.ltm.profile.client_ssls.client_ssl.exists.side_effect =\ self.exists_parent SSLProfileHelper.create_client_ssl_profile( bigip, 'testprofile', 'testcert', 'testkey', parent_profile="parentprofile" ) bigip.tm.ltm.profile.client_ssls.client_ssl.create.assert_called_with( name='testprofile', partition='Common', certKeyChain=[ {'name': 'testprofile', 'cert': '/Common/testprofile.crt', 'key': '/Common/testprofile.key'} ], sniDefault=False, defaultsFrom='parentprofile', )
def test_create_client_ssl_profile_parent_none(self): bigip = mock.MagicMock() bigip.tm.ltm.profile.client_ssls.client_ssl = mock.MagicMock() bigip.tm.ltm.profile.client_ssls.client_ssl.exists.return_value = False SSLProfileHelper.create_client_ssl_profile(bigip, 'testprofile', 'testcert', 'testkey', parent_profile=None) bigip.tm.ltm.profile.client_ssls.client_ssl.create.assert_called_with( name='testprofile', partition='Common', certKeyChain=[{ 'name': 'testprofile', 'cert': '/Common/testprofile.crt', 'key': '/Common/testprofile.key' }], sniDefault=False, defaultsFrom=None, )
def test_create_client_ssl_profile_parent(self): bigip = mock.MagicMock() bigip.tm.ltm.profile.client_ssls.client_ssl = mock.MagicMock() bigip.tm.ltm.profile.client_ssls.client_ssl.exists.side_effect =\ self.exists_parent SSLProfileHelper.create_client_ssl_profile( bigip, 'testprofile', 'testcert', 'testkey', parent_profile="parentprofile") bigip.tm.ltm.profile.client_ssls.client_ssl.create.assert_called_with( name='testprofile', partition='Common', certKeyChain=[{ 'name': 'testprofile', 'cert': '/Common/testprofile.crt', 'key': '/Common/testprofile.key' }], sniDefault=False, defaultsFrom='parentprofile', )
def test_create_client_ssl_profile(): # set of valid and invalid parent profile names test_parents = [None, "", "INVALID", "clientssl", "clientssl-insecure-compatible"] bigip = ManagementRoot('10.190.7.235', 'admin', 'admin') for parent in test_parents: name = random_name('Project_', 16) # create client ssl profile SSLProfileHelper.create_client_ssl_profile( bigip, name, FAKE_CERT, FAKE_KEY, parent_profile=parent) # created? client_ssl = bigip.tm.ltm.profile.client_ssls.client_ssl assert client_ssl.exists(name=name, partition='Common') # parent set correctly? sp = client_ssl.load(name=name, partition='Common') if not parent or parent == "INVALID": path = '/Common/' + 'clientssl' else: path = '/Common/' + parent assert sp.defaultsFrom == path # clean up sp.delete()
def test_get_ssl_profile_count(self): bigip = mock.MagicMock() bigip.tm.ltm.profile.client_ssls.get_collection =\ mock.MagicMock(return_value=[1, 2, 3, 4]) assert(SSLProfileHelper.get_client_ssl_profile_count(bigip) == 4)
def test_get_ssl_profile_count(self): bigip = mock.MagicMock() bigip.tm.ltm.profile.client_ssls.get_collection =\ mock.MagicMock(return_value=[1, 2, 3, 4]) assert (SSLProfileHelper.get_client_ssl_profile_count(bigip) == 4)