Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add shouldTryLinkingWithSessionUser flag to auth apis and make overwriteSessionDuringSignInUp deafult to true #909

Merged
merged 17 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
33 changes: 33 additions & 0 deletions .circleci/config_continue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ jobs:
- run: update-alternatives --install "/usr/bin/javac" "javac" "/usr/java/jdk-15.0.1/bin/javac" 2
- run: (cd .circleci/ && ./doUnitTests.sh << parameters.cdi-version >>)
- slack/status
test-backend-sdk-testing:
docker:
- image: rishabhpoddar/supertokens_node_driver_testing_node_20
resource_class: large
parameters:
cdi-version:
type: string
fdi-version:
type: string
steps:
- checkout
- run: echo "127.0.0.1 localhost.org" >> /etc/hosts
- run: apt-get install lsof
- run: npm i -d --force
- run: update-alternatives --install "/usr/bin/java" "java" "/usr/java/jdk-15.0.1/bin/java" 2
- run: update-alternatives --install "/usr/bin/javac" "javac" "/usr/java/jdk-15.0.1/bin/javac" 2
- run: (cd .circleci/ && ./doBackendSDKTests.sh << parameters.cdi-version >> << parameters.fdi-version >>)
- slack/status
test-website:
docker:
- image: rishabhpoddar/supertokens_website_sdk_testing
Expand Down Expand Up @@ -114,6 +132,20 @@ workflows:
matrix:
parameters:
cdi-version: placeholder
- test-backend-sdk-testing:
requires:
- test-dev-tag-as-not-passed
context:
- slack-notification
filters:
tags:
only: /dev-v[0-9]+(\.[0-9]+)*/
branches:
only: /test-cicd\/.*/
matrix:
parameters:
cdi-version: placeholder
fdi-version: placeholder
- test-website:
requires:
- test-dev-tag-as-not-passed
Expand Down Expand Up @@ -143,6 +175,7 @@ workflows:
- test-success:
requires:
- test-unit
- test-backend-sdk-testing
- test-website
- test-authreact
context:
Expand Down
38 changes: 38 additions & 0 deletions .circleci/doBackendSDKTests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
echo "Starting tests for CDI $1";

if [ -z "$SUPERTOKENS_API_KEY" ]; then
echo "SUPERTOKENS_API_KEY not set"
exit 1
fi

coreDriverVersion=$1
coreDriverVersion=`echo $coreDriverVersion | tr -d '"'`

frontendDriverVersion=$2

coreFree=`curl -s -X GET \
"https://api.supertokens.io/0/core-driver-interface/dependency/core/latest?password=$SUPERTOKENS_API_KEY&planType=FREE&mode=DEV&version=$coreDriverVersion&driverName=node" \
-H 'api-version: 1'`
if [[ `echo $coreFree | jq .core` == "null" ]]
then
echo "fetching latest X.Y version for core given core-driver-interface X.Y version: $coreDriverVersion, planType: FREE gave response: $coreFree. Please make sure all relevant cores have been pushed."
exit 1
fi
coreFree=$(echo $coreFree | jq .core | tr -d '"')

cd ..
./test/testExports.sh
if [[ $? -ne 0 ]]
then
echo "export test failed... exiting!"
exit 1
fi
cd .circleci

./setupAndTestBackendSDKWithFreeCore.sh $coreFree $coreDriverVersion $frontendDriverVersion
if [[ $? -ne 0 ]]
then
echo "test failed... exiting!"
exit 1
fi
rm -rf ../../supertokens-root
81 changes: 81 additions & 0 deletions .circleci/setupAndTestBackendSDKWithFreeCore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
coreInfo=`curl -s -X GET \
"https://api.supertokens.io/0/core/latest?password=$SUPERTOKENS_API_KEY&planType=FREE&mode=DEV&version=$1" \
-H 'api-version: 0'`
if [[ `echo $coreInfo | jq .tag` == "null" ]]
then
echo "fetching latest X.Y.Z version for core, X.Y version: $1, planType: FREE gave response: $coreInfo"
exit 1
fi
coreTag=$(echo $coreInfo | jq .tag | tr -d '"')
coreVersion=$(echo $coreInfo | jq .version | tr -d '"')

pluginInterfaceVersionXY=`curl -s -X GET \
"https://api.supertokens.io/0/core/dependency/plugin-interface/latest?password=$SUPERTOKENS_API_KEY&planType=FREE&mode=DEV&version=$1" \
-H 'api-version: 0'`
if [[ `echo $pluginInterfaceVersionXY | jq .pluginInterface` == "null" ]]
then
echo "fetching latest X.Y version for plugin-interface, given core X.Y version: $1, planType: FREE gave response: $pluginInterfaceVersionXY"
exit 1
fi
pluginInterfaceVersionXY=$(echo $pluginInterfaceVersionXY | jq .pluginInterface | tr -d '"')

pluginInterfaceInfo=`curl -s -X GET \
"https://api.supertokens.io/0/plugin-interface/latest?password=$SUPERTOKENS_API_KEY&planType=FREE&mode=DEV&version=$pluginInterfaceVersionXY" \
-H 'api-version: 0'`
if [[ `echo $pluginInterfaceInfo | jq .tag` == "null" ]]
then
echo "fetching latest X.Y.Z version for plugin-interface, X.Y version: $pluginInterfaceVersionXY, planType: FREE gave response: $pluginInterfaceInfo"
exit 1
fi
pluginInterfaceTag=$(echo $pluginInterfaceInfo | jq .tag | tr -d '"')
pluginInterfaceVersion=$(echo $pluginInterfaceInfo | jq .version | tr -d '"')

