Skip to content

Commit

Permalink
fixes tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabhpoddar committed May 9, 2024
1 parent e61c3d0 commit 2d00795
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 28 deletions.
56 changes: 28 additions & 28 deletions TestingApp/test/config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import AuthHttpRequest from "supertokens-react-native";
import assert from "assert";
import { ProcessState } from "supertokens-react-native/lib/build/processState";
import {
normaliseCookieDomainOrThrowError,
normaliseSessionScopeOrThrowError,
normaliseURLPathOrThrowError,
normaliseURLDomainOrThrowError
} from "supertokens-react-native/lib/build/utils";
Expand Down Expand Up @@ -170,35 +170,35 @@ describe("Config tests", function() {
});

it("testing cookieDomain normalisation", async function() {
assert(normaliseCookieDomainOrThrowError("api.example.com") === "api.example.com");
assert(normaliseCookieDomainOrThrowError("http://api.example.com") === "api.example.com");
assert(normaliseCookieDomainOrThrowError("https://api.example.com") === "api.example.com");
assert(normaliseCookieDomainOrThrowError("http://api.example.com?hello=1") === "api.example.com");
assert(normaliseCookieDomainOrThrowError("http://api.example.com/hello") === "api.example.com");
assert(normaliseCookieDomainOrThrowError("http://api.example.com/") === "api.example.com");
assert(normaliseCookieDomainOrThrowError("http://api.example.com:8080") === "api.example.com");
assert(normaliseCookieDomainOrThrowError("http://api.example.com#random2") === "api.example.com");
assert(normaliseCookieDomainOrThrowError("api.example.com/") === "api.example.com");
assert(normaliseCookieDomainOrThrowError("api.example.com#random") === "api.example.com");
assert(normaliseCookieDomainOrThrowError("example.com") === "example.com");
assert(normaliseCookieDomainOrThrowError("api.example.com/?hello=1&bye=2") === "api.example.com");
assert(normaliseCookieDomainOrThrowError("localhost") === "localhost");
assert(normaliseCookieDomainOrThrowError("localhost:8080") === "localhost");
assert(normaliseCookieDomainOrThrowError("localhost.org") === "localhost.org");
assert(normaliseCookieDomainOrThrowError("127.0.0.1") === "127.0.0.1");

assert(normaliseCookieDomainOrThrowError(".api.example.com") === ".api.example.com");
assert(normaliseCookieDomainOrThrowError(".api.example.com/") === ".api.example.com");
assert(normaliseCookieDomainOrThrowError(".api.example.com#random") === ".api.example.com");
assert(normaliseCookieDomainOrThrowError(".example.com") === ".example.com");
assert(normaliseCookieDomainOrThrowError(".api.example.com/?hello=1&bye=2") === ".api.example.com");
assert(normaliseCookieDomainOrThrowError(".localhost") === "localhost");
assert(normaliseCookieDomainOrThrowError(".localhost:8080") === "localhost");
assert(normaliseCookieDomainOrThrowError(".localhost.org") === ".localhost.org");
assert(normaliseCookieDomainOrThrowError(".127.0.0.1") === "127.0.0.1");
assert(normaliseSessionScopeOrThrowError("api.example.com") === "api.example.com");
assert(normaliseSessionScopeOrThrowError("http://api.example.com") === "api.example.com");
assert(normaliseSessionScopeOrThrowError("https://api.example.com") === "api.example.com");
assert(normaliseSessionScopeOrThrowError("http://api.example.com?hello=1") === "api.example.com");
assert(normaliseSessionScopeOrThrowError("http://api.example.com/hello") === "api.example.com");
assert(normaliseSessionScopeOrThrowError("http://api.example.com/") === "api.example.com");
assert(normaliseSessionScopeOrThrowError("http://api.example.com:8080") === "api.example.com");
assert(normaliseSessionScopeOrThrowError("http://api.example.com#random2") === "api.example.com");
assert(normaliseSessionScopeOrThrowError("api.example.com/") === "api.example.com");
assert(normaliseSessionScopeOrThrowError("api.example.com#random") === "api.example.com");
assert(normaliseSessionScopeOrThrowError("example.com") === "example.com");
assert(normaliseSessionScopeOrThrowError("api.example.com/?hello=1&bye=2") === "api.example.com");
assert(normaliseSessionScopeOrThrowError("localhost") === "localhost");
assert(normaliseSessionScopeOrThrowError("localhost:8080") === "localhost");
assert(normaliseSessionScopeOrThrowError("localhost.org") === "localhost.org");
assert(normaliseSessionScopeOrThrowError("127.0.0.1") === "127.0.0.1");

assert(normaliseSessionScopeOrThrowError(".api.example.com") === ".api.example.com");
assert(normaliseSessionScopeOrThrowError(".api.example.com/") === ".api.example.com");
assert(normaliseSessionScopeOrThrowError(".api.example.com#random") === ".api.example.com");
assert(normaliseSessionScopeOrThrowError(".example.com") === ".example.com");
assert(normaliseSessionScopeOrThrowError(".api.example.com/?hello=1&bye=2") === ".api.example.com");
assert(normaliseSessionScopeOrThrowError(".localhost") === "localhost");
assert(normaliseSessionScopeOrThrowError(".localhost:8080") === "localhost");
assert(normaliseSessionScopeOrThrowError(".localhost.org") === ".localhost.org");
assert(normaliseSessionScopeOrThrowError(".127.0.0.1") === "127.0.0.1");

try {
normaliseCookieDomainOrThrowError("http://");
normaliseSessionScopeOrThrowError("http://");
assert(false);
} catch (err) {
assert(err.message === "Please provide a valid cookieDomain");
Expand Down
11 changes: 11 additions & 0 deletions android/.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,15 @@
<natures>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
<filteredResources>
<filter>
<id>1715234366601</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>

0 comments on commit 2d00795

Please sign in to comment.