Skip to content

Commit ee821cc

Browse files
committed
# 655 bugfix.sslfile_tests added/clarified tests; added ssl resource object modify exceptions
1 parent 8586a52 commit ee821cc

3 files changed

Lines changed: 61 additions & 5 deletions

File tree

f5/bigip/tm/sys/file.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@ def __init__(self, ssl_certs):
103103
self._meta_data['required_creation_parameters'].update(
104104
('name', 'sourcePath'))
105105

106+
def modify(self, **kwargs):
107+
'''Modify is not supported for iFiles
108+
109+
:raises: UnsupportedOperation
110+
'''
111+
raise UnsupportedMethod(
112+
"%s does not support the update method" % self.__class__.__name__
113+
)
114+
106115

107116
class Ssl_Crls(Collection):
108117
def __init__(self, File):
@@ -120,6 +129,15 @@ def __init__(self, ssl_crls):
120129
self._meta_data['required_creation_parameters'].update(
121130
('name', 'sourcePath'))
122131

132+
def modify(self, **kwargs):
133+
'''Modify is not supported for iFiles
134+
135+
:raises: UnsupportedOperation
136+
'''
137+
raise UnsupportedMethod(
138+
"%s does not support the update method" % self.__class__.__name__
139+
)
140+
123141

124142
class Ssl_Csrs(Collection):
125143
def __init__(self, File):
@@ -138,6 +156,15 @@ def __init__(self, ssl_csrs):
138156
self._meta_data['required_creation_parameters'].update(
139157
('name', 'sourcePath'))
140158

159+
def modify(self, **kwargs):
160+
'''Modify is not supported for iFiles
161+
162+
:raises: UnsupportedOperation
163+
'''
164+
raise UnsupportedMethod(
165+
"%s does not support the update method" % self.__class__.__name__
166+
)
167+
141168

142169
class Ssl_Keys(Collection):
143170
def __init__(self, File):
@@ -154,3 +181,12 @@ def __init__(self, ssl_keys):
154181
u'tm:sys:file:ssl-key:ssl-keystate'
155182
self._meta_data['required_creation_parameters'].update(
156183
('name', 'sourcePath'))
184+
185+
def modify(self, **kwargs):
186+
'''Modify is not supported for iFiles
187+
188+
:raises: UnsupportedOperation
189+
'''
190+
raise UnsupportedMethod(
191+
"%s does not support the update method" % self.__class__.__name__
192+
)

f5/bigip/tm/sys/test/test_file.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ def test_cert_create_missing_arg(FakeSysCert):
6666
assert 'sourcePath' in ex.value.message
6767

6868

69+
def test_cert_modify(FakeSysCert):
70+
with pytest.raises(UnsupportedMethod):
71+
FakeSysCert.modify(value='Fake')
72+
73+
6974
@pytest.fixture
7075
def FakeSysCrl():
7176
fake_crl_s = mock.MagicMock()
@@ -84,6 +89,11 @@ def test_crl_create_missing_arg(FakeSysCrl):
8489
assert 'sourcePath' in ex.value.message
8590

8691

92+
def test_crl_modify(FakeSysCrl):
93+
with pytest.raises(UnsupportedMethod):
94+
FakeSysCrl.modify(value='Fake')
95+
96+
8797
@pytest.fixture
8898
def FakeSysCsr():
8999
fake_csr_s = mock.MagicMock()
@@ -96,6 +106,11 @@ def test_csr_create_no_args(FakeSysCsr):
96106
FakeSysCsr.create()
97107

98108

109+
def test_csr_modify(FakeSysCsr):
110+
with pytest.raises(UnsupportedMethod):
111+
FakeSysCsr.modify(value='Fake')
112+
113+
99114
def test_csr_create_missing_arg(FakeSysCsr):
100115
with pytest.raises(MissingRequiredCreationParameter) as ex:
101116
FakeSysCsr.create(name='test_csr')
@@ -118,3 +133,8 @@ def test_key_create_missing_arg(FakeSysKey):
118133
with pytest.raises(MissingRequiredCreationParameter) as ex:
119134
FakeSysKey.create(name='test_key')
120135
assert 'sourcePath' in ex.value.message
136+
137+
138+
def test_key_modify(FakeSysKey):
139+
with pytest.raises(UnsupportedMethod):
140+
FakeSysKey.modify(value='Fake')

test/functional/tm/sys/test_file.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ def gen_csr(key, **name):
4242
return req
4343

4444

45-
def gen_cert(req, xxx_todo_changeme, serial):
45+
def gen_cert(req, ca_files, serial):
4646
# returns the signed certificate in an X509 object
47-
(ca_cert, ca_key) = xxx_todo_changeme
47+
ca_cert, ca_key = ca_files
4848
cert = crypto.X509()
4949
cert.set_serial_number(serial)
5050
cert.gmtime_adj_notBefore(0)
@@ -172,7 +172,7 @@ def teardown():
172172
def test_CURDL_sslkeyfile(request, mgmt_root):
173173
# Create temporary Key File.
174174
# Use extensions so tmui doesn't break in managing them.
175-
ntf_key = NamedTemporaryFile(suffix='.key')
175+
ntf_key = NamedTemporaryFile(suffix='.key', delete=False)
176176
ntf_key_basename = os.path.basename(ntf_key.name)
177177
ntf_key_sourcepath = 'file:/var/config/rest/downloads/{0}'.format(
178178
ntf_key_basename)
@@ -225,7 +225,7 @@ def test_CURDL_sslkeyfile(request, mgmt_root):
225225
def test_CURDL_sslcsrfile(request, mgmt_root):
226226
# Create temporary CSR File.
227227
# Use extensions so tmui doesn't break in managing them.
228-
ntf_csr = NamedTemporaryFile(suffix='.csr')
228+
ntf_csr = NamedTemporaryFile(suffix='.csr', delete=False)
229229
ntf_csr_basename = os.path.basename(ntf_csr.name)
230230
ntf_csr_sourcepath = 'file:/var/config/rest/downloads/{0}'.format(
231231
ntf_csr_basename)
@@ -272,7 +272,7 @@ def test_CURDL_sslcsrfile(request, mgmt_root):
272272
def test_CURDL_sslcertfile(request, mgmt_root):
273273
# Create temporary CSR File.
274274
# Use extensions so tmui doesn't break in managing them.
275-
ntf_cert = NamedTemporaryFile(suffix='.crt')
275+
ntf_cert = NamedTemporaryFile(suffix='.crt', delete=False)
276276
ntf_cert_basename = os.path.basename(ntf_cert.name)
277277
ntf_cert_sourcepath = 'file:/var/config/rest/downloads/{0}'.format(
278278
ntf_cert_basename)

0 commit comments

Comments
 (0)