From 7a9284ad8c5b121fcf9fccac8c06b0bfb1054dca Mon Sep 17 00:00:00 2001 From: Sattvik Chakravarthy Date: Thu, 19 Oct 2023 17:10:36 +0530 Subject: [PATCH 1/2] test: null values in thirdparty config --- test/multitenancy/tenants-crud.test.js | 68 ++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/test/multitenancy/tenants-crud.test.js b/test/multitenancy/tenants-crud.test.js index 676477c84..4cdbe3ae7 100644 --- a/test/multitenancy/tenants-crud.test.js +++ b/test/multitenancy/tenants-crud.test.js @@ -211,6 +211,74 @@ describe(`tenants-crud: ${printPath("[test/multitenancy/tenants-crud.test.js]")} assert(tenantConfig.thirdParty.providers[0].clients[0].clientId === "abcd"); }); + it("test creation of thirdParty config with nulls", async function () { + const connectionURI = await startSTWithMultitenancy(); + SuperTokens.init({ + supertokens: { + connectionURI, + }, + appInfo: { + apiDomain: "api.supertokens.io", + appName: "SuperTokens", + websiteDomain: "supertokens.io", + }, + recipeList: [Multitenancy.init()], + }); + + const app = express(); + + app.use(middleware()); + app.use(errorHandler()); + + await Multitenancy.createOrUpdateTenant("t1", { emailPasswordEnabled: true }); + + const thirdPartyConfig = { + thirdPartyId: "google", + clients: [{ clientId: "abcd" }], + authorizationEndpointQueryParams: { + key1: null, + key2: "value", + }, + tokenEndpointBodyParams: { + key1: null, + key2: "value", + }, + userInfoEndpointQueryParams: { + key1: null, + key2: "value", + }, + userInfoEndpointHeaders: { + key1: null, + key2: "value", + }, + }; + + await Multitenancy.createOrUpdateThirdPartyConfig("t1", thirdPartyConfig); + + const tenantConfig = await Multitenancy.getTenant("t1"); + + assert(tenantConfig.thirdParty.providers.length === 1); + assert(tenantConfig.thirdParty.providers[0].thirdPartyId === "google"); + assert(tenantConfig.thirdParty.providers[0].clients.length === 1); + assert(tenantConfig.thirdParty.providers[0].clients[0].clientId === "abcd"); + assert.deepEqual( + tenantConfig.thirdParty.providers[0].authorizationEndpointQueryParams, + thirdPartyConfig.authorizationEndpointQueryParams + ); + assert.deepEqual( + tenantConfig.thirdParty.providers[0].tokenEndpointBodyParams, + thirdPartyConfig.tokenEndpointBodyParams + ); + assert.deepEqual( + tenantConfig.thirdParty.providers[0].userInfoEndpointQueryParams, + thirdPartyConfig.userInfoEndpointQueryParams + ); + assert.deepEqual( + tenantConfig.thirdParty.providers[0].userInfoEndpointHeaders, + thirdPartyConfig.userInfoEndpointHeaders + ); + }); + it("test deletion of thirdparty id", async function () { const connectionURI = await startSTWithMultitenancy(); SuperTokens.init({ From 20f03a5927c468e1ca7390a9f4354b31cd4cf2ec Mon Sep 17 00:00:00 2001 From: Sattvik Chakravarthy Date: Thu, 19 Oct 2023 17:14:19 +0530 Subject: [PATCH 2/2] fix: version update --- CHANGELOG.md | 4 ++++ CONTRIBUTING.md | 18 ++++++++++++++++++ lib/build/version.d.ts | 2 +- lib/build/version.js | 2 +- lib/ts/version.ts | 2 +- package-lock.json | 2 +- package.json | 2 +- 7 files changed, 27 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2aed35ad3..91c39627e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) +## [16.3.1] - 2023-10-19 + +- Tests `null` values in `ProviderConfig` saved in core + ## [16.3.0] - 2023-10-10 ### Added diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 20abbf353..549837928 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -52,6 +52,24 @@ You will need to setup the `supertokens-core` in order to to run the `supertoken 5. If all tests pass the output should be: ![node tests passing](https://github.com/supertokens/supertokens-logo/blob/master/images/supertokens-node-tests-passing.png) +### To be able to run and debug tests from vscode + +1. Install the extension - https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-mocha-test-adapter +2. Add the following to your vscode settings: + ```json + { + // ..., + "mochaExplorer.env": { + "TEST_MODE": "testing", + "INSTALL_PATH": "../supertokens-root" + } + } + ``` +3. In `lib/tsconfig.json`, change `"sourceMap"` to `true` +4. Run `npm run build` + +You should now be able to see tests on the VSCode's testing panel and run/debug from there. + ## Pull Request 1. Before submitting a pull request make sure all tests have passed diff --git a/lib/build/version.d.ts b/lib/build/version.d.ts index d722c34e2..0526ec868 100644 --- a/lib/build/version.d.ts +++ b/lib/build/version.d.ts @@ -1,4 +1,4 @@ // @ts-nocheck -export declare const version = "16.3.0"; +export declare const version = "16.3.1"; export declare const cdiSupported: string[]; export declare const dashboardVersion = "0.8"; diff --git a/lib/build/version.js b/lib/build/version.js index a5835bf84..4e4eeb4aa 100644 --- a/lib/build/version.js +++ b/lib/build/version.js @@ -15,7 +15,7 @@ exports.dashboardVersion = exports.cdiSupported = exports.version = void 0; * License for the specific language governing permissions and limitations * under the License. */ -exports.version = "16.3.0"; +exports.version = "16.3.1"; exports.cdiSupported = ["4.0"]; // Note: The actual script import for dashboard uses v{DASHBOARD_VERSION} exports.dashboardVersion = "0.8"; diff --git a/lib/ts/version.ts b/lib/ts/version.ts index 68d0fa2b3..9f01964aa 100644 --- a/lib/ts/version.ts +++ b/lib/ts/version.ts @@ -12,7 +12,7 @@ * License for the specific language governing permissions and limitations * under the License. */ -export const version = "16.3.0"; +export const version = "16.3.1"; export const cdiSupported = ["4.0"]; diff --git a/package-lock.json b/package-lock.json index 1ab79c477..dbc13d373 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "supertokens-node", - "version": "16.3.0", + "version": "16.3.1", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index 19e156ef5..19f3dafbf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "supertokens-node", - "version": "16.3.0", + "version": "16.3.1", "description": "NodeJS driver for SuperTokens core", "main": "index.js", "scripts": {