Skip to content

Commit b402a8d

Browse files
Milan KubíkMartinBasti
Milan Kubík
authored andcommitted
ipatests: replace the test-example.com domain in tests
Latest DNS patches introduced checks for the added zones. If a zone exists, the add fails if not forced. The domain test-example.com is resolvable thus causing errors in the test. Also adds missing __init__.py to the ipatests.test_cmdline package. Reviewed-By: Oleg Fayans <[email protected]>
1 parent 8dbae7d commit b402a8d

File tree

2 files changed

+33
-27
lines changed

2 files changed

+33
-27
lines changed

ipatests/test_cmdline/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#
2+
# Copyright (C) 2015 FreeIPA Contributors see COPYING for license
3+
#

ipatests/test_cmdline/test_cli.py

+30-27
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
if six.PY3:
1515
unicode = str
1616

17+
TEST_ZONE = u'zoneadd.%(domain)s' % api.env
18+
1719

1820
@pytest.mark.tier0
1921
class TestCLIParsing(object):
@@ -123,9 +125,9 @@ def test_group_add_interactive(self):
123125
all=False)
124126

125127
def test_dnsrecord_add(self):
126-
self.check_command('dnsrecord-add test-example.com ns --a-rec=1.2.3.4',
128+
self.check_command('dnsrecord-add %s ns --a-rec=1.2.3.4' % TEST_ZONE,
127129
'dnsrecord_add',
128-
dnszoneidnsname=u'test-example.com',
130+
dnszoneidnsname=TEST_ZONE,
129131
idnsname=u'ns',
130132
arecord=u'1.2.3.4',
131133
structured=False,
@@ -135,60 +137,60 @@ def test_dnsrecord_add(self):
135137

136138
def test_dnsrecord_del_all(self):
137139
try:
138-
self.run_command('dnszone_add', idnsname=u'test-example.com')
140+
self.run_command('dnszone_add', idnsname=TEST_ZONE)
139141
except errors.NotFound:
140142
raise nose.SkipTest('DNS is not configured')
141143
try:
142144
self.run_command('dnsrecord_add',
143-
dnszoneidnsname=u'test-example.com',
145+
dnszoneidnsname=TEST_ZONE,
144146
idnsname=u'ns', arecord=u'1.2.3.4', force=True)
145147
with self.fake_stdin('yes\n'):
146-
self.check_command('dnsrecord_del test-example.com ns',
148+
self.check_command('dnsrecord_del %s ns' % TEST_ZONE,
147149
'dnsrecord_del',
148-
dnszoneidnsname=u'test-example.com',
150+
dnszoneidnsname=TEST_ZONE,
149151
idnsname=u'ns',
150152
del_all=True,
151153
structured=False)
152154
with self.fake_stdin('YeS\n'):
153-
self.check_command('dnsrecord_del test-example.com ns',
155+
self.check_command('dnsrecord_del %s ns' % TEST_ZONE,
154156
'dnsrecord_del',
155-
dnszoneidnsname=u'test-example.com',
157+
dnszoneidnsname=TEST_ZONE,
156158
idnsname=u'ns',
157159
del_all=True,
158160
structured=False)
159161
finally:
160-
self.run_command('dnszone_del', idnsname=u'test-example.com')
162+
self.run_command('dnszone_del', idnsname=TEST_ZONE)
161163

162164
def test_dnsrecord_del_one_by_one(self):
163165
try:
164-
self.run_command('dnszone_add', idnsname=u'test-example.com')
166+
self.run_command('dnszone_add', idnsname=TEST_ZONE)
165167
except errors.NotFound:
166168
raise nose.SkipTest('DNS is not configured')
167169
try:
168170
records = (u'1 1 E3B72BA346B90570EED94BE9334E34AA795CED23',
169171
u'2 1 FD2693C1EFFC11A8D2BE57229212A04B45663791')
170172
for record in records:
171173
self.run_command('dnsrecord_add',
172-
dnszoneidnsname=u'test-example.com', idnsname=u'ns',
174+
dnszoneidnsname=TEST_ZONE, idnsname=u'ns',
173175
sshfprecord=record)
174176
with self.fake_stdin('no\nyes\nyes\n'):
175-
self.check_command('dnsrecord_del test-example.com ns',
177+
self.check_command('dnsrecord_del %s ns' % TEST_ZONE,
176178
'dnsrecord_del',
177-
dnszoneidnsname=u'test-example.com',
179+
dnszoneidnsname=TEST_ZONE,
178180
idnsname=u'ns',
179181
del_all=False,
180182
sshfprecord=records,
181183
structured=False)
182184
finally:
183-
self.run_command('dnszone_del', idnsname=u'test-example.com')
185+
self.run_command('dnszone_del', idnsname=TEST_ZONE)
184186

185187
def test_dnsrecord_add_ask_for_missing_fields(self):
186188
sshfp_parts = (1, 1, u'E3B72BA346B90570EED94BE9334E34AA795CED23')
187189

188190
with self.fake_stdin('SSHFP\n%d\n%d\n%s' % sshfp_parts):
189-
self.check_command('dnsrecord-add test-example.com sshfp',
191+
self.check_command('dnsrecord-add %s sshfp' % TEST_ZONE,
190192
'dnsrecord_add',
191-
dnszoneidnsname=u'test-example.com',
193+
dnszoneidnsname=TEST_ZONE,
192194
idnsname=u'sshfp',
193195
sshfp_part_fp_type=sshfp_parts[0],
194196
sshfp_part_algorithm=sshfp_parts[1],
@@ -201,10 +203,10 @@ def test_dnsrecord_add_ask_for_missing_fields(self):
201203
# NOTE: when a DNS record part is passed via command line, it is not
202204
# converted to its base type when transfered via wire
203205
with self.fake_stdin('%d\n%s' % (sshfp_parts[1], sshfp_parts[2])):
204-
self.check_command('dnsrecord-add test-example.com sshfp ' \
205-
'--sshfp-algorithm=%d' % sshfp_parts[0],
206+
self.check_command('dnsrecord-add %s sshfp '
207+
'--sshfp-algorithm=%d' % (TEST_ZONE, sshfp_parts[0]),
206208
'dnsrecord_add',
207-
dnszoneidnsname=u'test-example.com',
209+
dnszoneidnsname=TEST_ZONE,
208210
idnsname=u'sshfp',
209211
sshfp_part_fp_type=sshfp_parts[0],
210212
sshfp_part_algorithm=unicode(sshfp_parts[1]), # passed via cmdline
@@ -215,10 +217,11 @@ def test_dnsrecord_add_ask_for_missing_fields(self):
215217
force=False)
216218

217219
with self.fake_stdin(sshfp_parts[2]):
218-
self.check_command('dnsrecord-add test-example.com sshfp ' \
219-
'--sshfp-algorithm=%d --sshfp-fp-type=%d' % (sshfp_parts[0], sshfp_parts[1]),
220+
self.check_command('dnsrecord-add %s sshfp '
221+
'--sshfp-algorithm=%d --sshfp-fp-type=%d' % (
222+
TEST_ZONE, sshfp_parts[0], sshfp_parts[1]),
220223
'dnsrecord_add',
221-
dnszoneidnsname=u'test-example.com',
224+
dnszoneidnsname=TEST_ZONE,
222225
idnsname=u'sshfp',
223226
sshfp_part_fp_type=unicode(sshfp_parts[0]), # passed via cmdline
224227
sshfp_part_algorithm=unicode(sshfp_parts[1]), # passed via cmdline
@@ -231,26 +234,26 @@ def test_dnsrecord_add_ask_for_missing_fields(self):
231234
def test_dnsrecord_del_comma(self):
232235
try:
233236
self.run_command(
234-
'dnszone_add', idnsname=u'test-example.com')
237+
'dnszone_add', idnsname=TEST_ZONE)
235238
except errors.NotFound:
236239
raise nose.SkipTest('DNS is not configured')
237240
try:
238241
self.run_command(
239242
'dnsrecord_add',
240-
dnszoneidnsname=u'test-example.com',
243+
dnszoneidnsname=TEST_ZONE,
241244
idnsname=u'test',
242245
txtrecord=u'"A pretty little problem," said Holmes.')
243246
with self.fake_stdin('no\nyes\n'):
244247
self.check_command(
245-
'dnsrecord_del test-example.com test',
248+
'dnsrecord_del %s test' % TEST_ZONE,
246249
'dnsrecord_del',
247-
dnszoneidnsname=u'test-example.com',
250+
dnszoneidnsname=TEST_ZONE,
248251
idnsname=u'test',
249252
del_all=False,
250253
txtrecord=[u'"A pretty little problem," said Holmes.'],
251254
structured=False)
252255
finally:
253-
self.run_command('dnszone_del', idnsname=u'test-example.com')
256+
self.run_command('dnszone_del', idnsname=TEST_ZONE)
254257

255258
def test_idrange_add(self):
256259
"""

0 commit comments

Comments
 (0)