@@ -39,17 +39,18 @@ test_expect_success "browser is able to access API if Origin is the API port on
39
39
grep "HTTP/1.1 200 OK" curl_output && grep "$PEERID" curl_output
40
40
'
41
41
42
- test_expect_success " Companion extension is unable to access API with invalid Origin" '
42
+ test_expect_success " Random browser extension is unable to access RPC API due to invalid Origin" '
43
43
curl -sD - -X POST -A "Mozilla" -H "Origin: chrome-extension://invalidextensionid" "http://127.0.0.1:$API_PORT/api/v0/id" >curl_output &&
44
44
grep "HTTP/1.1 403 Forbidden" curl_output
45
45
'
46
46
47
- test_expect_success " Companion extension is able to access API if Origin is the API port on localhost (ipv4) " '
47
+ test_expect_success " Companion extension is able to access RPC API on localhost" '
48
48
curl -sD - -X POST -A "Mozilla" -H "Origin: chrome-extension://nibjojkomfdiaoajekhjakgkdhaomnch" "http://127.0.0.1:$API_PORT/api/v0/id" >curl_output &&
49
+ cat curl_output &&
49
50
grep "HTTP/1.1 200 OK" curl_output && grep "$PEERID" curl_output
50
51
'
51
52
52
- test_expect_success " Companion beta extension is able to access API if Origin is the API port on localhost (ipv4) " '
53
+ test_expect_success " Companion beta extension is able to access API on localhost" '
53
54
curl -sD - -X POST -A "Mozilla" -H "Origin: chrome-extension://hjoieblefckbooibpepigmacodalfndh" "http://127.0.0.1:$API_PORT/api/v0/id" >curl_output &&
54
55
grep "HTTP/1.1 200 OK" curl_output && grep "$PEERID" curl_output
55
56
'
@@ -64,6 +65,13 @@ test_expect_success "setting CORS in API.HTTPHeaders works via CLI" "
64
65
65
66
test_launch_ipfs_daemon
66
67
68
+ test_expect_success " Companion extension is able to access RPC API even when custom Access-Control-Allow-Origin is set" '
69
+ curl -sD - -X POST -A "Mozilla" -H "Origin: chrome-extension://nibjojkomfdiaoajekhjakgkdhaomnch" "http://127.0.0.1:$API_PORT/api/v0/id" >curl_output &&
70
+ cat curl_output &&
71
+ grep "HTTP/1.1 200 OK" curl_output &&
72
+ grep "$PEERID" curl_output
73
+ '
74
+
67
75
# https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request
68
76
test_expect_success " OPTIONS with preflight request to API with CORS allowlist succeeds" '
69
77
curl -svX OPTIONS -A "Mozilla" -H "Origin: https://valid.example.com" -H "Access-Control-Request-Method: POST" -H "Access-Control-Request-Headers: origin, x-requested-with" "http://127.0.0.1:$API_PORT/api/v0/id" 2>curl_output &&
0 commit comments