From da3b08b0a60fd115ff316262eaed85db8375f0a6 Mon Sep 17 00:00:00 2001 From: Pavel Kirilin Date: Thu, 4 Jan 2024 15:15:38 +0300 Subject: [PATCH] Added mountebank --- src/backend/src/FoodDiary.API/Startup.cs | 3 + .../src/FoodDiary.API/appsettings.json | 5 +- .../GoogleAuthOptions.cs | 7 +- tests/.pnp.cjs | 218 ++++++++++++++++-- tests/docker-compose.yml | 6 + tests/fakeAuth.ts | 43 ++++ tests/package.json | 1 + tests/scenarios/main.spec.ts | 18 +- tests/yarn.lock | 169 +++++++++++++- 9 files changed, 446 insertions(+), 24 deletions(-) create mode 100644 tests/fakeAuth.ts diff --git a/src/backend/src/FoodDiary.API/Startup.cs b/src/backend/src/FoodDiary.API/Startup.cs index 7811f029c..73644c987 100644 --- a/src/backend/src/FoodDiary.API/Startup.cs +++ b/src/backend/src/FoodDiary.API/Startup.cs @@ -65,6 +65,9 @@ public void ConfigureServices(IServiceCollection services) }) .AddGoogle(Constants.AuthenticationSchemes.OAuthGoogle, options => { + options.AuthorizationEndpoint = _googleAuthOptions.AuthorizationEndpoint; + options.TokenEndpoint = _googleAuthOptions.TokenEndpoint; + options.UserInformationEndpoint = _googleAuthOptions.UserInformationEndpoint; options.SignInScheme = Constants.AuthenticationSchemes.Cookie; options.ClientId = _googleAuthOptions.ClientId; options.ClientSecret = _googleAuthOptions.ClientSecret; diff --git a/src/backend/src/FoodDiary.API/appsettings.json b/src/backend/src/FoodDiary.API/appsettings.json index cc07f368c..0997a4838 100644 --- a/src/backend/src/FoodDiary.API/appsettings.json +++ b/src/backend/src/FoodDiary.API/appsettings.json @@ -20,7 +20,10 @@ }, "GoogleAuth": { "ClientId": "772368064111-19hqh3c6ksu56ke45nm24etn7qoma88v.apps.googleusercontent.com", - "ClientSecret": "" + "ClientSecret": "", + "AuthorizationEndpoint": "https://accounts.google.com/o/oauth2/v2/auth", + "TokenEndpoint": "https://oauth2.googleapis.com/token", + "UserInformationEndpoint": "https://www.googleapis.com/oauth2/v2/userinfo" }, "Import": { "MaxImportFileLengthBytes": 5242880 diff --git a/src/backend/src/FoodDiary.Configuration/GoogleAuthOptions.cs b/src/backend/src/FoodDiary.Configuration/GoogleAuthOptions.cs index 05f868455..9ab828b89 100644 --- a/src/backend/src/FoodDiary.Configuration/GoogleAuthOptions.cs +++ b/src/backend/src/FoodDiary.Configuration/GoogleAuthOptions.cs @@ -2,6 +2,9 @@ namespace FoodDiary.Configuration; public class GoogleAuthOptions { - public string ClientId { get; set; } - public string ClientSecret { get; set; } + public string ClientId { get; init; } + public string ClientSecret { get; init; } + public string AuthorizationEndpoint { get; init; } + public string TokenEndpoint { get; init; } + public string UserInformationEndpoint { get; init; } } \ No newline at end of file diff --git a/tests/.pnp.cjs b/tests/.pnp.cjs index 2efa5fb4f..9f6b24ca4 100755 --- a/tests/.pnp.cjs +++ b/tests/.pnp.cjs @@ -26,6 +26,7 @@ const RAW_RUNTIME_STATE = [null, {\ "packageLocation": "./",\ "packageDependencies": [\ + ["@anev/ts-mountebank", "npm:1.8.0"],\ ["@playwright/test", "npm:1.40.1"],\ ["@types/eslint", "npm:8.56.0"],\ ["@types/node", "npm:18.19.4"],\ @@ -54,6 +55,17 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["@anev/ts-mountebank", [\ + ["npm:1.8.0", {\ + "packageLocation": "../../../../.yarn/berry/cache/@anev-ts-mountebank-npm-1.8.0-316f17d016-10c0.zip/node_modules/@anev/ts-mountebank/",\ + "packageDependencies": [\ + ["@anev/ts-mountebank", "npm:1.8.0"],\ + ["superagent", "npm:8.1.2"],\ + ["typescript", "patch:typescript@npm%3A5.3.3#optional!builtin::version=5.3.3&hash=e012d7"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["@eslint-community/eslint-utils", [\ ["npm:4.4.0", {\ "packageLocation": "../../../../.yarn/berry/cache/@eslint-community-eslint-utils-npm-4.4.0-d1791bd5a3-10c0.zip/node_modules/@eslint-community/eslint-utils/",\ @@ -106,7 +118,7 @@ const RAW_RUNTIME_STATE = "packageDependencies": [\ ["@eslint/eslintrc", "npm:2.1.4"],\ ["ajv", "npm:6.12.6"],\ - ["debug", "virtual:4b12ba5111caf7e8338099bdbc7cb046a9f8e079a44e74d0c03dca469876e3071ebbe671c5e90ae6b78ae33e22c205fa5ed32169a4aabd1404b13c56d09986e1#npm:4.3.4"],\ + ["debug", "virtual:44190e1fe988f8ed52651ed2ecff6428d5b112011682ca13abf2192dbac5d4ff82a2b10b21daf4cd9476daaebf3a3c670978e9dc2e2943ba8cf7ca5fca753eb3#npm:4.3.4"],\ ["espree", "npm:9.6.1"],\ ["globals", "npm:13.24.0"],\ ["ignore", "npm:5.3.0"],\ @@ -133,7 +145,7 @@ const RAW_RUNTIME_STATE = "packageDependencies": [\ ["@humanwhocodes/config-array", "npm:0.11.13"],\ ["@humanwhocodes/object-schema", "npm:2.0.1"],\ - ["debug", "virtual:4b12ba5111caf7e8338099bdbc7cb046a9f8e079a44e74d0c03dca469876e3071ebbe671c5e90ae6b78ae33e22c205fa5ed32169a4aabd1404b13c56d09986e1#npm:4.3.4"],\ + ["debug", "virtual:44190e1fe988f8ed52651ed2ecff6428d5b112011682ca13abf2192dbac5d4ff82a2b10b21daf4cd9476daaebf3a3c670978e9dc2e2943ba8cf7ca5fca753eb3#npm:4.3.4"],\ ["minimatch", "npm:3.1.2"]\ ],\ "linkType": "HARD"\ @@ -342,7 +354,7 @@ const RAW_RUNTIME_STATE = ["@typescript-eslint/type-utils", "virtual:7bd6dca9b702c47be5b4180b684f7c592ed1c5ee9f7d79b3d07420f5ec92e2c2320a17042f0dcdfc9593ca6775b509df3fc3d2970608cda49ab73e27919526a0#npm:6.17.0"],\ ["@typescript-eslint/utils", "virtual:7bd6dca9b702c47be5b4180b684f7c592ed1c5ee9f7d79b3d07420f5ec92e2c2320a17042f0dcdfc9593ca6775b509df3fc3d2970608cda49ab73e27919526a0#npm:6.17.0"],\ ["@typescript-eslint/visitor-keys", "npm:6.17.0"],\ - ["debug", "virtual:4b12ba5111caf7e8338099bdbc7cb046a9f8e079a44e74d0c03dca469876e3071ebbe671c5e90ae6b78ae33e22c205fa5ed32169a4aabd1404b13c56d09986e1#npm:4.3.4"],\ + ["debug", "virtual:44190e1fe988f8ed52651ed2ecff6428d5b112011682ca13abf2192dbac5d4ff82a2b10b21daf4cd9476daaebf3a3c670978e9dc2e2943ba8cf7ca5fca753eb3#npm:4.3.4"],\ ["eslint", "npm:8.56.0"],\ ["graphemer", "npm:1.4.0"],\ ["ignore", "npm:5.3.0"],\ @@ -380,7 +392,7 @@ const RAW_RUNTIME_STATE = ["@typescript-eslint/types", "npm:6.17.0"],\ ["@typescript-eslint/typescript-estree", "virtual:99c2ca9c3ba3d50934cb8ed993c6adae14a50173dbf6227815300f5fd06645570c63f2e528a38b5ad8f155557fdced9ba0a03997ab89dedc796cde4e2d2099e6#npm:6.17.0"],\ ["@typescript-eslint/visitor-keys", "npm:6.17.0"],\ - ["debug", "virtual:4b12ba5111caf7e8338099bdbc7cb046a9f8e079a44e74d0c03dca469876e3071ebbe671c5e90ae6b78ae33e22c205fa5ed32169a4aabd1404b13c56d09986e1#npm:4.3.4"],\ + ["debug", "virtual:44190e1fe988f8ed52651ed2ecff6428d5b112011682ca13abf2192dbac5d4ff82a2b10b21daf4cd9476daaebf3a3c670978e9dc2e2943ba8cf7ca5fca753eb3#npm:4.3.4"],\ ["eslint", "npm:8.56.0"],\ ["typescript", "patch:typescript@npm%3A5.3.3#optional!builtin::version=5.3.3&hash=e012d7"]\ ],\ @@ -420,7 +432,7 @@ const RAW_RUNTIME_STATE = ["@types/typescript", null],\ ["@typescript-eslint/typescript-estree", "virtual:99c2ca9c3ba3d50934cb8ed993c6adae14a50173dbf6227815300f5fd06645570c63f2e528a38b5ad8f155557fdced9ba0a03997ab89dedc796cde4e2d2099e6#npm:6.17.0"],\ ["@typescript-eslint/utils", "virtual:7bd6dca9b702c47be5b4180b684f7c592ed1c5ee9f7d79b3d07420f5ec92e2c2320a17042f0dcdfc9593ca6775b509df3fc3d2970608cda49ab73e27919526a0#npm:6.17.0"],\ - ["debug", "virtual:4b12ba5111caf7e8338099bdbc7cb046a9f8e079a44e74d0c03dca469876e3071ebbe671c5e90ae6b78ae33e22c205fa5ed32169a4aabd1404b13c56d09986e1#npm:4.3.4"],\ + ["debug", "virtual:44190e1fe988f8ed52651ed2ecff6428d5b112011682ca13abf2192dbac5d4ff82a2b10b21daf4cd9476daaebf3a3c670978e9dc2e2943ba8cf7ca5fca753eb3#npm:4.3.4"],\ ["eslint", "npm:8.56.0"],\ ["ts-api-utils", "virtual:7bd6dca9b702c47be5b4180b684f7c592ed1c5ee9f7d79b3d07420f5ec92e2c2320a17042f0dcdfc9593ca6775b509df3fc3d2970608cda49ab73e27919526a0#npm:1.0.3"],\ ["typescript", "patch:typescript@npm%3A5.3.3#optional!builtin::version=5.3.3&hash=e012d7"]\ @@ -458,7 +470,7 @@ const RAW_RUNTIME_STATE = ["@types/typescript", null],\ ["@typescript-eslint/types", "npm:6.17.0"],\ ["@typescript-eslint/visitor-keys", "npm:6.17.0"],\ - ["debug", "virtual:4b12ba5111caf7e8338099bdbc7cb046a9f8e079a44e74d0c03dca469876e3071ebbe671c5e90ae6b78ae33e22c205fa5ed32169a4aabd1404b13c56d09986e1#npm:4.3.4"],\ + ["debug", "virtual:44190e1fe988f8ed52651ed2ecff6428d5b112011682ca13abf2192dbac5d4ff82a2b10b21daf4cd9476daaebf3a3c670978e9dc2e2943ba8cf7ca5fca753eb3#npm:4.3.4"],\ ["globby", "npm:11.1.0"],\ ["is-glob", "npm:4.0.3"],\ ["minimatch", "npm:9.0.3"],\ @@ -479,7 +491,7 @@ const RAW_RUNTIME_STATE = ["@types/typescript", null],\ ["@typescript-eslint/types", "npm:6.17.0"],\ ["@typescript-eslint/visitor-keys", "npm:6.17.0"],\ - ["debug", "virtual:4b12ba5111caf7e8338099bdbc7cb046a9f8e079a44e74d0c03dca469876e3071ebbe671c5e90ae6b78ae33e22c205fa5ed32169a4aabd1404b13c56d09986e1#npm:4.3.4"],\ + ["debug", "virtual:44190e1fe988f8ed52651ed2ecff6428d5b112011682ca13abf2192dbac5d4ff82a2b10b21daf4cd9476daaebf3a3c670978e9dc2e2943ba8cf7ca5fca753eb3#npm:4.3.4"],\ ["globby", "npm:11.1.0"],\ ["is-glob", "npm:4.0.3"],\ ["minimatch", "npm:9.0.3"],\ @@ -588,7 +600,7 @@ const RAW_RUNTIME_STATE = "packageLocation": "../../../../.yarn/berry/cache/agent-base-npm-7.1.0-4b12ba5111-10c0.zip/node_modules/agent-base/",\ "packageDependencies": [\ ["agent-base", "npm:7.1.0"],\ - ["debug", "virtual:4b12ba5111caf7e8338099bdbc7cb046a9f8e079a44e74d0c03dca469876e3071ebbe671c5e90ae6b78ae33e22c205fa5ed32169a4aabd1404b13c56d09986e1#npm:4.3.4"]\ + ["debug", "virtual:44190e1fe988f8ed52651ed2ecff6428d5b112011682ca13abf2192dbac5d4ff82a2b10b21daf4cd9476daaebf3a3c670978e9dc2e2943ba8cf7ca5fca753eb3#npm:4.3.4"]\ ],\ "linkType": "HARD"\ }]\ @@ -749,6 +761,24 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["asap", [\ + ["npm:2.0.6", {\ + "packageLocation": "../../../../.yarn/berry/cache/asap-npm-2.0.6-36714d439d-10c0.zip/node_modules/asap/",\ + "packageDependencies": [\ + ["asap", "npm:2.0.6"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ + ["asynckit", [\ + ["npm:0.4.0", {\ + "packageLocation": "../../../../.yarn/berry/cache/asynckit-npm-0.4.0-c718858525-10c0.zip/node_modules/asynckit/",\ + "packageDependencies": [\ + ["asynckit", "npm:0.4.0"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["available-typed-arrays", [\ ["npm:1.0.5", {\ "packageLocation": "../../../../.yarn/berry/cache/available-typed-arrays-npm-1.0.5-88f321e4d3-10c0.zip/node_modules/available-typed-arrays/",\ @@ -905,6 +935,25 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["combined-stream", [\ + ["npm:1.0.8", {\ + "packageLocation": "../../../../.yarn/berry/cache/combined-stream-npm-1.0.8-dc14d4a63a-10c0.zip/node_modules/combined-stream/",\ + "packageDependencies": [\ + ["combined-stream", "npm:1.0.8"],\ + ["delayed-stream", "npm:1.0.0"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ + ["component-emitter", [\ + ["npm:1.3.1", {\ + "packageLocation": "../../../../.yarn/berry/cache/component-emitter-npm-1.3.1-c2a8131a7e-10c0.zip/node_modules/component-emitter/",\ + "packageDependencies": [\ + ["component-emitter", "npm:1.3.1"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["concat-map", [\ ["npm:0.0.1", {\ "packageLocation": "../../../../.yarn/berry/cache/concat-map-npm-0.0.1-85a921b7ee-10c0.zip/node_modules/concat-map/",\ @@ -914,6 +963,15 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["cookiejar", [\ + ["npm:2.1.4", {\ + "packageLocation": "../../../../.yarn/berry/cache/cookiejar-npm-2.1.4-e418c49b9e-10c0.zip/node_modules/cookiejar/",\ + "packageDependencies": [\ + ["cookiejar", "npm:2.1.4"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["cross-spawn", [\ ["npm:7.0.3", {\ "packageLocation": "../../../../.yarn/berry/cache/cross-spawn-npm-7.0.3-e4ff3e65b3-10c0.zip/node_modules/cross-spawn/",\ @@ -955,10 +1013,10 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ - ["virtual:4b12ba5111caf7e8338099bdbc7cb046a9f8e079a44e74d0c03dca469876e3071ebbe671c5e90ae6b78ae33e22c205fa5ed32169a4aabd1404b13c56d09986e1#npm:4.3.4", {\ - "packageLocation": "./.yarn/__virtual__/debug-virtual-ede24543b9/5/.yarn/berry/cache/debug-npm-4.3.4-4513954577-10c0.zip/node_modules/debug/",\ + ["virtual:44190e1fe988f8ed52651ed2ecff6428d5b112011682ca13abf2192dbac5d4ff82a2b10b21daf4cd9476daaebf3a3c670978e9dc2e2943ba8cf7ca5fca753eb3#npm:4.3.4", {\ + "packageLocation": "./.yarn/__virtual__/debug-virtual-d2db70d0af/5/.yarn/berry/cache/debug-npm-4.3.4-4513954577-10c0.zip/node_modules/debug/",\ "packageDependencies": [\ - ["debug", "virtual:4b12ba5111caf7e8338099bdbc7cb046a9f8e079a44e74d0c03dca469876e3071ebbe671c5e90ae6b78ae33e22c205fa5ed32169a4aabd1404b13c56d09986e1#npm:4.3.4"],\ + ["debug", "virtual:44190e1fe988f8ed52651ed2ecff6428d5b112011682ca13abf2192dbac5d4ff82a2b10b21daf4cd9476daaebf3a3c670978e9dc2e2943ba8cf7ca5fca753eb3#npm:4.3.4"],\ ["@types/supports-color", null],\ ["ms", "npm:2.1.2"],\ ["supports-color", null]\ @@ -1003,6 +1061,26 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["delayed-stream", [\ + ["npm:1.0.0", {\ + "packageLocation": "../../../../.yarn/berry/cache/delayed-stream-npm-1.0.0-c5a4c4cc02-10c0.zip/node_modules/delayed-stream/",\ + "packageDependencies": [\ + ["delayed-stream", "npm:1.0.0"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ + ["dezalgo", [\ + ["npm:1.0.4", {\ + "packageLocation": "../../../../.yarn/berry/cache/dezalgo-npm-1.0.4-ae3b673c98-10c0.zip/node_modules/dezalgo/",\ + "packageDependencies": [\ + ["dezalgo", "npm:1.0.4"],\ + ["asap", "npm:2.0.6"],\ + ["wrappy", "npm:1.0.2"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["dir-glob", [\ ["npm:3.0.1", {\ "packageLocation": "../../../../.yarn/berry/cache/dir-glob-npm-3.0.1-1aea628b1b-10c0.zip/node_modules/dir-glob/",\ @@ -1191,7 +1269,7 @@ const RAW_RUNTIME_STATE = ["ajv", "npm:6.12.6"],\ ["chalk", "npm:4.1.2"],\ ["cross-spawn", "npm:7.0.3"],\ - ["debug", "virtual:4b12ba5111caf7e8338099bdbc7cb046a9f8e079a44e74d0c03dca469876e3071ebbe671c5e90ae6b78ae33e22c205fa5ed32169a4aabd1404b13c56d09986e1#npm:4.3.4"],\ + ["debug", "virtual:44190e1fe988f8ed52651ed2ecff6428d5b112011682ca13abf2192dbac5d4ff82a2b10b21daf4cd9476daaebf3a3c670978e9dc2e2943ba8cf7ca5fca753eb3#npm:4.3.4"],\ ["doctrine", "npm:3.0.0"],\ ["escape-string-regexp", "npm:4.0.0"],\ ["eslint-scope", "npm:7.2.2"],\ @@ -1706,6 +1784,15 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["fast-safe-stringify", [\ + ["npm:2.1.1", {\ + "packageLocation": "../../../../.yarn/berry/cache/fast-safe-stringify-npm-2.1.1-7ce89033ca-10c0.zip/node_modules/fast-safe-stringify/",\ + "packageDependencies": [\ + ["fast-safe-stringify", "npm:2.1.1"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["fastq", [\ ["npm:1.16.0", {\ "packageLocation": "../../../../.yarn/berry/cache/fastq-npm-1.16.0-88070bb399-10c0.zip/node_modules/fastq/",\ @@ -1773,6 +1860,7 @@ const RAW_RUNTIME_STATE = "packageLocation": "./",\ "packageDependencies": [\ ["food-diary-tests", "workspace:."],\ + ["@anev/ts-mountebank", "npm:1.8.0"],\ ["@playwright/test", "npm:1.40.1"],\ ["@types/eslint", "npm:8.56.0"],\ ["@types/node", "npm:18.19.4"],\ @@ -1813,6 +1901,31 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["form-data", [\ + ["npm:4.0.0", {\ + "packageLocation": "../../../../.yarn/berry/cache/form-data-npm-4.0.0-916facec2d-10c0.zip/node_modules/form-data/",\ + "packageDependencies": [\ + ["form-data", "npm:4.0.0"],\ + ["asynckit", "npm:0.4.0"],\ + ["combined-stream", "npm:1.0.8"],\ + ["mime-types", "npm:2.1.35"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ + ["formidable", [\ + ["npm:2.1.2", {\ + "packageLocation": "../../../../.yarn/berry/cache/formidable-npm-2.1.2-40ba18d67f-10c0.zip/node_modules/formidable/",\ + "packageDependencies": [\ + ["formidable", "npm:2.1.2"],\ + ["dezalgo", "npm:1.0.4"],\ + ["hexoid", "npm:1.0.0"],\ + ["once", "npm:1.4.0"],\ + ["qs", "npm:6.11.2"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["fs-minipass", [\ ["npm:2.1.0", {\ "packageLocation": "../../../../.yarn/berry/cache/fs-minipass-npm-2.1.0-501ef87306-10c0.zip/node_modules/fs-minipass/",\ @@ -2089,6 +2202,15 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["hexoid", [\ + ["npm:1.0.0", {\ + "packageLocation": "../../../../.yarn/berry/cache/hexoid-npm-1.0.0-2274609209-10c0.zip/node_modules/hexoid/",\ + "packageDependencies": [\ + ["hexoid", "npm:1.0.0"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["http-cache-semantics", [\ ["npm:4.1.1", {\ "packageLocation": "../../../../.yarn/berry/cache/http-cache-semantics-npm-4.1.1-1120131375-10c0.zip/node_modules/http-cache-semantics/",\ @@ -2104,7 +2226,7 @@ const RAW_RUNTIME_STATE = "packageDependencies": [\ ["http-proxy-agent", "npm:7.0.0"],\ ["agent-base", "npm:7.1.0"],\ - ["debug", "virtual:4b12ba5111caf7e8338099bdbc7cb046a9f8e079a44e74d0c03dca469876e3071ebbe671c5e90ae6b78ae33e22c205fa5ed32169a4aabd1404b13c56d09986e1#npm:4.3.4"]\ + ["debug", "virtual:44190e1fe988f8ed52651ed2ecff6428d5b112011682ca13abf2192dbac5d4ff82a2b10b21daf4cd9476daaebf3a3c670978e9dc2e2943ba8cf7ca5fca753eb3#npm:4.3.4"]\ ],\ "linkType": "HARD"\ }]\ @@ -2115,7 +2237,7 @@ const RAW_RUNTIME_STATE = "packageDependencies": [\ ["https-proxy-agent", "npm:7.0.2"],\ ["agent-base", "npm:7.1.0"],\ - ["debug", "virtual:4b12ba5111caf7e8338099bdbc7cb046a9f8e079a44e74d0c03dca469876e3071ebbe671c5e90ae6b78ae33e22c205fa5ed32169a4aabd1404b13c56d09986e1#npm:4.3.4"]\ + ["debug", "virtual:44190e1fe988f8ed52651ed2ecff6428d5b112011682ca13abf2192dbac5d4ff82a2b10b21daf4cd9476daaebf3a3c670978e9dc2e2943ba8cf7ca5fca753eb3#npm:4.3.4"]\ ],\ "linkType": "HARD"\ }]\ @@ -2585,6 +2707,15 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["methods", [\ + ["npm:1.1.2", {\ + "packageLocation": "../../../../.yarn/berry/cache/methods-npm-1.1.2-92f6fdb39b-10c0.zip/node_modules/methods/",\ + "packageDependencies": [\ + ["methods", "npm:1.1.2"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["micromatch", [\ ["npm:4.0.5", {\ "packageLocation": "../../../../.yarn/berry/cache/micromatch-npm-4.0.5-cfab5d7669-10c0.zip/node_modules/micromatch/",\ @@ -2596,6 +2727,34 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["mime", [\ + ["npm:2.6.0", {\ + "packageLocation": "../../../../.yarn/berry/cache/mime-npm-2.6.0-88b89d8de0-10c0.zip/node_modules/mime/",\ + "packageDependencies": [\ + ["mime", "npm:2.6.0"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ + ["mime-db", [\ + ["npm:1.52.0", {\ + "packageLocation": "../../../../.yarn/berry/cache/mime-db-npm-1.52.0-b5371d6fd2-10c0.zip/node_modules/mime-db/",\ + "packageDependencies": [\ + ["mime-db", "npm:1.52.0"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ + ["mime-types", [\ + ["npm:2.1.35", {\ + "packageLocation": "../../../../.yarn/berry/cache/mime-types-npm-2.1.35-dd9ea9f3e2-10c0.zip/node_modules/mime-types/",\ + "packageDependencies": [\ + ["mime-types", "npm:2.1.35"],\ + ["mime-db", "npm:1.52.0"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["minimatch", [\ ["npm:3.1.2", {\ "packageLocation": "../../../../.yarn/berry/cache/minimatch-npm-3.1.2-9405269906-10c0.zip/node_modules/minimatch/",\ @@ -3058,6 +3217,16 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["qs", [\ + ["npm:6.11.2", {\ + "packageLocation": "../../../../.yarn/berry/cache/qs-npm-6.11.2-b118bc1c6f-10c0.zip/node_modules/qs/",\ + "packageDependencies": [\ + ["qs", "npm:6.11.2"],\ + ["side-channel", "npm:1.0.4"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["queue-microtask", [\ ["npm:1.2.3", {\ "packageLocation": "../../../../.yarn/berry/cache/queue-microtask-npm-1.2.3-fcc98e4e2d-10c0.zip/node_modules/queue-microtask/",\ @@ -3298,7 +3467,7 @@ const RAW_RUNTIME_STATE = "packageDependencies": [\ ["socks-proxy-agent", "npm:8.0.2"],\ ["agent-base", "npm:7.1.0"],\ - ["debug", "virtual:4b12ba5111caf7e8338099bdbc7cb046a9f8e079a44e74d0c03dca469876e3071ebbe671c5e90ae6b78ae33e22c205fa5ed32169a4aabd1404b13c56d09986e1#npm:4.3.4"],\ + ["debug", "virtual:44190e1fe988f8ed52651ed2ecff6428d5b112011682ca13abf2192dbac5d4ff82a2b10b21daf4cd9476daaebf3a3c670978e9dc2e2943ba8cf7ca5fca753eb3#npm:4.3.4"],\ ["socks", "npm:2.7.1"]\ ],\ "linkType": "HARD"\ @@ -3408,6 +3577,25 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["superagent", [\ + ["npm:8.1.2", {\ + "packageLocation": "../../../../.yarn/berry/cache/superagent-npm-8.1.2-44190e1fe9-10c0.zip/node_modules/superagent/",\ + "packageDependencies": [\ + ["superagent", "npm:8.1.2"],\ + ["component-emitter", "npm:1.3.1"],\ + ["cookiejar", "npm:2.1.4"],\ + ["debug", "virtual:44190e1fe988f8ed52651ed2ecff6428d5b112011682ca13abf2192dbac5d4ff82a2b10b21daf4cd9476daaebf3a3c670978e9dc2e2943ba8cf7ca5fca753eb3#npm:4.3.4"],\ + ["fast-safe-stringify", "npm:2.1.1"],\ + ["form-data", "npm:4.0.0"],\ + ["formidable", "npm:2.1.2"],\ + ["methods", "npm:1.1.2"],\ + ["mime", "npm:2.6.0"],\ + ["qs", "npm:6.11.2"],\ + ["semver", "npm:7.5.4"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["supports-color", [\ ["npm:7.2.0", {\ "packageLocation": "../../../../.yarn/berry/cache/supports-color-npm-7.2.0-606bfcf7da-10c0.zip/node_modules/supports-color/",\ diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml index 230d13ab2..e729a6fd9 100644 --- a/tests/docker-compose.yml +++ b/tests/docker-compose.yml @@ -13,6 +13,11 @@ services: test: ["CMD-SHELL", "pg_isready -p 8090 -U postgres"] interval: 10s retries: 5 + mountebank: + image: bbyars/mountebank:2.9.1 + ports: + - "2125:2525" + - "2126:2126" web: depends_on: db: @@ -31,6 +36,7 @@ services: - Google__ExportFolderId=test_folder_id - GoogleAuth__ClientId=test_client_id - GoogleAuth__ClientSecret=test_client_secret + - GoogleAuth__AuthorizationEndpoint=http://localhost:2126/authorize volumes: - ../certs:/https:ro entrypoint: > diff --git a/tests/fakeAuth.ts b/tests/fakeAuth.ts new file mode 100644 index 000000000..d6efd5fd9 --- /dev/null +++ b/tests/fakeAuth.ts @@ -0,0 +1,43 @@ +import { + Mountebank, + Imposter, + HttpMethod, + Stub, + EqualPredicate, + Response, +} from '@anev/ts-mountebank'; + +const PORT = 2126; + +const HTML = ` + + + + + + Document + + + Hello world! + + +`; + +export class FakeAuthProvider { + private readonly _mountebank = new Mountebank().withURL('http://localhost:2125'); + private readonly _imposter = new Imposter().withPort(PORT); + + public async setup(): Promise { + const authorizeStub = new Stub() + .withPredicate(new EqualPredicate().withMethod(HttpMethod.GET).withPath('/authorize')) + .withResponse( + new Response().withStatusCode(200).withHeader('Content-Type', 'text/html').withBody(HTML), + ); + + await this._mountebank.createImposter(this._imposter.withStub(authorizeStub)); + } + + public async teardown(): Promise { + await this._mountebank.deleteImposter(PORT); + } +} diff --git a/tests/package.json b/tests/package.json index a0971d4bf..57abcf778 100644 --- a/tests/package.json +++ b/tests/package.json @@ -15,6 +15,7 @@ "lint:fix": "eslint . --fix" }, "devDependencies": { + "@anev/ts-mountebank": "^1.8.0", "@playwright/test": "^1.40.1", "@types/eslint": "^8", "@types/node": "^18.16.0", diff --git a/tests/scenarios/main.spec.ts b/tests/scenarios/main.spec.ts index 6d2dea2ef..22f73cd72 100644 --- a/tests/scenarios/main.spec.ts +++ b/tests/scenarios/main.spec.ts @@ -1,7 +1,21 @@ import { test, expect } from '@playwright/test'; +import { FakeAuthProvider } from '../fakeAuth'; + +let fakeAuth: FakeAuthProvider | null = null; + +test.beforeEach(async () => { + fakeAuth = new FakeAuthProvider(); + await fakeAuth.setup(); +}); + +test.afterEach(async () => { + await fakeAuth?.teardown(); +}); test('should display sign in page', async ({ page }) => { - await page.goto('https://localhost:10000'); + await page.goto('https://localhost:8080'); + + await page.getByRole('button', { name: /sign in with google/i }).click(); - await expect(page.getByRole('button', { name: /sign in with google/i })).toBeVisible(); + await expect(page.getByText(/hello world/i)).toBeVisible(); }); diff --git a/tests/yarn.lock b/tests/yarn.lock index d576e9d1c..e4f79cda0 100644 --- a/tests/yarn.lock +++ b/tests/yarn.lock @@ -12,6 +12,16 @@ __metadata: languageName: node linkType: hard +"@anev/ts-mountebank@npm:^1.8.0": + version: 1.8.0 + resolution: "@anev/ts-mountebank@npm:1.8.0" + dependencies: + superagent: "npm:^8.1.2" + typescript: "npm:^5.2.2" + checksum: 3eee3bd6efc532d01a354f6b6e95a4ea92ef0f1bb63b21c4f00cc21d2c0de806056347301c2ef10750e8c01101582a6310fc04020ef1e8cee85ef36f24957b2d + languageName: node + linkType: hard + "@eslint-community/eslint-utils@npm:^4.1.2, @eslint-community/eslint-utils@npm:^4.2.0, @eslint-community/eslint-utils@npm:^4.4.0": version: 4.4.0 resolution: "@eslint-community/eslint-utils@npm:4.4.0" @@ -519,6 +529,20 @@ __metadata: languageName: node linkType: hard +"asap@npm:^2.0.0": + version: 2.0.6 + resolution: "asap@npm:2.0.6" + checksum: c6d5e39fe1f15e4b87677460bd66b66050cd14c772269cee6688824c1410a08ab20254bb6784f9afb75af9144a9f9a7692d49547f4d19d715aeb7c0318f3136d + languageName: node + linkType: hard + +"asynckit@npm:^0.4.0": + version: 0.4.0 + resolution: "asynckit@npm:0.4.0" + checksum: d73e2ddf20c4eb9337e1b3df1a0f6159481050a5de457c55b14ea2e5cb6d90bb69e004c9af54737a5ee0917fcf2c9e25de67777bbe58261847846066ba75bc9d + languageName: node + linkType: hard + "available-typed-arrays@npm:^1.0.5": version: 1.0.5 resolution: "available-typed-arrays@npm:1.0.5" @@ -655,6 +679,22 @@ __metadata: languageName: node linkType: hard +"combined-stream@npm:^1.0.8": + version: 1.0.8 + resolution: "combined-stream@npm:1.0.8" + dependencies: + delayed-stream: "npm:~1.0.0" + checksum: 0dbb829577e1b1e839fa82b40c07ffaf7de8a09b935cadd355a73652ae70a88b4320db322f6634a4ad93424292fa80973ac6480986247f1734a1137debf271d5 + languageName: node + linkType: hard + +"component-emitter@npm:^1.3.0": + version: 1.3.1 + resolution: "component-emitter@npm:1.3.1" + checksum: e4900b1b790b5e76b8d71b328da41482118c0f3523a516a41be598dc2785a07fd721098d9bf6e22d89b19f4fa4e1025160dc00317ea111633a3e4f75c2b86032 + languageName: node + linkType: hard + "concat-map@npm:0.0.1": version: 0.0.1 resolution: "concat-map@npm:0.0.1" @@ -662,6 +702,13 @@ __metadata: languageName: node linkType: hard +"cookiejar@npm:^2.1.4": + version: 2.1.4 + resolution: "cookiejar@npm:2.1.4" + checksum: 2dae55611c6e1678f34d93984cbd4bda58f4fe3e5247cc4993f4a305cd19c913bbaf325086ed952e892108115073a747596453d3dc1c34947f47f731818b8ad1 + languageName: node + linkType: hard + "cross-spawn@npm:^7.0.0, cross-spawn@npm:^7.0.2": version: 7.0.3 resolution: "cross-spawn@npm:7.0.3" @@ -723,6 +770,23 @@ __metadata: languageName: node linkType: hard +"delayed-stream@npm:~1.0.0": + version: 1.0.0 + resolution: "delayed-stream@npm:1.0.0" + checksum: d758899da03392e6712f042bec80aa293bbe9e9ff1b2634baae6a360113e708b91326594c8a486d475c69d6259afb7efacdc3537bfcda1c6c648e390ce601b19 + languageName: node + linkType: hard + +"dezalgo@npm:^1.0.4": + version: 1.0.4 + resolution: "dezalgo@npm:1.0.4" + dependencies: + asap: "npm:^2.0.0" + wrappy: "npm:1" + checksum: 8a870ed42eade9a397e6141fe5c025148a59ed52f1f28b1db5de216b4d57f0af7a257070c3af7ce3d5508c1ce9dd5009028a76f4b2cc9370dc56551d2355fad8 + languageName: node + linkType: hard + "dir-glob@npm:^3.0.1": version: 3.0.1 resolution: "dir-glob@npm:3.0.1" @@ -1212,6 +1276,13 @@ __metadata: languageName: node linkType: hard +"fast-safe-stringify@npm:^2.1.1": + version: 2.1.1 + resolution: "fast-safe-stringify@npm:2.1.1" + checksum: d90ec1c963394919828872f21edaa3ad6f1dddd288d2bd4e977027afff09f5db40f94e39536d4646f7e01761d704d72d51dce5af1b93717f3489ef808f5f4e4d + languageName: node + linkType: hard + "fastq@npm:^1.6.0": version: 1.16.0 resolution: "fastq@npm:1.16.0" @@ -1271,6 +1342,7 @@ __metadata: version: 0.0.0-use.local resolution: "food-diary-tests@workspace:." dependencies: + "@anev/ts-mountebank": "npm:^1.8.0" "@playwright/test": "npm:^1.40.1" "@types/eslint": "npm:^8" "@types/node": "npm:^18.16.0" @@ -1308,6 +1380,29 @@ __metadata: languageName: node linkType: hard +"form-data@npm:^4.0.0": + version: 4.0.0 + resolution: "form-data@npm:4.0.0" + dependencies: + asynckit: "npm:^0.4.0" + combined-stream: "npm:^1.0.8" + mime-types: "npm:^2.1.12" + checksum: cb6f3ac49180be03ff07ba3ff125f9eba2ff0b277fb33c7fc47569fc5e616882c5b1c69b9904c4c4187e97dd0419dd03b134174756f296dec62041e6527e2c6e + languageName: node + linkType: hard + +"formidable@npm:^2.1.2": + version: 2.1.2 + resolution: "formidable@npm:2.1.2" + dependencies: + dezalgo: "npm:^1.0.4" + hexoid: "npm:^1.0.0" + once: "npm:^1.4.0" + qs: "npm:^6.11.0" + checksum: efba03d11127098daa6ef54c3c0fad25693973eb902fa88ccaaa203baebe8c74d12ba0fe1e113eccf79b9172510fa337e4e107330b124fb3a8c74697b4aa2ce3 + languageName: node + linkType: hard + "fs-minipass@npm:^2.0.0": version: 2.1.0 resolution: "fs-minipass@npm:2.1.0" @@ -1566,6 +1661,13 @@ __metadata: languageName: node linkType: hard +"hexoid@npm:^1.0.0": + version: 1.0.0 + resolution: "hexoid@npm:1.0.0" + checksum: 9c45e8ba676b9eb88455631ebceec4c829a8374a583410dc735472ab9808bf11339fcd074633c3fa30e420901b894d8a92ffd5e2e21eddd41149546e05a91f69 + languageName: node + linkType: hard + "http-cache-semantics@npm:^4.1.1": version: 4.1.1 resolution: "http-cache-semantics@npm:4.1.1" @@ -2001,6 +2103,13 @@ __metadata: languageName: node linkType: hard +"methods@npm:^1.1.2": + version: 1.1.2 + resolution: "methods@npm:1.1.2" + checksum: bdf7cc72ff0a33e3eede03708c08983c4d7a173f91348b4b1e4f47d4cdbf734433ad971e7d1e8c77247d9e5cd8adb81ea4c67b0a2db526b758b2233d7814b8b2 + languageName: node + linkType: hard + "micromatch@npm:^4.0.4": version: 4.0.5 resolution: "micromatch@npm:4.0.5" @@ -2011,6 +2120,31 @@ __metadata: languageName: node linkType: hard +"mime-db@npm:1.52.0": + version: 1.52.0 + resolution: "mime-db@npm:1.52.0" + checksum: 0557a01deebf45ac5f5777fe7740b2a5c309c6d62d40ceab4e23da9f821899ce7a900b7ac8157d4548ddbb7beffe9abc621250e6d182b0397ec7f10c7b91a5aa + languageName: node + linkType: hard + +"mime-types@npm:^2.1.12": + version: 2.1.35 + resolution: "mime-types@npm:2.1.35" + dependencies: + mime-db: "npm:1.52.0" + checksum: 82fb07ec56d8ff1fc999a84f2f217aa46cb6ed1033fefaabd5785b9a974ed225c90dc72fff460259e66b95b73648596dbcc50d51ed69cdf464af2d237d3149b2 + languageName: node + linkType: hard + +"mime@npm:2.6.0": + version: 2.6.0 + resolution: "mime@npm:2.6.0" + bin: + mime: cli.js + checksum: a7f2589900d9c16e3bdf7672d16a6274df903da958c1643c9c45771f0478f3846dcb1097f31eb9178452570271361e2149310931ec705c037210fc69639c8e6c + languageName: node + linkType: hard + "minimatch@npm:9.0.3, minimatch@npm:^9.0.1": version: 9.0.3 resolution: "minimatch@npm:9.0.3" @@ -2248,7 +2382,7 @@ __metadata: languageName: node linkType: hard -"once@npm:^1.3.0": +"once@npm:^1.3.0, once@npm:^1.4.0": version: 1.4.0 resolution: "once@npm:1.4.0" dependencies: @@ -2432,6 +2566,15 @@ __metadata: languageName: node linkType: hard +"qs@npm:^6.11.0": + version: 6.11.2 + resolution: "qs@npm:6.11.2" + dependencies: + side-channel: "npm:^1.0.4" + checksum: 4f95d4ff18ed480befcafa3390022817ffd3087fc65f146cceb40fc5edb9fa96cb31f648cae2fa96ca23818f0798bd63ad4ca369a0e22702fcd41379b3ab6571 + languageName: node + linkType: hard + "queue-microtask@npm:^1.2.2": version: 1.2.3 resolution: "queue-microtask@npm:1.2.3" @@ -2563,7 +2706,7 @@ __metadata: languageName: node linkType: hard -"semver@npm:^7.0.0, semver@npm:^7.3.5, semver@npm:^7.5.3, semver@npm:^7.5.4": +"semver@npm:^7.0.0, semver@npm:^7.3.5, semver@npm:^7.3.8, semver@npm:^7.5.3, semver@npm:^7.5.4": version: 7.5.4 resolution: "semver@npm:7.5.4" dependencies: @@ -2762,6 +2905,24 @@ __metadata: languageName: node linkType: hard +"superagent@npm:^8.1.2": + version: 8.1.2 + resolution: "superagent@npm:8.1.2" + dependencies: + component-emitter: "npm:^1.3.0" + cookiejar: "npm:^2.1.4" + debug: "npm:^4.3.4" + fast-safe-stringify: "npm:^2.1.1" + form-data: "npm:^4.0.0" + formidable: "npm:^2.1.2" + methods: "npm:^1.1.2" + mime: "npm:2.6.0" + qs: "npm:^6.11.0" + semver: "npm:^7.3.8" + checksum: 016416fc9c3d3a04fb648bc0efb3d3d5c9d96da00de47e4a625d9976d28c6c37ab0a7f185f2c3ec6d653ee8bb522f70fba0c1072aea7774341a6c0269a9fa77f + languageName: node + linkType: hard + "supports-color@npm:^7.1.0": version: 7.2.0 resolution: "supports-color@npm:7.2.0" @@ -2909,7 +3070,7 @@ __metadata: languageName: node linkType: hard -"typescript@npm:^5.3.3": +"typescript@npm:^5.2.2, typescript@npm:^5.3.3": version: 5.3.3 resolution: "typescript@npm:5.3.3" bin: @@ -2919,7 +3080,7 @@ __metadata: languageName: node linkType: hard -"typescript@patch:typescript@npm%3A^5.3.3#optional!builtin": +"typescript@patch:typescript@npm%3A^5.2.2#optional!builtin, typescript@patch:typescript@npm%3A^5.3.3#optional!builtin": version: 5.3.3 resolution: "typescript@patch:typescript@npm%3A5.3.3#optional!builtin::version=5.3.3&hash=e012d7" bin: