From 4f5f65f7dafe8442b59475f625ed96a419c5e622 Mon Sep 17 00:00:00 2001 From: Ivanq Date: Thu, 5 Mar 2020 22:59:07 +0300 Subject: [PATCH 1/4] Add GitHub Actions workflow --- .github/workflows/tests.yml | 46 +++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6f2a748ed..0cea32225 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,8 +3,7 @@ name: tests on: [push] jobs: - test: - + test-linux: runs-on: ubuntu-16.04 strategy: max-parallel: 16 @@ -47,3 +46,46 @@ jobs: find src -name "*.json" | xargs -n 1 python3 -c "import json, sys; print(sys.argv[1], end=' '); json.load(open(sys.argv[1])); print('[OK]')" find plugins -name "*.json" | xargs -n 1 python3 -c "import json, sys; print(sys.argv[1], end=' '); json.load(open(sys.argv[1])); print('[OK]')" flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics --exclude=src/lib/pyaes/ + + test-windows: + runs-on: windows-latest + strategy: + max-parallel: 16 + matrix: + python-version: [3.5, 3.6, 3.7, 3.8] + + steps: + - uses: actions/checkout@v1 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + + - name: Prepare for installation + run: | + python -m pip install setuptools + python -m pip install --upgrade pip wheel + python -m pip install --upgrade codecov coveralls flake8 mock pytest==4.6.3 pytest-cov selenium + + - name: Install + run: | + python -m pip install --upgrade -r requirements.txt + python -m pip list + + - name: Prepare for tests + run: | + openssl version -a + + - name: Test + run: | + python -m pytest src/Test --cov=src --cov-config src/Test/coverage.ini + $env:ZERONET_LOG_DIR="log/CryptMessage"; python -m pytest -x plugins/CryptMessage/Test + $env:ZERONET_LOG_DIR="log/Bigfile"; python -m pytest -x plugins/Bigfile/Test + $env:ZERONET_LOG_DIR="log/AnnounceLocal"; python -m pytest -x plugins/AnnounceLocal/Test + $env:ZERONET_LOG_DIR="log/OptionalManager"; python -m pytest -x plugins/OptionalManager/Test + $env:ZERONET_LOG_DIR="log/Multiuser"; mv plugins/disabled-Multiuser plugins/Multiuser; python -m pytest -x plugins/Multiuser/Test + $env:ZERONET_LOG_DIR="log/Bootstrapper"; mv plugins/disabled-Bootstrapper plugins/Bootstrapper; python -m pytest -x plugins/Bootstrapper/Test + find src -name "*.json" | xargs -n 1 python -c "import json, sys; print(sys.argv[1], end=' '); json.load(open(sys.argv[1])); print('[OK]')" + find plugins -name "*.json" | xargs -n 1 python -c "import json, sys; print(sys.argv[1], end=' '); json.load(open(sys.argv[1])); print('[OK]')" + flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics --exclude=src/lib/pyaes/ From 5ddf7edf7c5add3efad937b7c693745c84f4021b Mon Sep 17 00:00:00 2001 From: Ivanq Date: Fri, 6 Mar 2020 08:37:40 +0300 Subject: [PATCH 2/4] Fix openssl on windows --- .github/workflows/tests.yml | 2 ++ src/Crypt/CryptConnection.py | 3 +++ src/Test/conftest.py | 2 ++ 3 files changed, 7 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0cea32225..651b75b3b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -75,7 +75,9 @@ jobs: - name: Prepare for tests run: | + echo "::set-env name=ZERONET_OPENSSL_BIN::$((Get-Command openssl).definition)" openssl version -a + openssl rand -hex 256 - name: Test run: | diff --git a/src/Crypt/CryptConnection.py b/src/Crypt/CryptConnection.py index ebbc62955..7ba964c4b 100644 --- a/src/Crypt/CryptConnection.py +++ b/src/Crypt/CryptConnection.py @@ -156,6 +156,9 @@ def createSslRsaCert(self): ) back = proc.stdout.read().strip().decode(errors="replace").replace("\r", "") proc.wait() + print(back) + + print(subprocess.run(self.openssl_bin + " rand -hex 256", shell=True, stdout=subprocess.PIPE).stdout.decode(errors="replace")) if not (os.path.isfile(self.cacert_pem) and os.path.isfile(self.cakey_pem)): self.log.error("RSA ECC SSL CAcert generation failed, CAcert or CAkey files not exist. (%s)" % back) diff --git a/src/Test/conftest.py b/src/Test/conftest.py index 8f9dc3a56..d932b10bc 100644 --- a/src/Test/conftest.py +++ b/src/Test/conftest.py @@ -77,6 +77,8 @@ def pytest_collection_modifyitems(config, items): config.data_dir = TEST_DATA_PATH # Use test data for unittests if "ZERONET_LOG_DIR" in os.environ: config.log_dir = os.environ["ZERONET_LOG_DIR"] +if "ZERONET_OPENSSL_BIN" in os.environ: + config.openssl_bin_file = os.environ["ZERONET_OPENSSL_BIN"] config.initLogging(console_logging=False) # Set custom formatter with realative time format (via: https://stackoverflow.com/questions/31521859/python-logging-module-time-since-last-log) From 70feb3a82e9aba18c23576457f52b452dbcebb1b Mon Sep 17 00:00:00 2001 From: Ivanq Date: Sat, 7 Mar 2020 09:30:40 +0300 Subject: [PATCH 3/4] Update CryptConnection.py --- src/Crypt/CryptConnection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Crypt/CryptConnection.py b/src/Crypt/CryptConnection.py index 7ba964c4b..f0edfb699 100644 --- a/src/Crypt/CryptConnection.py +++ b/src/Crypt/CryptConnection.py @@ -158,7 +158,7 @@ def createSslRsaCert(self): proc.wait() print(back) - print(subprocess.run(self.openssl_bin + " rand -hex 256", shell=True, stdout=subprocess.PIPE).stdout.decode(errors="replace")) + print(subprocess.run(helper.shellquote(self.openssl_bin) + " rand -hex 256", shell=True, stdout=subprocess.PIPE).stdout.decode(errors="replace")) if not (os.path.isfile(self.cacert_pem) and os.path.isfile(self.cakey_pem)): self.log.error("RSA ECC SSL CAcert generation failed, CAcert or CAkey files not exist. (%s)" % back) From 71d8b46ba5026a3399b7b12dc2bad2eb3d8710f2 Mon Sep 17 00:00:00 2001 From: Ivanq Date: Fri, 6 Mar 2020 08:37:40 +0300 Subject: [PATCH 4/4] Fix openssl on windows --- src/Crypt/CryptConnection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Crypt/CryptConnection.py b/src/Crypt/CryptConnection.py index f0edfb699..293954c86 100644 --- a/src/Crypt/CryptConnection.py +++ b/src/Crypt/CryptConnection.py @@ -158,7 +158,7 @@ def createSslRsaCert(self): proc.wait() print(back) - print(subprocess.run(helper.shellquote(self.openssl_bin) + " rand -hex 256", shell=True, stdout=subprocess.PIPE).stdout.decode(errors="replace")) + print(subprocess.run(helper.shellquote(self.openssl_bin) + " rand -hex 65536", shell=True, stdout=subprocess.PIPE).stdout.decode(errors="replace")) if not (os.path.isfile(self.cacert_pem) and os.path.isfile(self.cakey_pem)): self.log.error("RSA ECC SSL CAcert generation failed, CAcert or CAkey files not exist. (%s)" % back)