diff --git a/README.md b/README.md index 593f1ee..fa1a06b 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,10 @@ If you get any other errors, or have any other problem with libray, please [crea clp = compressed length prefix +## Tests + +`python -m unittest discover` + ## Deployment 0. `pip3 install wheel twine` diff --git a/docs/flow.png b/docs/flow.png new file mode 100644 index 0000000..bbc4995 Binary files /dev/null and b/docs/flow.png differ diff --git a/libray/__init__.py b/libray/__init__.py index e69de29..99e3143 100644 --- a/libray/__init__.py +++ b/libray/__init__.py @@ -0,0 +1,32 @@ +# -*- coding: utf8 -*- + +# libray - Libre Blu-Ray PS3 ISO Tool +# Copyright © 2018 - 2021 Nichlas Severinsen +# +# This file is part of libray. +# +# libray is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# libray is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with libray. If not, see . + +# This is a script to find the redump names and game serial id's using rpcs3's compatibility list. +# It puts the name, serial id, and some other info into an sqlite3 database. +# That database can then be used to harcode serial id to keys into keys.db. +# This script is not included in the release of libray. + +import pkgutil + +__all__ = [] +for loader, module_name, is_pkg in pkgutil.walk_packages(__path__): + __all__.append(module_name) + _module = loader.find_module(module_name).load_module(module_name) + globals()[module_name] = _module diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_interface.py b/tests/test_interface.py new file mode 100644 index 0000000..f66fe50 --- /dev/null +++ b/tests/test_interface.py @@ -0,0 +1,68 @@ +# -*- coding: utf8 -*- + +# libray - Libre Blu-Ray PS3 ISO Tool +# Copyright © 2018 - 2021 Nichlas Severinsen +# +# This file is part of libray. +# +# libray is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# libray is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with libray. If not, see . + +# This is a script to find the redump names and game serial id's using rpcs3's compatibility list. +# It puts the name, serial id, and some other info into an sqlite3 database. +# That database can then be used to harcode serial id to keys into keys.db. +# This script is not included in the release of libray. + + +import io +import argparse +import builtins +import unittest +import unittest.mock + +import libray + + +class TestInterface(unittest.TestCase): + + + + @unittest.mock.patch('argparse.ArgumentParser.parse_args', return_value=argparse.Namespace()) + def test_decrypt_with_key(self, mock_args): + + io_object = io.BytesIO(b"some initial binary data: \x00\x01") + + os_stat = unittest.mock.Mock() + os_stat.return_value.st_mode = 33188 + + iso_filepath = unittest.mock.Mock() + iso_filepath.open = unittest.mock.mock_open(read_data=b"some initial binary data: \x00\x01") + + iso_filepath.is_file.return_value = True + iso_filepath.stat.return_value = unittest.mock.MagicMock() + iso_filepath.stat.st_size = 1024 + iso_filepath.stat.st_mode = 33188 + iso_filepath.stat.S_ISBLK.return_value = False + + mock_args.iso = 'encrypted_mock.iso' + + #mock_args.iso = iso_filepath + + with unittest.mock.patch('os.stat', os_stat): + + with unittest.mock.patch('builtins.open', iso_filepath.open): + + libray.core.decrypt(mock_args) + + +