echo "Testing with FREE core: $coreVersion, plugin-interface: $pluginInterfaceVersion"

cd ../../
git clone git@github.com:supertokens/supertokens-root.git
cd supertokens-root
if [[ $2 == "2.0" ]] || [[ $2 == "2.1" ]] || [[ $2 == "2.2" ]]
then
git checkout 36e5af1b9a4e3b07247d0cf333cf82a071a78681
fi
echo -e "core,$1\nplugin-interface,$pluginInterfaceVersionXY" > modules.txt
./loadModules --ssh
cd supertokens-core
git checkout $coreTag
cd ../supertokens-plugin-interface
git checkout $pluginInterfaceTag
cd ../
echo $SUPERTOKENS_API_KEY > apiPassword
./utils/setupTestEnvLocal
cd ../project/

# Set the script to exit on error
set -e

API_PORT=3030
ST_CONNECTION_URI=http://localhost:8081

# start test-server
pushd test/test-server
npm install
API_PORT=$API_PORT ST_CONNECTION_URI=$ST_CONNECTION_URI npm start &
popd

frontendDriverVersion=$3
# run tests
cd ../
git clone git@github.com:supertokens/backend-sdk-testing.git
cd backend-sdk-testing
git checkout $frontendDriverVersion
npm install
npm run build

if ! [[ -z "${CIRCLE_NODE_TOTAL}" ]]; then
API_PORT=$API_PORT TEST_MODE=testing SUPERTOKENS_CORE_TAG=$coreTag NODE_PORT=8081 INSTALL_PATH=../supertokens-root npx mocha --node-option no-experimental-fetch -r test/fetch-polyfill.mjs --no-config --timeout 500000 $(npx mocha-split-tests -r ./runtime.log -t $CIRCLE_NODE_TOTAL -g $CIRCLE_NODE_INDEX -f 'test/**/*.test.js')
else
API_PORT=$API_PORT TEST_MODE=testing SUPERTOKENS_CORE_TAG=$coreTag NODE_PORT=8081 INSTALL_PATH=../supertokens-root npm test
fi

# kill test-server
kill $(lsof -t -i:$API_PORT)
33 changes: 0 additions & 33 deletions .circleci/setupAndTestWithFreeCore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,36 +58,3 @@ if ! [[ -z "${CIRCLE_NODE_TOTAL}" ]]; then
else
TEST_MODE=testing SUPERTOKENS_CORE_TAG=$coreTag NODE_PORT=8081 INSTALL_PATH=../supertokens-root npm test
fi

API_PORT=3030
ST_CONNECTION_URI=http://localhost:8081

# start test-server
pushd test/test-server
npm install
API_PORT=$API_PORT ST_CONNECTION_URI=$ST_CONNECTION_URI npm start &
popd

# lets read frontendDriverInterfaceSupported
frontendDriverJson=`cat ./frontendDriverInterfaceSupported.json`
# get versions
frontendDriverArray=`echo $frontendDriverJson | jq ".versions"`
# use latest version
frontendDriverVersion=`echo $frontendDriverArray | jq ".[-1]" | tr -d '"'`

# run tests
cd ../
git clone git@github.com:supertokens/backend-sdk-testing.git
cd backend-sdk-testing
git checkout $frontendDriverVersion
npm install
npm run build

if ! [[ -z "${CIRCLE_NODE_TOTAL}" ]]; then
API_PORT=$API_PORT TEST_MODE=testing SUPERTOKENS_CORE_TAG=$coreTag NODE_PORT=8081 INSTALL_PATH=../supertokens-root npx mocha --node-option no-experimental-fetch -r test/fetch-polyfill.mjs --no-config --timeout 500000 $(npx mocha-split-tests -r ./runtime.log -t $CIRCLE_NODE_TOTAL -g $CIRCLE_NODE_INDEX -f 'test/**/*.test.js')
else
API_PORT=$API_PORT TEST_MODE=testing SUPERTOKENS_CORE_TAG=$coreTag NODE_PORT=8081 INSTALL_PATH=../supertokens-root npm test
fi

# kill test-server
kill $(lsof -t -i:$API_PORT)
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Added OAuth2Provider recipe

## [20.0.2] - 2024-08-08

- Fixes an issue where `shouldDoAutomaticAccountLinking` was called without a primary user when linking in some cases.

## [20.0.1] - 2024-08-05

- Fixes an issue with `removeFromPayloadByMerge_internal` for `MultiFactorAuthClaim` where it was not retaining other claims while removing the claim from the payload.
- Updates testing with backend-sdk-testing repo to run against all supported FDI versions.

## [20.0.0] - 2024-07-24

### Changes
Expand Down
2 changes: 1 addition & 1 deletion docs/classes/framework.BaseRequest.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/framework.BaseResponse.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/framework_custom.CollectingResponse.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/framework_custom.PreParsedRequest.html

Large diffs are not rendered by default.

Loading
Loading