Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/scripts/run_odoo_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ dropdb --if-exists "$db" >/dev/null 2>&1
# (child_of, moving a record with its children) right
createdb --encoding=UTF8 --lc-collate=C --template=template0 "$db" || exit 1

# the first start of Chrome on a new machine can take longer than the 10 seconds Odoo waits for it, which skips
# the browser test with a warning: start it once before
for chrome in google-chrome chromium chromium-browser; do
if command -v "$chrome" >/dev/null; then
timeout 60 "$chrome" --headless --no-sandbox --disable-gpu --dump-dom about:blank >/dev/null 2>&1
break
fi
done

echo "Installing $modules on $db, testing $tags"
"$python" "$odoo/odoo-bin" -c "$conf" -d "$db" -i "$modules" --with-demo --test-tags "$tags" \
--stop-after-init --http-port "${HTTP_PORT:-8069}" > "$log" 2>&1
Expand Down
14 changes: 8 additions & 6 deletions om_shopify/tests/test_oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@ def test_install_by_link(self):
def test_forged_or_wrong_callback(self):
state = self._start()
params = {'code': 'abc', 'shop': 'partner-shop.myshopify.com', 'state': state, 'timestamp': '1'}
response, fake = self._callback({**params, 'hmac': sign('forged', params)})
self.assertEqual(response.status_code, 403)
self.assertFalse([c for c in fake.calls if c[0] == 'token'], "no code exchange without the signature")
other = {**params, 'shop': 'evil-shop.myshopify.com'}
response, _fake = self._callback({**other, 'hmac': sign('app-secret', other)})
self.assertEqual(response.status_code, 403)
with self.assertLogs('odoo.addons.om_shopify.controllers.oauth', 'WARNING') as logs:
response, fake = self._callback({**params, 'hmac': sign('forged', params)})
self.assertEqual(response.status_code, 403)
self.assertFalse([c for c in fake.calls if c[0] == 'token'], "no code exchange without the signature")
other = {**params, 'shop': 'evil-shop.myshopify.com'}
response, _fake = self._callback({**other, 'hmac': sign('app-secret', other)})
self.assertEqual(response.status_code, 403)
self.assertEqual(len(logs.records), 2, "each refused callback is logged")
response, _fake = self._callback({**params, 'state': 'unknown', 'hmac': 'x'})
self.assertEqual(response.status_code, 403)
self.store.invalidate_recordset()
Expand Down
6 changes: 4 additions & 2 deletions om_shopify/tests/test_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ def test_signed_webhook_is_queued_once(self):
self.assertFalse(self.store.access_token)

def test_wrong_signature_or_shop(self):
self.assertEqual(self._post({'id': 1}, secret='forged').status_code, 401)
self.assertEqual(self._post({'id': 1}, shop='other.myshopify.com').status_code, 401)
with self.assertLogs('odoo.addons.om_shopify.controllers.webhook', 'WARNING') as logs:
self.assertEqual(self._post({'id': 1}, secret='forged').status_code, 401)
self.assertEqual(self._post({'id': 1}, shop='other.myshopify.com').status_code, 401)
self.assertEqual(len(logs.records), 2, "each refused webhook is logged")
self.assertFalse(self._jobs())

def test_unhandled_topic_is_ignored(self):
Expand Down
6 changes: 5 additions & 1 deletion om_spreadsheet_account/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
const expected = %(expected)s;
const { helpers } = odoo.loader.modules.get("@odoo/o-spreadsheet");
const loader = odoo.__WOWL_DEBUG__.root.env.services.spreadsheet_dashboard_loader;
await loader.load();
// the action has loaded the dashboards already: loading them again would give the dashboard on the screen a
// new model while it is shown
if (!loader.getDashboardGroups().length) {
await loader.load();
}
const found = {};
for (const group of loader.getDashboardGroups()) {
for (const dashboard of group.dashboards) {
Expand Down
3 changes: 2 additions & 1 deletion om_woocommerce/tests/test_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def test_signed_webhook_is_queued_once(self):

def test_wrong_signature(self):
body = json.dumps({'id': 1}).encode()
self.assertEqual(self.post(body, secret='not-the-secret').status_code, 401)
with self.assertLogs('odoo.addons.om_woocommerce.controllers.webhook', 'WARNING'):
self.assertEqual(self.post(body, secret='not-the-secret').status_code, 401)
self.assertFalse(self.jobs())

def test_ping_and_unknown(self):
Expand Down
Loading