From 441a4850620647347be49040c91b647861809c41 Mon Sep 17 00:00:00 2001 From: Joshua May Date: Tue, 10 Sep 2019 11:19:22 -0700 Subject: [PATCH] Tests are green! So many warnings, but progress --- Makefile | 2 +- docker-compose.test.yml | 8 +++++++- docker-compose.yml | 8 +------- sirius/coding/claiming.py | 28 ++++++++++++++-------------- sirius/coding/encoders.py | 18 ++++++++++-------- sirius/coding/image_encoding.py | 2 +- sirius/coding/test_image_coding.py | 2 +- sirius/testing/base.py | 2 ++ sirius/web/test_friends.py | 4 ++-- sirius/web/test_printing.py | 13 +++++++++---- 10 files changed, 48 insertions(+), 39 deletions(-) diff --git a/Makefile b/Makefile index 33eee6b..76c2a72 100644 --- a/Makefile +++ b/Makefile @@ -3,4 +3,4 @@ run-development: run-test: docker rm -v sirius-database-test || true - docker-compose -f docker-compose.yml -f docker-compose.test.yml up \ No newline at end of file + docker-compose -f docker-compose.yml -f docker-compose.test.yml up --build \ No newline at end of file diff --git a/docker-compose.test.yml b/docker-compose.test.yml index 15e4baf..b998f74 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -4,8 +4,9 @@ services: sirius: depends_on: - sirius-database-test + command: "bin/wait-for-it.sh sirius-database-test:5432 -- bin/docker-entrypoint.sh" environment: - - DATABASE_URL=postgresql://postgres:plop@sirius-database/sirius-test + - DATABASE_URL=postgresql://postgres:plop@sirius-database-test/sirius-test sirius-database-test: container_name: sirius-database-test @@ -15,3 +16,8 @@ services: environment: - POSTGRES_DB=sirius-test - POSTGRES_PASSWORD=plop + + sirius-web: + ports: + - "8880:80" + - "8443:443" diff --git a/docker-compose.yml b/docker-compose.yml index 2c4133d..fb32483 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,13 +7,7 @@ services: dockerfile: ./Dockerfile depends_on: - sirius-web - command: - [ - "bin/wait-for-it.sh", - "sirius-database:5432", - "--", - "bin/docker-entrypoint.sh", - ] + command: "bin/wait-for-it.sh sirius-database:5432 -- bin/docker-entrypoint.sh" environment: - OPENSSL_CONF=/etc/ssl/ diff --git a/sirius/coding/claiming.py b/sirius/coding/claiming.py index 8950917..a3784e1 100755 --- a/sirius/coding/claiming.py +++ b/sirius/coding/claiming.py @@ -100,30 +100,30 @@ def generate_link_key(input): # Pad with the original length encoded as a 16bit int # Python3 - #input = input + bytes( [((input_length * 8) >> 8 & 0xff)] ) - #input = input + bytes( [((input_length * 8) >> 0 & 0xff)] ) + input = input + bytes( [((input_length * 8) >> 8 & 0xff)] ) + input = input + bytes( [((input_length * 8) >> 0 & 0xff)] ) # Python2 - input = input + chr((input_length * 8) >> 8 & 0xff) - input = input + chr((input_length * 8) >> 0 & 0xff) + # input = input + chr((input_length * 8) >> 8 & 0xff) + # input = input + chr((input_length * 8) >> 0 & 0xff) elif input_length != ZBEE_SEC_CONST_BLOCKSIZE: raise InvalidClaimCode("cannot handle input size %d" % input_length) # We encrypt the salt and the input bytes - # blocks = [bytes(CLAIM_CODE_SALT), input] # Python3 - blocks = [str(bytearray(CLAIM_CODE_SALT)), input] # Python2 + blocks = [bytes(CLAIM_CODE_SALT), input] # Python3 + # blocks = [str(bytearray(CLAIM_CODE_SALT)), input] # Python2 - #output = bytes(16) # Works in Python3 - output = bytearray(16) # Works in Python2 + output = bytes(16) # Works in Python3 + # output = bytearray(16) # Works in Python2 for block in blocks: - # aes_encoder = AES.new(output, AES.MODE_ECB) # Python3 - aes_encoder = AES.new(str(output), AES.MODE_ECB) # Python2 + aes_encoder = AES.new(output, AES.MODE_ECB) # Python3 + # aes_encoder = AES.new(str(output), AES.MODE_ECB) # Python2 h = aes_encoder.encrypt(block) output = bytearray(16) for i in range(len(output)): - # output[i] = h[i] ^ block[i] # Python3 - output[i] = ord(h[i]) ^ ord(block[i]) # Python2 + output[i] = h[i] ^ block[i] # Python3 + # output[i] = ord(h[i]) ^ ord(block[i]) # Python2 output = bytes(output) return output @@ -142,8 +142,8 @@ def process_claim_code(claim_code): # Generate our own CRC from the raw_value, and confirm it matches the extracted crc data_for_crc = struct.pack("