From d0f569c50b697e24c5f0acd8266ad9db0e64d040 Mon Sep 17 00:00:00 2001 From: Zeke Gabrielse Date: Fri, 5 Jul 2024 09:12:22 -0500 Subject: [PATCH 1/2] fix observer gem errors --- Gemfile | 2 +- Gemfile.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index d3636133c1..001fbdc942 100644 --- a/Gemfile +++ b/Gemfile @@ -128,7 +128,7 @@ group :test do gem 'rspec-rails', '~> 6.0.3' gem 'rspec-expectations', '~> 3.12.1' gem 'anbt-sql-formatter' - gem 'factory_bot_rails', '~> 6.2' + gem 'factory_bot_rails', '~> 6.4' gem 'database_cleaner', '~> 2.0' gem 'webmock', '~> 3.14.0' gem 'elif', '~> 0.1.0' diff --git a/Gemfile.lock b/Gemfile.lock index f1818acfd7..8193c12753 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -205,10 +205,10 @@ GEM erubis (2.7.0) et-orbi (1.2.7) tzinfo - factory_bot (6.2.1) + factory_bot (6.4.6) activesupport (>= 5.0.0) - factory_bot_rails (6.2.0) - factory_bot (~> 6.2.0) + factory_bot_rails (6.4.3) + factory_bot (~> 6.4) railties (>= 5.0.0) faker (2.20.0) i18n (>= 1.8.11, < 2) @@ -526,7 +526,7 @@ DEPENDENCIES dotenv-rails ed25519 elif (~> 0.1.0) - factory_bot_rails (~> 6.2) + factory_bot_rails (~> 6.4) faker (~> 2.20.0) haml-rails has_scope From b7eaf33387ae429bd3a298b12217c6c6e4fbcf81 Mon Sep 17 00:00:00 2001 From: Zeke Gabrielse Date: Fri, 5 Jul 2024 10:05:54 -0500 Subject: [PATCH 2/2] add support for tauri v2 --- .../tauri/upgrades_controller.rb | 18 +- .../v1/engines/tauri/{ => v1}/upgrade.feature | 2 +- .../api/v1/engines/tauri/v2/upgrade.feature | 427 ++++++++++++++++++ 3 files changed, 442 insertions(+), 5 deletions(-) rename features/api/v1/engines/tauri/{ => v1}/upgrade.feature (99%) create mode 100644 features/api/v1/engines/tauri/v2/upgrade.feature diff --git a/app/controllers/api/v1/release_engines/tauri/upgrades_controller.rb b/app/controllers/api/v1/release_engines/tauri/upgrades_controller.rb index fee1e00cd0..bf0c77c653 100644 --- a/app/controllers/api/v1/release_engines/tauri/upgrades_controller.rb +++ b/app/controllers/api/v1/release_engines/tauri/upgrades_controller.rb @@ -29,16 +29,26 @@ def show artifacts = authorized_scope(upgrade.artifacts) artifact = artifacts.joins(:platform, :arch, :filetype) + .where.not(filetype: { key: %w[sig] }) .reorder( - # NOTE(ezekg) Order so that NSIS always takes precedence - # over deprecated MSI on conflict. + # NOTE(ezekg) Prioritize Tauri v1 update bundles over Tauri v2 for backwards + # compatibility, as v2 dropped most compressed formats. We also + # let NSIS take precedence over deprecated MSI. + # + # 1. For Tauri v1, `.zip` and `.gz` take precedence over uncompressed formats. + # 2. For Tauri v1, `.nsis.zip` takes precedence `.msi.zip`. + # 3. For Tauri v2, `.exe` takes precedence over `.msi`. + # + # Since Tauri v2 no longer produces most compressed formats, + # this should be backwards compatible. Arel.sql(<<~SQL.squish) + release_artifacts.filename ILIKE ANY (ARRAY['%.zip', '%.gz']) DESC, release_artifacts.filename ILIKE '%.nsis.zip' DESC, + release_artifacts.filename ILIKE '%.exe' DESC, release_artifacts.created_at DESC SQL ) .find_by!( - filetype: { key: %w[gz zip] }, platform: { key: platform }, arch: { key: arch }, ) @@ -54,7 +64,7 @@ def show }, ) - # See: https://tauri.app/v1/guides/distribution/updater + # See: https://v2.tauri.app/plugin/updater/#dynamic-update-server render json: { url: vanity_v1_account_release_artifact_url(artifact.account, artifact, filename: artifact.filename), signature: artifact.signature, diff --git a/features/api/v1/engines/tauri/upgrade.feature b/features/api/v1/engines/tauri/v1/upgrade.feature similarity index 99% rename from features/api/v1/engines/tauri/upgrade.feature rename to features/api/v1/engines/tauri/v1/upgrade.feature index 01761c468a..17b0ef54e8 100644 --- a/features/api/v1/engines/tauri/upgrade.feature +++ b/features/api/v1/engines/tauri/v1/upgrade.feature @@ -1,5 +1,5 @@ @api/v1 -Feature: Tauri upgrade package +Feature: Tauri v1 upgrade application Background: Given the following "accounts" exist: | name | slug | diff --git a/features/api/v1/engines/tauri/v2/upgrade.feature b/features/api/v1/engines/tauri/v2/upgrade.feature new file mode 100644 index 0000000000..d4b52c1175 --- /dev/null +++ b/features/api/v1/engines/tauri/v2/upgrade.feature @@ -0,0 +1,427 @@ +@api/v1 +Feature: Tauri v2 upgrade application + Background: + Given the following "accounts" exist: + | name | slug | + | Test 1 | test1 | + | Test 2 | test2 | + And the current account is "test1" + And the current account has the following "product" rows: + | id | name | + | 6198261a-48b5-4445-a045-9fed4afc7735 | Test | + And the current account has the following "package" rows: + | id | product_id | engine | key | + | 46e034fe-2312-40f8-bbeb-7d9957fb6fcf | 6198261a-48b5-4445-a045-9fed4afc7735 | tauri | app1 | + | 2f8af04a-2424-4ca2-8480-6efe24318d1a | 6198261a-48b5-4445-a045-9fed4afc7735 | tauri | app2 | + | 7b113ac2-ae81-406a-b44e-f356126e2faa | 6198261a-48b5-4445-a045-9fed4afc7735 | pypi | pkg1 | + | 5666d47e-936e-4d48-8dd7-382d32462b4e | 6198261a-48b5-4445-a045-9fed4afc7735 | | pkg2 | + And the current account has the following "release" rows: + | id | product_id | release_package_id | version | channel | description | + | 757e0a41-835e-42ad-bad8-84cabd29c72a | 6198261a-48b5-4445-a045-9fed4afc7735 | 46e034fe-2312-40f8-bbeb-7d9957fb6fcf | 1.0.0 | stable | foo | + | 028a38a2-0d17-4871-acb8-c5e6f040fc12 | 6198261a-48b5-4445-a045-9fed4afc7735 | 46e034fe-2312-40f8-bbeb-7d9957fb6fcf | 1.1.0 | stable | bar | + | 2bbb14ae-bb6b-4c57-b6ab-26f7982c967d | 6198261a-48b5-4445-a045-9fed4afc7735 | 46e034fe-2312-40f8-bbeb-7d9957fb6fcf | 1.2.0-beta.1 | beta | | + | c77ba874-de62-4a17-8368-fc10db1e1c80 | 6198261a-48b5-4445-a045-9fed4afc7735 | 2f8af04a-2424-4ca2-8480-6efe24318d1a | 1.0.0-beta.1 | beta | baz | + | 29f74047-265f-452c-9d64-779621682857 | 6198261a-48b5-4445-a045-9fed4afc7735 | 2f8af04a-2424-4ca2-8480-6efe24318d1a | 1.0.1-beta.1 | beta | baz | + | 972aa5b8-b12c-49f4-8ba4-7c9ae053dfa2 | 6198261a-48b5-4445-a045-9fed4afc7735 | 2f8af04a-2424-4ca2-8480-6efe24318d1a | 2.0.0-beta.1 | beta | qux | + And the current account has the following "artifact" rows: + | id | release_id | filename | filetype | platform | arch | signature | + # 1.0.0 + | 1f63d6ec-8147-4bf0-bcd2-5d4f0e5eab8f | 757e0a41-835e-42ad-bad8-84cabd29c72a | myapp.AppImage | appimage | linux | x86_64 | KhuUa6VkDwE1CxJ37Z2bokP4OCeFDtA457rCoeL3it8zvjlLHw4JB29/OV6mn0cwtcW985kcLxkeD7LmLs7KUw== | + | c1f8705e-68cd-4312-b2b1-72e19df47bd1 | 757e0a41-835e-42ad-bad8-84cabd29c72a | myapp.AppImage.sig | sig | linux | x86_64 | PGXlpwysSCW2qsWXwBHeBWAlUP+s0E3mhUufAHpU9IpIjIufWDVbu9/8GTuxCKvElDcq/b59HnwNSDXx4deOLw== | + | 2fd19ae7-e0cf-4de0-ad4a-1ca65db75c87 | 757e0a41-835e-42ad-bad8-84cabd29c72a | myapp.app | app | darwin | x86_64 | N7XdIjFjUxsaldjvUiPeTqrMZgcvcx9+DTEslA26iouEcMEwP9Wlc90VHzed+f/V47FpDrPQrUsBjPDcSNPsGw== | + | a8e49ea6-17df-4798-937f-e4756e331db5 | 757e0a41-835e-42ad-bad8-84cabd29c72a | myapp.app.tar.gz | gz | darwin | x86_64 | d4LD3Wc6/wkAH6ZM+e4a4RYwoCMmsigGDdO8fG8xpywOKtoyE1oE5gJRvaiEpkZ00JsxtJuzfwIov1sQg30KdA== | + | adce1d8b-7120-43b6-a42a-a64c24ed2a25 | 757e0a41-835e-42ad-bad8-84cabd29c72a | myapp.app.tar.gz.sig | sig | darwin | x86_64 | YDacBfpcurpkoOrDGhpbguhYlwDC7nTuyevwMJTXnwEHbcdO52SJU6bSKgNYHsU4UpYz3ShDG88eL4QtOITSNA== | + | fa773c2b-1c3a-4bd8-83fe-546480e92098 | 757e0a41-835e-42ad-bad8-84cabd29c72a | myapp-setup.exe | exe | windows | x86_64 | /nYfyW4+9j1i+VcJxmq6wlcVc9JnxvC01OuzvNvVyl8GjmFQpZhjHimcjaGSnc1Jg4y99l33kQhF0Ju3ThZtpQ== | + | 1cccff81-8b49-40b2-9453-3456f2ca04ac | 757e0a41-835e-42ad-bad8-84cabd29c72a | myapp-setup.exe.sig | sig | windows | x86_64 | tOfzZilkppAQWhtT6buV7tZUdzDNOZK1YjNkslSSafzsvsuQmSbk9XfXXQEeF1iSgbM+x8fGlCcTjuBDSZZS1Q== | + | ab3f9749-3ea7-4057-92ec-d647784ff097 | 757e0a41-835e-42ad-bad8-84cabd29c72a | myapp.msi | msi | windows | x86_64 | AvUSjpAijmte0EuiWtfj0iajkKqJn11tiKGEomaQzFEqULaAUsoE/aME9akekNnPC3jQp3gu7mHgJvAlwXZBBA== | + | a2fd1960-54c6-4624-83d1-84f0c8dd1f1a | 757e0a41-835e-42ad-bad8-84cabd29c72a | myapp.msi.sig | sig | windows | x86_64 | xlHIObWDYsjaYOl1EZEGGfkpi1DlT8/73vkJ2gBdFKQBcPJa4iwI4887vQnfi65fH+s3ptcOjmrtiiRnqTTt4w= | + # 1.1.0 + | 00aeec65-165c-487c-8e22-7ab454319b0f | 028a38a2-0d17-4871-acb8-c5e6f040fc12 | myapp.AppImage | appimage | linux | x86_64 | 93pUF68vzR3QRoGSXHbTQ9XVvXNburu5ofuFFLcrm1C1ZD9C2fr5mcaG06RljftY1HUzlFrpFmk9WVEbwr18tQ== | + | 394180bd-4e0d-4d1b-986d-e4befad92101 | 028a38a2-0d17-4871-acb8-c5e6f040fc12 | myapp.AppImage.sig | sig | linux | x86_64 | Lc4r8JwhtfB7y9AhQ48uQiITGBXeockeMrsZU6kFk9dSF0dAi6SDWCFUsrJbUYPRhN2eduQdk8fHq0GwRD/dgw== | + | 65132a0a-4ca9-4422-b836-0cd39b0a94f7 | 028a38a2-0d17-4871-acb8-c5e6f040fc12 | myapp.app | app | darwin | x86_64 | DrLt7Nc1tqwsPehg5TxG7OKz2qLaDt0F61xPN6KCZjULc8OWVO2m+WAZdDFnzh+edHWtSawYWgwlIUREnYzKmQ== | + | 77aaaf13-cfc3-4339-8350-163efcaf8814 | 028a38a2-0d17-4871-acb8-c5e6f040fc12 | myapp.app.tar.gz | gz | darwin | x86_64 | qjuxG7/3e44SUMRWSc8h3mOMk11L8lMSpKmEujgYmSjc+PnRY/Jedbw74a0+AMWkGSBCXvOISWK3bfylbNkaxw== | + | 8bdc0604-6948-4ab7-82bc-2b9a19153367 | 028a38a2-0d17-4871-acb8-c5e6f040fc12 | myapp.app.tar.gz.sig | sig | darwin | x86_64 | AB/jy6vPxiW8grw86W9iDNqV/hrs2NKRakT9shzyJtv6LO9cza5FBoJctzH2B3Z84x5Vq19vwU66QUf5Ac7+lw== | + | 2133955c-137f-4422-9290-9a364b1a40a0 | 028a38a2-0d17-4871-acb8-c5e6f040fc12 | myapp-setup.exe | exe | windows | x86_64 | BQfSyTfYWnHrl7LywK/fcioco+6IM4y1ermCGf5MjV1HT9VZ5ZtWRlQUM0UrPEXZct/gFYOf/THLk7mTvLUw1A== | + | ba8dd592-2c3e-46bf-afdc-dabc2fed9d8e | 028a38a2-0d17-4871-acb8-c5e6f040fc12 | myapp-setup.exe.sig | sig | windows | x86_64 | gBbZS6U0bu6lDtfT0ntoATXijot9PwCTj38rSD0Np7Vs6Jh73oL7caa9Td4MFHq/wt1t70gLPPaHoNvOWEN+2w== | + | eaa67d65-f596-427a-8f64-80a7125ae299 | 028a38a2-0d17-4871-acb8-c5e6f040fc12 | myapp.msi | msi | windows | x86_64 | OE7wQq5K4TNsQ2nyZCuJhpOSS45t5/G0S3IbPKhOhVWYUJtwu4a4wwTHr04f6JTas8jiklJPdLS3wuXZ749fEw== | + | c185d92b-1232-4bdd-9906-fa4d99e259c7 | 028a38a2-0d17-4871-acb8-c5e6f040fc12 | myapp.msi.sig | sig | windows | x86_64 | DbSIbY2X0YRCySCC+xQeeber/9A45KZxHSyjNh4FSfQRkbK/jTCZ+MpIZ7geWu4Jx0FVq+7R9qj8Gtiz3TaEYg== | + # 1.2.0-beta.1 + | 05f8a823-b80b-4453-a524-82332fc50792 | 2bbb14ae-bb6b-4c57-b6ab-26f7982c967d | myapp.AppImage | appimage | linux | x86_64 | Zd9e9c4l6Z1pHJPjFzYSWKLmzaQG1d/80hWMM5QbcnBBdNzObcJFGbmXJzAzrNRI1F9K6npGWlCFLZikvFm4rA== | + | 623efc8c-c2c9-46a1-9d1d-ff24e34a3359 | 2bbb14ae-bb6b-4c57-b6ab-26f7982c967d | myapp.AppImage.sig | sig | linux | x86_64 | +X5qPRP3+DGO2JcTuakCVyTdCeK9xRrdMHfiqBFRMSiRKOImlhRN8ja5mK9FDtAqGlS0F9MnK2rITLzJh+uYLQ== | + | 1eff1d91-02ff-44ec-8b44-1a11c10461ab | 2bbb14ae-bb6b-4c57-b6ab-26f7982c967d | myapp.app | app | darwin | x86_64 | IFd4DUPeV53K7Ts6XvpT4GrnoZW25w1nYRXsyNEGo0n9yAbx4cs2NTrliHXz+GbPN5OaEadlCAul33WvvthJvA== | + | 4502501f-8371-4aa8-acac-fff32c204a41 | 2bbb14ae-bb6b-4c57-b6ab-26f7982c967d | myapp.app.tar.gz | gz | darwin | x86_64 | Dp/hr/+5PfyRzvYgm9CyFVixGeS662piAsKIeO2b/nHrS/XgPExt7l4mqkH1UWpDokC00eY2LbQjaf4c5bWi1w== | + | 260b1b8d-bf7e-4738-bad0-5316373da8f5 | 2bbb14ae-bb6b-4c57-b6ab-26f7982c967d | myapp.app.tar.gz.sig | sig | darwin | x86_64 | pwaEooOf8pKsr3VScsXUWjPB202reCD47KbOE0ZG2njOANH7wXifW4CMh6PRISsa08WkO41IGrhISX2C7kVwwQ== | + | d5405732-577f-42eb-bd53-3bbc524072f0 | 2bbb14ae-bb6b-4c57-b6ab-26f7982c967d | myapp-setup.exe | exe | windows | x86_64 | HmRBSDpEPZJQThHKOVViieS5xhx8HN9B2xieSp/8CV7FbOVsC62l5KaM27wrG6DFYyCCVUboNaYncB2a7vvOYA== | + | 419ba987-9184-4baf-82bf-8ca9baa4e267 | 2bbb14ae-bb6b-4c57-b6ab-26f7982c967d | myapp-setup.exe.sig | sig | windows | x86_64 | uAAQVTGXau6Y6WNUIHBEzahPFn34E6poG78Ip9Bc9urgLuTzZgyQAaohS6nU4wuQdftUTwZbVxpYpXlAh/fDbg== | + | becabe1f-4b3f-4a83-9ab4-27fdb1ba07fe | 2bbb14ae-bb6b-4c57-b6ab-26f7982c967d | myapp.msi | msi | windows | x86_64 | 167ASeXh6NLamALrvdbIEpuB2PJqLpkrBHpvTy0L7FSvDTQZzGwY7b0zBgFlHyHlSnzJw9y2dC4xQgYAK5EiwA== | + | d2801d8a-5ce8-4c48-89ee-7177d7dcc84c | 2bbb14ae-bb6b-4c57-b6ab-26f7982c967d | myapp.msi.sig | sig | windows | x86_64 | uUsbx9f9ZGlN/45rBK3ZRy7/QNJNdsyG5f18dIt1FO0caAPr5cBxBIuUAbmIC7FnrECrDLcaL18GQ8MeB86WOA== | + # 1.0.0-beta.1 + | 699a9b1e-6d57-428a-b039-cb387de7d6ff | c77ba874-de62-4a17-8368-fc10db1e1c80 | myapp-setup.exe | exe | windows | i686 | dQj9GEoEqv0jxagPuks0zPCs3RIXi0fBvxsXUEkyeNwt372dRtjyJxHNAzEys9vsWCAI+FcH3erTmzVwtoQkgA== | + | f36df79d-5952-4d7d-ae13-87198e1cd0f0 | c77ba874-de62-4a17-8368-fc10db1e1c80 | myapp-setup.exe.sig | sig | windows | i686 | nr20BEyN5xnWX3I+OxDX85GhGoABpvJGevnmo95nBdHdxFxKCQMLRwQaVqCh++RRRAWv22Hq1VZcxpwumOwuLw== | + | 375d8a5a-e839-4bc1-a168-e376baf27c78 | c77ba874-de62-4a17-8368-fc10db1e1c80 | myapp.msi | msi | windows | i686 | foTILz/82kERvo9wdYprCKw/zCq4tA409RSnFAhMbSXbn6Co9MBmSIVjVFaVIP/cy74oXDUAuRHscQVwEUH1rA== | + | ecdb59f6-00c1-4fec-80bd-7fc176f9d1a0 | c77ba874-de62-4a17-8368-fc10db1e1c80 | myapp.msi.sig | sig | windows | i686 | qJ6ij921jgD6yJ3UknE5IFAiSfFPTcUZPkqGj+WwfedTKPz7d7NmiUZRxPoajz/GKLimBoXdEm0a57L+yFEejw== | + # 1.0.1-beta.1 + | 05b82ab6-ad64-46d4-9885-97a23347eb1c | 29f74047-265f-452c-9d64-779621682857 | myapp-setup.exe | exe | windows | i686 | w3tDl0PCRIBM8t07D8fWpl102zpxiKKYJ8E6oCLBxiXYBB3Zvb52osFgrw6H8nPrqNu3Ax0NV8VKtBmmxxUN3A== | + | cefb4032-6e1b-4411-8e85-f5d7d8a269a2 | 29f74047-265f-452c-9d64-779621682857 | myapp-setup.exe.sig | sig | windows | i686 | dA4En1FgSfi+6O8O+DY5bCchQkVxRGR8w+4pKfGjpug6+/4wwrZgmlhOfs364eKVtf7UcWsZ9vopF0E6HV28UA== | + | 1adda3a2-021d-4d76-b715-6907ce7d78c2 | 29f74047-265f-452c-9d64-779621682857 | myapp.msi | msi | windows | i686 | G0ocYvc2INVNpBcaoDEaAwQhAxX9/xxNv1g44NICAnMU+Z8V6ohUGtoX2Q8adDOo7JE8/picj+i1gwWb5Em1Fw== | + | 2986a294-fc70-4a99-805e-e91b90b4ec2b | 29f74047-265f-452c-9d64-779621682857 | myapp.msi.sig | sig | windows | i686 | CW5imayiWMU50dYJIW1CMDxMW0qr01YUGd97r4IOs2WZlpcl1OIyeYvKgDNAJXkBBSbi9QPG21I3OxJxecsoBw== | + # 2.0.0-beta.1 + | 16b9a3fa-6b12-4d86-b81e-be2757392bae | 972aa5b8-b12c-49f4-8ba4-7c9ae053dfa2 | myapp-setup.exe | exe | windows | i686 | 1/ZheqnqL3OJbQcUa+zmFCENiXqhW1oqrUP2sREyExryaDRcy14lC6nSHg4gt/TfbHkE1ANnsEFizRdno+uZZg== | + | e1a9d063-cd8d-4655-95e5-647c961852eb | 972aa5b8-b12c-49f4-8ba4-7c9ae053dfa2 | myapp-setup.exe.sig | sig | windows | i686 | Rpvx4kMZlfBr1lM7GwA1tJA7qeRGfNACOIYXwyxqTH6RkqIvcNcB8dl3ZcdEqdF46l1oFDiWYcI5xYE35/NSlA== | + | 61987e0a-1848-4a04-9b2a-86ff6a7f464b | 972aa5b8-b12c-49f4-8ba4-7c9ae053dfa2 | myapp.msi | msi | windows | i686 | 3vw5nDxg8qAZ4yPtPvBb0BJf5I+Df7zveGPDWEhOFAfeSfPhUuxbwePy/inD16AQM/K2ovHPpBMsZ9nmpI/r9A== | + | dd61752e-187e-4346-a7df-fda80adb7131 | 972aa5b8-b12c-49f4-8ba4-7c9ae053dfa2 | myapp.msi.sig | sig | windows | i686 | /oBea3DwxhueGOhoKQ9JxTBHamr9cp85WyJI5p50FeRqq9zELjroza7h5/c33CgZGnx1klSo4omAqWgdupx+8g== | + And I send the following raw headers: + """ + User-Agent: tauri-updater + Accept: application/octet-stream + """ + + Scenario: Endpoint should be inaccessible when account is disabled + Given the account "test1" is canceled + And I am an admin of account "test1" + And I use an authentication token + When I send a GET request to "/accounts/test1/engines/tauri/app1?platform=linux&arch=x86_64&version=1.0.0" + Then the response status should be "403" + And the response should contain the following headers: + """ + { "Content-Type": "application/json; charset=utf-8" } + """ + + Scenario: Endpoint should not return an upgrade when an upgrade is not available + Given the current account has 1 "webhook-endpoint" + And I am an admin of account "test1" + And I use an authentication token + When I send a GET request to "/accounts/test1/engines/tauri/app1?platform=linux&arch=x86_64&version=1.1.0" + Then the response status should be "204" + And sidekiq should have 0 "webhook" jobs + And sidekiq should have 0 "metric" jobs + And sidekiq should have 1 "request-log" job + + Scenario: Endpoint should not return an upgrade when a version does not exist + Given the current account has 1 "webhook-endpoint" + And I am an admin of account "test1" + And I use an authentication token + When I send a GET request to "/accounts/test1/engines/tauri/app1?platform=linux&arch=x86_64&version=3.0.0" + Then the response status should be "204" + And sidekiq should have 0 "webhook" jobs + And sidekiq should have 0 "metric" jobs + And sidekiq should have 1 "request-log" job + + Scenario: Endpoint should return an upgrade when an upgrade is available + Given the current account has 1 "webhook-endpoint" + And I am an admin of account "test1" + And I use an authentication token + When I send a GET request to "/accounts/test1/engines/tauri/app1?platform=linux&arch=x86_64&version=1.0.0" + Then the response status should be "200" + And the response body should include the following: + """ + { + "url": "https://api.keygen.sh/v1/accounts/$account/artifacts/00aeec65-165c-487c-8e22-7ab454319b0f/myapp.AppImage", + "signature": "93pUF68vzR3QRoGSXHbTQ9XVvXNburu5ofuFFLcrm1C1ZD9C2fr5mcaG06RljftY1HUzlFrpFmk9WVEbwr18tQ==", + "version": "1.1.0" + } + """ + And sidekiq should have 1 "webhook" job + And sidekiq should have 1 "metric" job + And sidekiq should have 1 "request-log" job + + Scenario: Endpoint should prefer NSIS over MSI for windows + Given I am an admin of account "test1" + And I use an authentication token + When I send a GET request to "/accounts/test1/engines/tauri/app2?platform=windows&arch=i686&version=1.0.0-beta.1" + Then the response status should be "200" + And the response body should include the following: + """ + { + "url": "https://api.keygen.sh/v1/accounts/$account/artifacts/16b9a3fa-6b12-4d86-b81e-be2757392bae/myapp-setup.exe", + "signature": "1/ZheqnqL3OJbQcUa+zmFCENiXqhW1oqrUP2sREyExryaDRcy14lC6nSHg4gt/TfbHkE1ANnsEFizRdno+uZZg==", + "version": "2.0.0-beta.1" + } + """ + + Scenario: Endpoint should include release notes when available + Given I am an admin of account "test1" + And I use an authentication token + When I send a GET request to "/accounts/test1/engines/tauri/app1?platform=darwin&arch=x86_64&version=1.0.0" + Then the response status should be "200" + And the response body should include the following: + """ + { "notes": "bar" } + """ + + Scenario: Endpoint should include publish date when available + Given the second "release" has the following attributes: + """ + { "createdAt": "2023-08-15T00:00:00.000Z" } + """ + And I am an admin of account "test1" + And I use an authentication token + When I send a GET request to "/accounts/test1/engines/tauri/app1?platform=darwin&arch=x86_64&version=1.0.0" + Then the response status should be "200" + And the response body should include the following: + """ + { "pub_date": "2023-08-15T00:00:00.000Z" } + """ + + Scenario: Endpoint should constrain to a semver constraint + Given the second "release" has the following attributes: + """ + { "createdAt": "2023-08-15T00:00:00.000Z" } + """ + And I am an admin of account "test1" + And I use an authentication token + When I send a GET request to "/accounts/test1/engines/tauri/app2?platform=windows&arch=i686&version=1.0.0-beta.1&constraint=1.0" + Then the response status should be "200" + And the response body should include the following: + """ + { + "url": "https://api.keygen.sh/v1/accounts/$account/artifacts/05b82ab6-ad64-46d4-9885-97a23347eb1c/myapp-setup.exe", + "signature": "w3tDl0PCRIBM8t07D8fWpl102zpxiKKYJ8E6oCLBxiXYBB3Zvb52osFgrw6H8nPrqNu3Ax0NV8VKtBmmxxUN3A==", + "version": "1.0.1-beta.1" + } + """ + + Scenario: Endpoint should upgrade from stable to beta + Given the second "release" has the following attributes: + """ + { "createdAt": "2023-08-15T00:00:00.000Z" } + """ + And I am an admin of account "test1" + And I use an authentication token + When I send a GET request to "/accounts/test1/engines/tauri/app1?platform=linux&arch=x86_64&version=1.1.0&channel=beta" + Then the response status should be "200" + And the response body should include the following: + """ + { + "url": "https://api.keygen.sh/v1/accounts/$account/artifacts/05f8a823-b80b-4453-a524-82332fc50792/myapp.AppImage", + "signature": "Zd9e9c4l6Z1pHJPjFzYSWKLmzaQG1d/80hWMM5QbcnBBdNzObcJFGbmXJzAzrNRI1F9K6npGWlCFLZikvFm4rA==", + "version": "1.2.0-beta.1" + } + """ + + Scenario: Endpoint should return error for non-Tauri packages + Given I am an admin of account "test1" + And I use an authentication token + When I send a GET request to "/accounts/test1/engines/tauri/pkg1?platform=darwin&arch=x86_64&version=1.0.0" + Then the response status should be "404" + + Scenario: Endpoint should return error for missing platform + Given I am an admin of account "test1" + And I use an authentication token + When I send a GET request to "/accounts/test1/engines/tauri/app1?arch=x86_64&version=1.0.0" + Then the response status should be "400" + And the first error should have the following properties: + """ + { + "title": "Bad request", + "detail": "is missing", + "source": { + "parameter": "platform" + } + } + """ + + Scenario: Endpoint should return error for missing arch + Given I am an admin of account "test1" + And I use an authentication token + When I send a GET request to "/accounts/test1/engines/tauri/app1?platform=darwin&version=1.0.0" + Then the response status should be "400" + And the first error should have the following properties: + """ + { + "title": "Bad request", + "detail": "is missing", + "source": { + "parameter": "arch" + } + } + """ + + Scenario: Endpoint should return error for missing version + Given I am an admin of account "test1" + And I use an authentication token + When I send a GET request to "/accounts/test1/engines/tauri/app1?platform=darwin&arch=x86_64" + Then the response status should be "400" + And the first error should have the following properties: + """ + { + "title": "Bad request", + "detail": "is missing", + "source": { + "parameter": "version" + } + } + """ + + Scenario: Product retrieves an upgrade when an upgrade is available + Given I am the first product of account "test1" + And I use an authentication token + When I send a GET request to "/accounts/test1/engines/tauri/app1?platform=windows&arch=x86_64&version=1.0.0" + Then the response status should be "200" + And the response body should include the following: + """ + { + "url": "https://api.keygen.sh/v1/accounts/$account/artifacts/2133955c-137f-4422-9290-9a364b1a40a0/myapp-setup.exe", + "signature": "BQfSyTfYWnHrl7LywK/fcioco+6IM4y1ermCGf5MjV1HT9VZ5ZtWRlQUM0UrPEXZct/gFYOf/THLk7mTvLUw1A==", + "version": "1.1.0" + } + """ + + Scenario: License retrieves an upgrade when an upgrade is available + Given the current account has 1 "policy" for the last "product" with the following: + """ + { "authenticationStrategy": "LICENSE" } + """ + And the current account has 1 "license" for the last "policy" + And I am a license of account "test1" + And I authenticate with my key + When I send a GET request to "/accounts/test1/engines/tauri/app1?platform=darwin&arch=x86_64&version=1.0.0" + Then the response status should be "200" + And the response body should include the following: + """ + { + "url": "https://api.keygen.sh/v1/accounts/$account/artifacts/77aaaf13-cfc3-4339-8350-163efcaf8814/myapp.app.tar.gz", + "signature": "qjuxG7/3e44SUMRWSc8h3mOMk11L8lMSpKmEujgYmSjc+PnRY/Jedbw74a0+AMWkGSBCXvOISWK3bfylbNkaxw==", + "version": "1.1.0" + } + """ + + Scenario: License retrieves an upgrade for a release that has entitlement constraints (no entitlements) + Given the current account has 3 "entitlements" + And the current account has 1 "release-entitlement-constraint" with the following: + """ + { + "entitlementId": "$entitlements[0]", + "releaseId": "$releases[0]" + } + """ + And the current account has 1 "policy" for the last "product" with the following: + """ + { "authenticationStrategy": "LICENSE" } + """ + And the current account has 1 "license" for the last "policy" + And I am a license of account "test1" + And I authenticate with my key + When I send a GET request to "/accounts/test1/engines/tauri/app1?platform=darwin&arch=x86_64&version=1.0.0" + Then the response status should be "204" + + Scenario: License retrieves an upgrade that has entitlement constraints (no entitlements) + Given the current account has 3 "entitlements" + And the current account has 1 "release-entitlement-constraint" with the following: + """ + { + "entitlementId": "$entitlements[0]", + "releaseId": "$releases[1]" + } + """ + And the current account has 1 "policy" for the last "product" with the following: + """ + { "authenticationStrategy": "LICENSE" } + """ + And the current account has 1 "license" for the last "policy" + And I am a license of account "test1" + And I authenticate with my key + When I send a GET request to "/accounts/test1/engines/tauri/app1?platform=darwin&arch=x86_64&version=1.0.0" + Then the response status should be "204" + + Scenario: License retrieves an upgrade that has entitlement constraints (has entitlements) + Given the current account has 3 "entitlements" + And the current account has 1 "release-entitlement-constraint" with the following: + """ + { + "entitlementId": "$entitlements[0]", + "releaseId": "$releases[1]" + } + """ + And the current account has 1 "policy" for the last "product" with the following: + """ + { "authenticationStrategy": "LICENSE" } + """ + And the current account has 1 "license" for the last "policy" + And the current account has 1 "license-entitlement" with the following: + """ + { + "entitlementId": "$entitlements[0]", + "licenseId": "$licenses[0]" + } + """ + And I am a license of account "test1" + And I authenticate with my key + When I send a GET request to "/accounts/test1/engines/tauri/app1?platform=darwin&arch=x86_64&version=1.0.0" + Then the response status should be "200" + And the response body should include the following: + """ + { + "url": "https://api.keygen.sh/v1/accounts/$account/artifacts/77aaaf13-cfc3-4339-8350-163efcaf8814/myapp.app.tar.gz", + "signature": "qjuxG7/3e44SUMRWSc8h3mOMk11L8lMSpKmEujgYmSjc+PnRY/Jedbw74a0+AMWkGSBCXvOISWK3bfylbNkaxw==", + "version": "1.1.0" + } + """ + + Scenario: User retrieves an upgrade when an upgrade is available (license owner) + Given the current account has 1 "policy" for the last "product" + And the current account has 1 "license" for the last "policy" + And the current account has 1 "user" + And the last "license" belongs to the last "user" through "owner" + And I am a user of account "test1" + And I use an authentication token + When I send a GET request to "/accounts/test1/engines/tauri/app1?platform=darwin&arch=x86_64&version=1.0.0" + Then the response status should be "200" + And the response body should include the following: + """ + { + "url": "https://api.keygen.sh/v1/accounts/$account/artifacts/77aaaf13-cfc3-4339-8350-163efcaf8814/myapp.app.tar.gz", + "signature": "qjuxG7/3e44SUMRWSc8h3mOMk11L8lMSpKmEujgYmSjc+PnRY/Jedbw74a0+AMWkGSBCXvOISWK3bfylbNkaxw==", + "version": "1.1.0" + } + """ + + Scenario: User retrieves an upgrade when an upgrade is available (license user) + Given the current account has 1 "policy" for the last "product" + And the current account has 1 "license" for the last "policy" + And the current account has 1 "user" + And the current account has 1 "license-user" for the last "license" and the last "user" + And I am a user of account "test1" + And I use an authentication token + When I send a GET request to "/accounts/test1/engines/tauri/app1?platform=darwin&arch=x86_64&version=1.0.0" + Then the response status should be "200" + And the response body should include the following: + """ + { + "url": "https://api.keygen.sh/v1/accounts/$account/artifacts/77aaaf13-cfc3-4339-8350-163efcaf8814/myapp.app.tar.gz", + "signature": "qjuxG7/3e44SUMRWSc8h3mOMk11L8lMSpKmEujgYmSjc+PnRY/Jedbw74a0+AMWkGSBCXvOISWK3bfylbNkaxw==", + "version": "1.1.0" + } + """ + + Scenario: Anonymous retrieves an upgrade for a licensed product + Given the last "product" has the following attributes: + """ + { "distributionStrategy": "LICENSED" } + """ + When I send a GET request to "/accounts/test1/engines/tauri/app1?platform=darwin&arch=x86_64&version=1.0.0" + Then the response status should be "404" + + Scenario: Anonymous retrieves an upgrade for a closed product + Given the last "product" has the following attributes: + """ + { "distributionStrategy": "CLOSED" } + """ + When I send a GET request to "/accounts/test1/engines/tauri/app1?platform=darwin&arch=x86_64&version=1.0.0" + Then the response status should be "404" + + Scenario: Anonymous retrieves an upgrade for an open product + Given the last "product" has the following attributes: + """ + { "distributionStrategy": "OPEN" } + """ + When I send a GET request to "/accounts/test1/engines/tauri/app1?platform=darwin&arch=x86_64&version=1.0.0" + Then the response status should be "200" + And the response body should include the following: + """ + { + "url": "https://api.keygen.sh/v1/accounts/$account/artifacts/77aaaf13-cfc3-4339-8350-163efcaf8814/myapp.app.tar.gz", + "signature": "qjuxG7/3e44SUMRWSc8h3mOMk11L8lMSpKmEujgYmSjc+PnRY/Jedbw74a0+AMWkGSBCXvOISWK3bfylbNkaxw==", + "version": "1.1.0" + } + """