summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/npm_tests.rs2
-rw-r--r--tests/registry/npm-private/@denotest/basic/1.0.0/main.d.mts (renamed from tests/registry/npm-private/@denotest2/basic/1.0.0/main.d.mts)0
-rw-r--r--tests/registry/npm-private/@denotest/basic/1.0.0/main.mjs (renamed from tests/registry/npm-private/@denotest2/basic/1.0.0/main.mjs)0
-rw-r--r--tests/registry/npm-private/@denotest/basic/1.0.0/other.mjs (renamed from tests/registry/npm-private/@denotest2/basic/1.0.0/other.mjs)0
-rw-r--r--tests/registry/npm-private/@denotest/basic/1.0.0/package.json7
-rw-r--r--tests/registry/npm-private2/@denotest2/basic/1.0.0/main.d.mts3
-rw-r--r--tests/registry/npm-private2/@denotest2/basic/1.0.0/main.mjs11
-rw-r--r--tests/registry/npm-private2/@denotest2/basic/1.0.0/other.mjs3
-rw-r--r--tests/registry/npm-private2/@denotest2/basic/1.0.0/package.json (renamed from tests/registry/npm-private/@denotest2/basic/1.0.0/package.json)0
-rw-r--r--tests/specs/compile/npmrc/.npmrc4
-rw-r--r--tests/specs/compile/npmrc/__test__.jsonc28
-rw-r--r--tests/specs/compile/npmrc/install.out9
-rw-r--r--tests/specs/compile/npmrc/main.js8
-rw-r--r--tests/specs/compile/npmrc/main.out3
-rw-r--r--tests/specs/compile/npmrc/package.json8
-rw-r--r--tests/specs/npm/npmrc/.npmrc4
-rw-r--r--tests/specs/npm/npmrc/__test__.jsonc13
-rw-r--r--tests/specs/npm/npmrc/install.out9
-rw-r--r--tests/specs/npm/npmrc/main.js8
-rw-r--r--tests/specs/npm/npmrc/main.out3
-rw-r--r--tests/specs/npm/npmrc/package.json8
-rw-r--r--tests/specs/npm/npmrc_bad_token/.npmrc2
-rw-r--r--tests/specs/npm/npmrc_bad_token/__test__.jsonc9
-rw-r--r--tests/specs/npm/npmrc_bad_token/main.js5
-rw-r--r--tests/specs/npm/npmrc_bad_token/main.out4
-rw-r--r--tests/specs/npm/npmrc_bad_token/package.json7
-rw-r--r--tests/specs/npm/npmrc_basic_auth/.npmrc4
-rw-r--r--tests/specs/npm/npmrc_basic_auth/__test__.jsonc13
-rw-r--r--tests/specs/npm/npmrc_basic_auth/install.out9
-rw-r--r--tests/specs/npm/npmrc_basic_auth/main.js8
-rw-r--r--tests/specs/npm/npmrc_basic_auth/main.out3
-rw-r--r--tests/specs/npm/npmrc_basic_auth/package.json8
-rw-r--r--tests/specs/npm/npmrc_deno_json/.npmrc2
-rw-r--r--tests/specs/npm/npmrc_deno_json/__test__.jsonc8
-rw-r--r--tests/specs/npm/npmrc_deno_json/deno.json3
-rw-r--r--tests/specs/npm/npmrc_deno_json/main.js5
-rw-r--r--tests/specs/npm/npmrc_deno_json/main.out4
-rw-r--r--tests/specs/npm/npmrc_not_next_to_package_json/.npmrc2
-rw-r--r--tests/specs/npm/npmrc_not_next_to_package_json/__test__.jsonc9
-rw-r--r--tests/specs/npm/npmrc_not_next_to_package_json/main.out6
-rw-r--r--tests/specs/npm/npmrc_not_next_to_package_json/subdir/main.js5
-rw-r--r--tests/specs/npm/npmrc_not_next_to_package_json/subdir/package.json7
-rw-r--r--tests/util/server/src/lib.rs2
-rw-r--r--tests/util/server/src/npm.rs13
-rw-r--r--tests/util/server/src/servers/mod.rs4
-rw-r--r--tests/util/server/src/servers/npm_registry.rs40
46 files changed, 309 insertions, 4 deletions
diff --git a/tests/integration/npm_tests.rs b/tests/integration/npm_tests.rs
index ab00c7b56..63547cfce 100644
--- a/tests/integration/npm_tests.rs
+++ b/tests/integration/npm_tests.rs
@@ -3088,7 +3088,7 @@ async fn test_private_npm_registry() {
let client = reqwest::Client::new();
- let url = Url::parse("http://127.0.0.1:4261/@denotest2/basic").unwrap();
+ let url = Url::parse("http://127.0.0.1:4261/@denotest/basic").unwrap();
let req = reqwest::Request::new(reqwest::Method::GET, url.clone());
let resp = client.execute(req).await.unwrap();
diff --git a/tests/registry/npm-private/@denotest2/basic/1.0.0/main.d.mts b/tests/registry/npm-private/@denotest/basic/1.0.0/main.d.mts
index 29da1e6d7..29da1e6d7 100644
--- a/tests/registry/npm-private/@denotest2/basic/1.0.0/main.d.mts
+++ b/tests/registry/npm-private/@denotest/basic/1.0.0/main.d.mts
diff --git a/tests/registry/npm-private/@denotest2/basic/1.0.0/main.mjs b/tests/registry/npm-private/@denotest/basic/1.0.0/main.mjs
index 0a44f7585..0a44f7585 100644
--- a/tests/registry/npm-private/@denotest2/basic/1.0.0/main.mjs
+++ b/tests/registry/npm-private/@denotest/basic/1.0.0/main.mjs
diff --git a/tests/registry/npm-private/@denotest2/basic/1.0.0/other.mjs b/tests/registry/npm-private/@denotest/basic/1.0.0/other.mjs
index 00ed99da4..00ed99da4 100644
--- a/tests/registry/npm-private/@denotest2/basic/1.0.0/other.mjs
+++ b/tests/registry/npm-private/@denotest/basic/1.0.0/other.mjs
diff --git a/tests/registry/npm-private/@denotest/basic/1.0.0/package.json b/tests/registry/npm-private/@denotest/basic/1.0.0/package.json
new file mode 100644
index 000000000..8f7324aa5
--- /dev/null
+++ b/tests/registry/npm-private/@denotest/basic/1.0.0/package.json
@@ -0,0 +1,7 @@
+{
+ "name": "@denotest/basic",
+ "version": "1.0.0",
+ "type": "module",
+ "main": "main.mjs",
+ "types": "main.d.mts"
+}
diff --git a/tests/registry/npm-private2/@denotest2/basic/1.0.0/main.d.mts b/tests/registry/npm-private2/@denotest2/basic/1.0.0/main.d.mts
new file mode 100644
index 000000000..29da1e6d7
--- /dev/null
+++ b/tests/registry/npm-private2/@denotest2/basic/1.0.0/main.d.mts
@@ -0,0 +1,3 @@
+export declare function setValue(val: number): void;
+export declare function getValue(): number;
+export declare const url: string;
diff --git a/tests/registry/npm-private2/@denotest2/basic/1.0.0/main.mjs b/tests/registry/npm-private2/@denotest2/basic/1.0.0/main.mjs
new file mode 100644
index 000000000..0a44f7585
--- /dev/null
+++ b/tests/registry/npm-private2/@denotest2/basic/1.0.0/main.mjs
@@ -0,0 +1,11 @@
+let value = 0;
+
+export function setValue(newValue) {
+ value = newValue;
+}
+
+export function getValue() {
+ return value;
+}
+
+export const url = import.meta.url;
diff --git a/tests/registry/npm-private2/@denotest2/basic/1.0.0/other.mjs b/tests/registry/npm-private2/@denotest2/basic/1.0.0/other.mjs
new file mode 100644
index 000000000..00ed99da4
--- /dev/null
+++ b/tests/registry/npm-private2/@denotest2/basic/1.0.0/other.mjs
@@ -0,0 +1,3 @@
+export function hello() {
+ return "hello, world!";
+} \ No newline at end of file
diff --git a/tests/registry/npm-private/@denotest2/basic/1.0.0/package.json b/tests/registry/npm-private2/@denotest2/basic/1.0.0/package.json
index d7129c348..d7129c348 100644
--- a/tests/registry/npm-private/@denotest2/basic/1.0.0/package.json
+++ b/tests/registry/npm-private2/@denotest2/basic/1.0.0/package.json
diff --git a/tests/specs/compile/npmrc/.npmrc b/tests/specs/compile/npmrc/.npmrc
new file mode 100644
index 000000000..0624091f0
--- /dev/null
+++ b/tests/specs/compile/npmrc/.npmrc
@@ -0,0 +1,4 @@
+@denotest:registry=http://127.0.0.1:4261/
+//127.0.0.1:4261/denotest/:_authToken=private-reg-token
+@denotest2:registry=http://127.0.0.1:4262/
+//127.0.0.1:4262/denotest2/:_authToken=private-reg-token2
diff --git a/tests/specs/compile/npmrc/__test__.jsonc b/tests/specs/compile/npmrc/__test__.jsonc
new file mode 100644
index 000000000..470e5299c
--- /dev/null
+++ b/tests/specs/compile/npmrc/__test__.jsonc
@@ -0,0 +1,28 @@
+{
+ "envs": {
+ "DENO_FUTURE": "1"
+ },
+ "tempDir": true,
+ "steps": [{
+ "args": "install",
+ "output": "install.out"
+ }, {
+ "if": "unix",
+ "args": "compile --output main main.js",
+ "output": "[WILDCARD]"
+ }, {
+ "if": "unix",
+ "commandName": "./main",
+ "args": [],
+ "output": "main.out"
+ }, {
+ "if": "windows",
+ "args": "compile --output main.exe main.js",
+ "output": "[WILDCARD]"
+ }, {
+ "if": "windows",
+ "commandName": "./main.exe",
+ "args": [],
+ "output": "main.out"
+ }]
+}
diff --git a/tests/specs/compile/npmrc/install.out b/tests/specs/compile/npmrc/install.out
new file mode 100644
index 000000000..7484405db
--- /dev/null
+++ b/tests/specs/compile/npmrc/install.out
@@ -0,0 +1,9 @@
+⚠️ `deno install` behavior will change in Deno 2. To preserve the current behavior use the `-g` or `--global` flag.
+[UNORDERED_START]
+Download http://127.0.0.1:4261/@denotest/basic
+Download http://127.0.0.1:4262/@denotest2/basic
+Download http://localhost:4261/@denotest/basic/1.0.0.tgz
+Download http://localhost:4262/@denotest2/basic/1.0.0.tgz
+Initialize @denotest2/basic@1.0.0
+Initialize @denotest/basic@1.0.0
+[UNORDERED_END]
diff --git a/tests/specs/compile/npmrc/main.js b/tests/specs/compile/npmrc/main.js
new file mode 100644
index 000000000..66b393636
--- /dev/null
+++ b/tests/specs/compile/npmrc/main.js
@@ -0,0 +1,8 @@
+import { getValue, setValue } from "@denotest/basic";
+import * as test from "@denotest2/basic";
+
+console.log(getValue());
+setValue(42);
+console.log(getValue());
+
+console.log(test.getValue());
diff --git a/tests/specs/compile/npmrc/main.out b/tests/specs/compile/npmrc/main.out
new file mode 100644
index 000000000..bbe210bdb
--- /dev/null
+++ b/tests/specs/compile/npmrc/main.out
@@ -0,0 +1,3 @@
+0
+42
+0
diff --git a/tests/specs/compile/npmrc/package.json b/tests/specs/compile/npmrc/package.json
new file mode 100644
index 000000000..274d1ed7f
--- /dev/null
+++ b/tests/specs/compile/npmrc/package.json
@@ -0,0 +1,8 @@
+{
+ "name": "npmrc_test",
+ "version": "0.0.1",
+ "dependencies": {
+ "@denotest/basic": "1.0.0",
+ "@denotest2/basic": "1.0.0"
+ }
+}
diff --git a/tests/specs/npm/npmrc/.npmrc b/tests/specs/npm/npmrc/.npmrc
new file mode 100644
index 000000000..085885ec8
--- /dev/null
+++ b/tests/specs/npm/npmrc/.npmrc
@@ -0,0 +1,4 @@
+@denotest:registry=http://127.0.0.1:4261/
+//127.0.0.1:4261/denotest/:_auth=ZGVubzpsYW5k
+@denotest2:registry=http://127.0.0.1:4262/
+//127.0.0.1:4262/denotest2/:_auth=ZGVubzpsYW5kMg==
diff --git a/tests/specs/npm/npmrc/__test__.jsonc b/tests/specs/npm/npmrc/__test__.jsonc
new file mode 100644
index 000000000..44298ed2f
--- /dev/null
+++ b/tests/specs/npm/npmrc/__test__.jsonc
@@ -0,0 +1,13 @@
+{
+ "envs": {
+ "DENO_FUTURE": "1"
+ },
+ "tempDir": true,
+ "steps": [{
+ "args": "install",
+ "output": "install.out"
+ }, {
+ "args": "run -A main.js",
+ "output": "main.out"
+ }]
+}
diff --git a/tests/specs/npm/npmrc/install.out b/tests/specs/npm/npmrc/install.out
new file mode 100644
index 000000000..7484405db
--- /dev/null
+++ b/tests/specs/npm/npmrc/install.out
@@ -0,0 +1,9 @@
+⚠️ `deno install` behavior will change in Deno 2. To preserve the current behavior use the `-g` or `--global` flag.
+[UNORDERED_START]
+Download http://127.0.0.1:4261/@denotest/basic
+Download http://127.0.0.1:4262/@denotest2/basic
+Download http://localhost:4261/@denotest/basic/1.0.0.tgz
+Download http://localhost:4262/@denotest2/basic/1.0.0.tgz
+Initialize @denotest2/basic@1.0.0
+Initialize @denotest/basic@1.0.0
+[UNORDERED_END]
diff --git a/tests/specs/npm/npmrc/main.js b/tests/specs/npm/npmrc/main.js
new file mode 100644
index 000000000..66b393636
--- /dev/null
+++ b/tests/specs/npm/npmrc/main.js
@@ -0,0 +1,8 @@
+import { getValue, setValue } from "@denotest/basic";
+import * as test from "@denotest2/basic";
+
+console.log(getValue());
+setValue(42);
+console.log(getValue());
+
+console.log(test.getValue());
diff --git a/tests/specs/npm/npmrc/main.out b/tests/specs/npm/npmrc/main.out
new file mode 100644
index 000000000..bbe210bdb
--- /dev/null
+++ b/tests/specs/npm/npmrc/main.out
@@ -0,0 +1,3 @@
+0
+42
+0
diff --git a/tests/specs/npm/npmrc/package.json b/tests/specs/npm/npmrc/package.json
new file mode 100644
index 000000000..274d1ed7f
--- /dev/null
+++ b/tests/specs/npm/npmrc/package.json
@@ -0,0 +1,8 @@
+{
+ "name": "npmrc_test",
+ "version": "0.0.1",
+ "dependencies": {
+ "@denotest/basic": "1.0.0",
+ "@denotest2/basic": "1.0.0"
+ }
+}
diff --git a/tests/specs/npm/npmrc_bad_token/.npmrc b/tests/specs/npm/npmrc_bad_token/.npmrc
new file mode 100644
index 000000000..c4b03fd7a
--- /dev/null
+++ b/tests/specs/npm/npmrc_bad_token/.npmrc
@@ -0,0 +1,2 @@
+@denotest:registry=http://127.0.0.1:4261/
+//127.0.0.1:4261/denotest/:_authToken=invalid-token
diff --git a/tests/specs/npm/npmrc_bad_token/__test__.jsonc b/tests/specs/npm/npmrc_bad_token/__test__.jsonc
new file mode 100644
index 000000000..fe99247b1
--- /dev/null
+++ b/tests/specs/npm/npmrc_bad_token/__test__.jsonc
@@ -0,0 +1,9 @@
+{
+ "envs": {
+ "DENO_FUTURE": "1"
+ },
+ "tempDir": true,
+ "args": "install",
+ "output": "main.out",
+ "exitCode": 1
+}
diff --git a/tests/specs/npm/npmrc_bad_token/main.js b/tests/specs/npm/npmrc_bad_token/main.js
new file mode 100644
index 000000000..e8ccf7611
--- /dev/null
+++ b/tests/specs/npm/npmrc_bad_token/main.js
@@ -0,0 +1,5 @@
+import { getValue, setValue } from "@denotest/basic";
+
+console.log(getValue());
+setValue(42);
+console.log(getValue());
diff --git a/tests/specs/npm/npmrc_bad_token/main.out b/tests/specs/npm/npmrc_bad_token/main.out
new file mode 100644
index 000000000..ceee1fed4
--- /dev/null
+++ b/tests/specs/npm/npmrc_bad_token/main.out
@@ -0,0 +1,4 @@
+⚠️ `deno install` behavior will change in Deno 2. To preserve the current behavior use the `-g` or `--global` flag.
+Download http://127.0.0.1:4261/@denotest/basic
+error: Error getting response at http://127.0.0.1:4261/@denotest/basic for package "@denotest/basic": Bad response: 401
+[WILDCARD] \ No newline at end of file
diff --git a/tests/specs/npm/npmrc_bad_token/package.json b/tests/specs/npm/npmrc_bad_token/package.json
new file mode 100644
index 000000000..b5ca7df42
--- /dev/null
+++ b/tests/specs/npm/npmrc_bad_token/package.json
@@ -0,0 +1,7 @@
+{
+ "name": "npmrc_test",
+ "version": "0.0.1",
+ "dependencies": {
+ "@denotest/basic": "1.0.0"
+ }
+}
diff --git a/tests/specs/npm/npmrc_basic_auth/.npmrc b/tests/specs/npm/npmrc_basic_auth/.npmrc
new file mode 100644
index 000000000..0624091f0
--- /dev/null
+++ b/tests/specs/npm/npmrc_basic_auth/.npmrc
@@ -0,0 +1,4 @@
+@denotest:registry=http://127.0.0.1:4261/
+//127.0.0.1:4261/denotest/:_authToken=private-reg-token
+@denotest2:registry=http://127.0.0.1:4262/
+//127.0.0.1:4262/denotest2/:_authToken=private-reg-token2
diff --git a/tests/specs/npm/npmrc_basic_auth/__test__.jsonc b/tests/specs/npm/npmrc_basic_auth/__test__.jsonc
new file mode 100644
index 000000000..44298ed2f
--- /dev/null
+++ b/tests/specs/npm/npmrc_basic_auth/__test__.jsonc
@@ -0,0 +1,13 @@
+{
+ "envs": {
+ "DENO_FUTURE": "1"
+ },
+ "tempDir": true,
+ "steps": [{
+ "args": "install",
+ "output": "install.out"
+ }, {
+ "args": "run -A main.js",
+ "output": "main.out"
+ }]
+}
diff --git a/tests/specs/npm/npmrc_basic_auth/install.out b/tests/specs/npm/npmrc_basic_auth/install.out
new file mode 100644
index 000000000..7484405db
--- /dev/null
+++ b/tests/specs/npm/npmrc_basic_auth/install.out
@@ -0,0 +1,9 @@
+⚠️ `deno install` behavior will change in Deno 2. To preserve the current behavior use the `-g` or `--global` flag.
+[UNORDERED_START]
+Download http://127.0.0.1:4261/@denotest/basic
+Download http://127.0.0.1:4262/@denotest2/basic
+Download http://localhost:4261/@denotest/basic/1.0.0.tgz
+Download http://localhost:4262/@denotest2/basic/1.0.0.tgz
+Initialize @denotest2/basic@1.0.0
+Initialize @denotest/basic@1.0.0
+[UNORDERED_END]
diff --git a/tests/specs/npm/npmrc_basic_auth/main.js b/tests/specs/npm/npmrc_basic_auth/main.js
new file mode 100644
index 000000000..66b393636
--- /dev/null
+++ b/tests/specs/npm/npmrc_basic_auth/main.js
@@ -0,0 +1,8 @@
+import { getValue, setValue } from "@denotest/basic";
+import * as test from "@denotest2/basic";
+
+console.log(getValue());
+setValue(42);
+console.log(getValue());
+
+console.log(test.getValue());
diff --git a/tests/specs/npm/npmrc_basic_auth/main.out b/tests/specs/npm/npmrc_basic_auth/main.out
new file mode 100644
index 000000000..bbe210bdb
--- /dev/null
+++ b/tests/specs/npm/npmrc_basic_auth/main.out
@@ -0,0 +1,3 @@
+0
+42
+0
diff --git a/tests/specs/npm/npmrc_basic_auth/package.json b/tests/specs/npm/npmrc_basic_auth/package.json
new file mode 100644
index 000000000..274d1ed7f
--- /dev/null
+++ b/tests/specs/npm/npmrc_basic_auth/package.json
@@ -0,0 +1,8 @@
+{
+ "name": "npmrc_test",
+ "version": "0.0.1",
+ "dependencies": {
+ "@denotest/basic": "1.0.0",
+ "@denotest2/basic": "1.0.0"
+ }
+}
diff --git a/tests/specs/npm/npmrc_deno_json/.npmrc b/tests/specs/npm/npmrc_deno_json/.npmrc
new file mode 100644
index 000000000..18887e8d3
--- /dev/null
+++ b/tests/specs/npm/npmrc_deno_json/.npmrc
@@ -0,0 +1,2 @@
+@denotest:registry=http://127.0.0.1:4261/
+//127.0.0.1:4261/denotest/:_authToken=private-reg-token
diff --git a/tests/specs/npm/npmrc_deno_json/__test__.jsonc b/tests/specs/npm/npmrc_deno_json/__test__.jsonc
new file mode 100644
index 000000000..5d07b7034
--- /dev/null
+++ b/tests/specs/npm/npmrc_deno_json/__test__.jsonc
@@ -0,0 +1,8 @@
+{
+ "envs": {
+ "DENO_FUTURE": "1"
+ },
+ "tempDir": true,
+ "args": "run -A main.js",
+ "output": "main.out"
+}
diff --git a/tests/specs/npm/npmrc_deno_json/deno.json b/tests/specs/npm/npmrc_deno_json/deno.json
new file mode 100644
index 000000000..f6ca8454c
--- /dev/null
+++ b/tests/specs/npm/npmrc_deno_json/deno.json
@@ -0,0 +1,3 @@
+{
+ "imports": {}
+}
diff --git a/tests/specs/npm/npmrc_deno_json/main.js b/tests/specs/npm/npmrc_deno_json/main.js
new file mode 100644
index 000000000..9246715d1
--- /dev/null
+++ b/tests/specs/npm/npmrc_deno_json/main.js
@@ -0,0 +1,5 @@
+import { getValue, setValue } from "npm:@denotest/basic";
+
+console.log(getValue());
+setValue(42);
+console.log(getValue());
diff --git a/tests/specs/npm/npmrc_deno_json/main.out b/tests/specs/npm/npmrc_deno_json/main.out
new file mode 100644
index 000000000..6a1e47669
--- /dev/null
+++ b/tests/specs/npm/npmrc_deno_json/main.out
@@ -0,0 +1,4 @@
+Download http://127.0.0.1:4261/@denotest/basic
+Download http://localhost:4261/@denotest/basic/1.0.0.tgz
+0
+42
diff --git a/tests/specs/npm/npmrc_not_next_to_package_json/.npmrc b/tests/specs/npm/npmrc_not_next_to_package_json/.npmrc
new file mode 100644
index 000000000..18887e8d3
--- /dev/null
+++ b/tests/specs/npm/npmrc_not_next_to_package_json/.npmrc
@@ -0,0 +1,2 @@
+@denotest:registry=http://127.0.0.1:4261/
+//127.0.0.1:4261/denotest/:_authToken=private-reg-token
diff --git a/tests/specs/npm/npmrc_not_next_to_package_json/__test__.jsonc b/tests/specs/npm/npmrc_not_next_to_package_json/__test__.jsonc
new file mode 100644
index 000000000..fa545c290
--- /dev/null
+++ b/tests/specs/npm/npmrc_not_next_to_package_json/__test__.jsonc
@@ -0,0 +1,9 @@
+{
+ "envs": {
+ "DENO_FUTURE": "1"
+ },
+ "tempDir": true,
+ "args": "install -A -L debug",
+ "output": "main.out",
+ "cwd": "subdir"
+}
diff --git a/tests/specs/npm/npmrc_not_next_to_package_json/main.out b/tests/specs/npm/npmrc_not_next_to_package_json/main.out
new file mode 100644
index 000000000..8f42fb6d8
--- /dev/null
+++ b/tests/specs/npm/npmrc_not_next_to_package_json/main.out
@@ -0,0 +1,6 @@
+[# This test is still downloading code, because we have a private registry]
+[# that serves the same packages. The important bit is the message below.]
+[WILDCARD] No .npmrc file found
+[WILDCARD]
+Download http://localhost:4260/@denotest/esm-basic/1.0.0.tgz
+Initialize @denotest/esm-basic@1.0.0
diff --git a/tests/specs/npm/npmrc_not_next_to_package_json/subdir/main.js b/tests/specs/npm/npmrc_not_next_to_package_json/subdir/main.js
new file mode 100644
index 000000000..81dd521da
--- /dev/null
+++ b/tests/specs/npm/npmrc_not_next_to_package_json/subdir/main.js
@@ -0,0 +1,5 @@
+import { getValue, setValue } from "@denotest/esm-basic";
+
+console.log(getValue());
+setValue(42);
+console.log(getValue());
diff --git a/tests/specs/npm/npmrc_not_next_to_package_json/subdir/package.json b/tests/specs/npm/npmrc_not_next_to_package_json/subdir/package.json
new file mode 100644
index 000000000..99feed9d8
--- /dev/null
+++ b/tests/specs/npm/npmrc_not_next_to_package_json/subdir/package.json
@@ -0,0 +1,7 @@
+{
+ "name": "npmrc_test",
+ "version": "0.0.1",
+ "dependencies": {
+ "@denotest/esm-basic": "1.0.0"
+ }
+}
diff --git a/tests/util/server/src/lib.rs b/tests/util/server/src/lib.rs
index ee5348049..a7f4fb447 100644
--- a/tests/util/server/src/lib.rs
+++ b/tests/util/server/src/lib.rs
@@ -307,7 +307,7 @@ async fn get_tcp_listener_stream(
futures::stream::select_all(listeners)
}
-pub const TEST_SERVERS_COUNT: usize = 28;
+pub const TEST_SERVERS_COUNT: usize = 30;
#[derive(Default)]
struct HttpServerCount {
diff --git a/tests/util/server/src/npm.rs b/tests/util/server/src/npm.rs
index 7cb6a04f2..363a45d7e 100644
--- a/tests/util/server/src/npm.rs
+++ b/tests/util/server/src/npm.rs
@@ -30,7 +30,6 @@ pub static PUBLIC_TEST_NPM_REGISTRY: Lazy<TestNpmRegistry> = Lazy::new(|| {
)
});
-// TODO: rewrite to use config
pub static PRIVATE_TEST_NPM_REGISTRY_1: Lazy<TestNpmRegistry> =
Lazy::new(|| {
TestNpmRegistry::new(
@@ -43,6 +42,18 @@ pub static PRIVATE_TEST_NPM_REGISTRY_1: Lazy<TestNpmRegistry> =
)
});
+pub static PRIVATE_TEST_NPM_REGISTRY_2: Lazy<TestNpmRegistry> =
+ Lazy::new(|| {
+ TestNpmRegistry::new(
+ NpmRegistryKind::Private,
+ &format!(
+ "http://localhost:{}",
+ crate::servers::PRIVATE_NPM_REGISTRY_2_PORT
+ ),
+ "npm-private2",
+ )
+ });
+
pub enum NpmRegistryKind {
Public,
Private,
diff --git a/tests/util/server/src/servers/mod.rs b/tests/util/server/src/servers/mod.rs
index 4c86eb451..1b6e2f71d 100644
--- a/tests/util/server/src/servers/mod.rs
+++ b/tests/util/server/src/servers/mod.rs
@@ -90,6 +90,7 @@ const JSR_REGISTRY_SERVER_PORT: u16 = 4250;
const PROVENANCE_MOCK_SERVER_PORT: u16 = 4251;
pub(crate) const PUBLIC_NPM_REGISTRY_PORT: u16 = 4260;
pub(crate) const PRIVATE_NPM_REGISTRY_1_PORT: u16 = 4261;
+pub(crate) const PRIVATE_NPM_REGISTRY_2_PORT: u16 = 4262;
// Use the single-threaded scheduler. The hyper server is used as a point of
// comparison for the (single-threaded!) benchmarks in cli/bench. We're not
@@ -140,6 +141,8 @@ pub async fn run_all_servers() {
npm_registry::public_npm_registry(PUBLIC_NPM_REGISTRY_PORT);
let private_npm_registry_1_server_futs =
npm_registry::private_npm_registry1(PRIVATE_NPM_REGISTRY_1_PORT);
+ let private_npm_registry_2_server_futs =
+ npm_registry::private_npm_registry2(PRIVATE_NPM_REGISTRY_2_PORT);
let mut futures = vec![
redirect_server_fut.boxed_local(),
@@ -169,6 +172,7 @@ pub async fn run_all_servers() {
];
futures.extend(npm_registry_server_futs);
futures.extend(private_npm_registry_1_server_futs);
+ futures.extend(private_npm_registry_2_server_futs);
assert_eq!(futures.len(), TEST_SERVERS_COUNT);
diff --git a/tests/util/server/src/servers/npm_registry.rs b/tests/util/server/src/servers/npm_registry.rs
index eadfafe02..7e5547b5b 100644
--- a/tests/util/server/src/servers/npm_registry.rs
+++ b/tests/util/server/src/servers/npm_registry.rs
@@ -33,6 +33,12 @@ pub fn public_npm_registry(port: u16) -> Vec<LocalBoxFuture<'static, ()>> {
}
const PRIVATE_NPM_REGISTRY_AUTH_TOKEN: &str = "private-reg-token";
+const PRIVATE_NPM_REGISTRY_2_AUTH_TOKEN: &str = "private-reg-token2";
+
+// `deno:land` encoded using base64
+const PRIVATE_NPM_REGISTRY_AUTH_BASE64: &str = "ZGVubzpsYW5k";
+// `deno:land2` encoded using base64
+const PRIVATE_NPM_REGISTRY_2_AUTH_BASE64: &str = "ZGVubzpsYW5kMg==";
pub fn private_npm_registry1(port: u16) -> Vec<LocalBoxFuture<'static, ()>> {
run_npm_server(
@@ -42,6 +48,14 @@ pub fn private_npm_registry1(port: u16) -> Vec<LocalBoxFuture<'static, ()>> {
)
}
+pub fn private_npm_registry2(port: u16) -> Vec<LocalBoxFuture<'static, ()>> {
+ run_npm_server(
+ port,
+ "npm private registry server error",
+ private_npm_registry2_handler,
+ )
+}
+
fn run_npm_server<F, S>(
port: u16,
error_msg: &'static str,
@@ -91,7 +105,9 @@ async fn private_npm_registry1_handler(
.get("authorization")
.and_then(|x| x.to_str().ok())
.unwrap_or_default();
- if auth != format!("Bearer {}", PRIVATE_NPM_REGISTRY_AUTH_TOKEN) {
+ if auth != format!("Bearer {}", PRIVATE_NPM_REGISTRY_AUTH_TOKEN)
+ && auth != format!("Basic {}", PRIVATE_NPM_REGISTRY_AUTH_BASE64)
+ {
return Ok(
Response::builder()
.status(StatusCode::UNAUTHORIZED)
@@ -103,6 +119,28 @@ async fn private_npm_registry1_handler(
handle_req_for_registry(req, &npm::PRIVATE_TEST_NPM_REGISTRY_1).await
}
+async fn private_npm_registry2_handler(
+ req: Request<hyper::body::Incoming>,
+) -> Result<Response<UnsyncBoxBody<Bytes, Infallible>>, anyhow::Error> {
+ let auth = req
+ .headers()
+ .get("authorization")
+ .and_then(|x| x.to_str().ok())
+ .unwrap_or_default();
+ if auth != format!("Bearer {}", PRIVATE_NPM_REGISTRY_2_AUTH_TOKEN)
+ && auth != format!("Basic {}", PRIVATE_NPM_REGISTRY_2_AUTH_BASE64)
+ {
+ return Ok(
+ Response::builder()
+ .status(StatusCode::UNAUTHORIZED)
+ .body(empty_body())
+ .unwrap(),
+ );
+ }
+
+ handle_req_for_registry(req, &npm::PRIVATE_TEST_NPM_REGISTRY_2).await
+}
+
async fn handle_req_for_registry(
req: Request<Incoming>,
test_npm_registry: &npm::TestNpmRegistry,