Skip to content

Commit

Permalink
Merge pull request #362 from balena-io/fixes-tests-and-forces-sdk-email
Browse files Browse the repository at this point in the history
Fixes tests and forces sdk email
  • Loading branch information
flowzone-app[bot] authored May 24, 2024
2 parents c6fa018 + 2a3b5a3 commit 915bcb7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion balena/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def __init__(self, callback, error):
self.callback = callback
self.error = error
self.pending = b""
self.is_running = True

def dataReceived(self, data):
obj = {}
Expand All @@ -53,7 +54,8 @@ def dataReceived(self, data):
self.error(e)
break

self.callback(obj)
if self.is_running:
self.callback(obj)

def connectionLost(self, reason):
pass
Expand All @@ -66,6 +68,7 @@ def cbRequest(response, callback, error):


def cbDrop(protocol):
protocol.is_running = False
protocol.transport.stopProducing()
protocol.transport.loseConnection()

Expand Down
5 changes: 4 additions & 1 deletion tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ def __init__(self):
}
)

if "+testsdk" not in self.credentials["email"]:
raise Exception("Missing environment credentials, all emails must include `+testsdk` to avoid accidental deletion") # noqa: E501

# Stop the test if it's run by an admin user account.
token_data = jwt.decode(
self.balena.settings.get("token"),
algorithms=["HS256"],
options={"verify_signature": False},
)
if any("admin" in s for s in token_data["permissions"]):
if "permissions" in token_data.keys() and any("admin" in s for s in token_data["permissions"]):
raise Exception(
"The test is run with an admin user account. Cancelled, please try" " again with a normal account!"
)
Expand Down

0 comments on commit 915bcb7

Please sign in to comment.