Skip to content

Commit 48eeb6e

Browse files
committed
test: mock simpleRequest
1 parent dfb4aed commit 48eeb6e

File tree

5 files changed

+18
-14
lines changed

5 files changed

+18
-14
lines changed

tests/integration/test_credentials.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,7 @@
2727
def _build_credential_manager(
2828
realm: Optional[str] = None,
2929
) -> credentials.CredentialManager:
30-
session_key = credentials.get_session_key(
31-
context.username,
32-
context.password,
33-
scheme=context.scheme,
34-
host=context.host,
35-
port=context.port,
36-
)
30+
session_key = context.get_session_key()
3731
return credentials.CredentialManager(
3832
session_key,
3933
context.app,

tests/integration/test_hec_config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
sys.path.insert(0, op.dirname(op.dirname(op.abspath(__file__))))
2424

2525

26-
def test_hec_config():
26+
def test_hec_config(monkeypatch):
27+
context.mock_splunk(monkeypatch)
28+
2729
session_key = context.get_session_key()
2830
config = hec_config.HECConfig(session_key)
2931
stanza = {

tests/integration/test_hec_event_writer.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
sys.path.insert(0, op.dirname(op.dirname(op.abspath(__file__))))
2626

2727

28-
def test_hec_event_writer():
28+
def test_hec_event_writer(monkeypatch):
29+
context.mock_splunk(monkeypatch)
30+
2931
session_key = context.get_session_key()
3032

3133
ew = hew.HECEventWriter("test", session_key)
@@ -40,7 +42,9 @@ def test_hec_event_writer():
4042
ew.write_events([e1, e2])
4143

4244

43-
def test_hec_event_writes_with_non_utf_8():
45+
def test_hec_event_writes_with_non_utf_8(monkeypatch):
46+
context.mock_splunk(monkeypatch)
47+
4448
# To test scenario listed in https://github.com/splunk/addonfactory-solutions-library-python/pull/112.
4549
test_name = "test_hec_event_writes_with_non_utf_8"
4650
session_key = context.get_session_key()

tests/integration/test_time_parser.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
sys.path.insert(0, op.dirname(op.dirname(op.abspath(__file__))))
2525

2626

27-
def test_time_parser():
27+
def test_time_parser(monkeypatch):
28+
context.mock_splunk(monkeypatch)
29+
2830
session_key = context.get_session_key()
2931
tp = time_parser.TimeParser(session_key)
3032

tests/integration/test_user_access.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ def test_app_capability_manager():
114114
assert not acm.capabilities_are_registered()
115115

116116

117-
def test_check_user_access():
117+
def test_check_user_access(monkeypatch):
118+
context.mock_splunk(monkeypatch)
119+
118120
session_key = context.get_session_key()
119121
app_capabilities = {
120122
"object_type1": {
@@ -179,10 +181,10 @@ def test_get_user_roles():
179181
)
180182

181183

182-
def test_user_access():
184+
def test_user_access(monkeypatch):
183185
test_object_acl_manager()
184186
test_app_capability_manager()
185-
test_check_user_access()
187+
test_check_user_access(monkeypatch)
186188
test_get_current_username()
187189
test_get_user_capabilities()
188190
test_user_is_capable()

0 commit comments

Comments
 (0)