Skip to content

Commit 9db3b41

Browse files
authored
tests: xfail NITRC search tests blocked by AWS WAF (pyxnat#210)
NITRC now blocks POST /ir/data/search with an AWS WAF “challenge” (status 202, empty body), causing pyxnat search-based tests (Search.where / search_experiments) to fail for reasons outside pyxnat/XNAT control. Mark affected tests as xfail.
1 parent c71c931 commit 9db3b41

4 files changed

Lines changed: 35 additions & 2 deletions

File tree

pyxnat/tests/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import pytest
33
import os
44

5+
REASON_NITRC_WAF = "NITRC blocks POST /data/search via AWS WAF (firewall)"
6+
57

68
def skip_if_no_network(func=None):
79
"""Skip test completely in NONETWORK settings

pyxnat/tests/array_test.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import unittest
2+
import pytest
23
from pyxnat import Interface
3-
from pyxnat.tests import skip_if_no_network
4+
from pyxnat.tests import skip_if_no_network, REASON_NITRC_WAF
45
import logging as log
56
log.basicConfig(level=log.INFO)
67

@@ -59,6 +60,9 @@ def test_array_mrscans(self):
5960

6061
@skip_if_no_network
6162
def test_search_experiments(self):
63+
if "nitrc.org" in self._intf._server:
64+
pytest.xfail(REASON_NITRC_WAF)
65+
6266
et = 'xnat:subjectData'
6367
e = self._intf.array.search_experiments(project_id='ixi',
6468
experiment_type=et)

pyxnat/tests/interfaces_test.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
import os.path as op
33
import tempfile
44
from pyxnat import Interface
5-
from pyxnat.tests import skip_if_no_network
5+
from pyxnat.tests import skip_if_no_network, REASON_NITRC_WAF
6+
import pytest
67

78
fp = op.abspath('.central.cfg')
89
central = Interface(config=fp)
@@ -28,6 +29,9 @@ def test_nested_path_listing():
2829

2930
@skip_if_no_network
3031
def test_search_access():
32+
if "nitrc.org" in central._server:
33+
pytest.xfail(REASON_NITRC_WAF)
34+
3135
constraints = [('xnat:subjectData/PROJECT', '=', 'ixi'),
3236
'AND']
3337

pyxnat/tests/search_test.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
from pyxnat import Interface
33
from pyxnat import jsonutil
44
import os.path as op
5+
import pytest
6+
from pyxnat.tests import REASON_NITRC_WAF
57

68
fp = op.abspath('.central.cfg')
79
central = Interface(config=fp)
@@ -21,6 +23,9 @@ def test_datafields():
2123

2224

2325
def test_fieldvalues():
26+
if "nitrc.org" in central._server:
27+
pytest.xfail(REASON_NITRC_WAF)
28+
2429
assert len(central.inspect.field_values('xnat:subjectData/SUBJECT_ID')
2530
) != 0
2631

@@ -48,6 +53,9 @@ def test_inspect_resources():
4853

4954

5055
def test_search():
56+
if "nitrc.org" in central._server:
57+
pytest.xfail(REASON_NITRC_WAF)
58+
5159
results = central.select(
5260
'xnat:mrSessionData',
5361
central.inspect.datatypes('xnat:mrSessionData')
@@ -58,6 +66,9 @@ def test_search():
5866

5967

6068
def test_save_search():
69+
if "nitrc.org" in central._server:
70+
pytest.xfail(REASON_NITRC_WAF)
71+
6172
central.manage.search.save(
6273
search_name, 'xnat:mrSessionData',
6374
central.inspect.datatypes('xnat:mrSessionData'),
@@ -68,16 +79,25 @@ def test_save_search():
6879

6980

7081
def test_get_search():
82+
if "nitrc.org" in central._server:
83+
pytest.xfail(REASON_NITRC_WAF)
84+
7185
results = central.manage.search.get(search_name)
7286
assert isinstance(results, jsonutil.JsonTable)
7387

7488

7589
def test_delete_search():
90+
if "nitrc.org" in central._server:
91+
pytest.xfail(REASON_NITRC_WAF)
92+
7693
central.manage.search.delete(search_name)
7794
assert search_name not in central.manage.search.saved()
7895

7996

8097
def test_save_search_template():
98+
if "nitrc.org" in central._server:
99+
pytest.xfail(REASON_NITRC_WAF)
100+
81101
central.manage.search.save_template(
82102
search_template_name, 'xnat:mrSessionData',
83103
central.inspect.datatypes('xnat:mrSessionData'),
@@ -89,6 +109,9 @@ def test_save_search_template():
89109

90110

91111
def test_delete_search_template():
112+
if "nitrc.org" in central._server:
113+
pytest.xfail(REASON_NITRC_WAF)
114+
92115
central.manage.search.delete_template(search_template_name)
93116
assert search_template_name not in \
94117
central.manage.search.saved_templates()

0 commit comments

Comments
 (0)