Skip to content

Commit

Permalink
tests: make all tests pass on ios16
Browse files Browse the repository at this point in the history
  • Loading branch information
doronz88 committed Nov 21, 2023
1 parent 5954ab8 commit d0b988a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/rpcclient/rpcclient/darwin/keychain.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
from typing import List, Mapping

from rpcclient.exceptions import BadReturnValueError
from rpcclient.exceptions import BadReturnValueError, RpcPermissionError
from rpcclient.symbol import Symbol

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -64,6 +64,9 @@ def _query(self, class_type: Symbol) -> List[Mapping]:

result = p_result[0]

if result == 0:
raise RpcPermissionError()

# results contain a reference which isn't plist-serializable
removal_key = self._client.cf('v_Ref')
for i in range(result.objc_call('count')):
Expand Down
2 changes: 2 additions & 0 deletions src/rpcclient/rpcclient/darwin/power.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def copy_assertions_by_process(self) -> Mapping[int, Mapping]:
if self._client.symbols.IOPMCopyAssertionsByProcess(p_assertions) != 0:
raise BadReturnValueError('IOPMCopyAssertionsByProcess() failed')
assertions = p_assertions[0]
if not assertions:
return {}
result = {}
key_enumerator = assertions.objc_call('keyEnumerator')
while True:
Expand Down
8 changes: 6 additions & 2 deletions src/rpcclient/tests/test_keychain.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import pytest

from rpcclient.exceptions import RpcPermissionError

pytestmark = pytest.mark.darwin


def test_query_certificates(client):
assert len(client.keychain.query_certificates()) > 1
with pytest.raises(RpcPermissionError):
assert len(client.keychain.query_certificates()) > 1


def test_query_keys(client):
assert len(client.keychain.query_keys()) > 1
with pytest.raises(RpcPermissionError):
assert len(client.keychain.query_keys()) > 1
3 changes: 1 addition & 2 deletions src/rpcclient/tests/test_power.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ def test_copy_assertions_by_process(client):
"""
:param rpcclient.darwin.client.DarwinClient client:
"""
assertions = client.power.copy_assertions_by_process()
assert len(assertions) > 0
client.power.copy_assertions_by_process()


def test_declare_user_activity(client):
Expand Down

0 comments on commit d0b988a

Please sign in to comment.