Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
2feff332
Commit
2feff332
authored
Jul 25, 2020
by
Kevin Neaton
Committed by
Adin Schmahmann
Aug 19, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: update gateway tests for dir-index-html v1.1.0
parent
9e95a82a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
6 deletions
+12
-6
core/corehttp/gateway_test.go
core/corehttp/gateway_test.go
+11
-5
test/sharness/t0111-gateway-writeable.sh
test/sharness/t0111-gateway-writeable.sh
+1
-1
No files found.
core/corehttp/gateway_test.go
View file @
2feff332
...
...
@@ -6,6 +6,7 @@ import (
"io/ioutil"
"net/http"
"net/http/httptest"
"regexp"
"strings"
"testing"
"time"
...
...
@@ -154,6 +155,11 @@ func newTestServerAndNode(t *testing.T, ns mockNamesys) (*httptest.Server, iface
return
ts
,
api
,
n
.
Context
()
}
func
matchPathOrBreadcrumbs
(
s
string
,
expected
string
)
bool
{
matched
,
_
:=
regexp
.
MatchString
(
"Index of
\n
[
\t
]*"
+
regexp
.
QuoteMeta
(
expected
),
s
)
return
matched
}
func
TestGatewayGet
(
t
*
testing
.
T
)
{
ns
:=
mockNamesys
{}
ts
,
api
,
ctx
:=
newTestServerAndNode
(
t
,
ns
)
...
...
@@ -442,7 +448,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) {
s
:=
string
(
body
)
t
.
Logf
(
"body: %s
\n
"
,
string
(
body
))
if
!
strings
.
Contains
(
s
,
"Index of /ipns/example.net/
foo? #<'
/
"
)
{
if
!
matchPathOrBreadcrumbs
(
s
,
"/ipns/<a href=
\"
/ipns/example.net
\"
>example.net</a>/<a href=
\"
/ipns/example.net/foo%3F%20%23%3C%27
\"
>
foo? #<'
</a>
"
)
{
t
.
Fatalf
(
"expected a path in directory listing"
)
}
if
!
strings
.
Contains
(
s
,
"<a href=
\"
/foo%3F%20%23%3C%27/./..
\"
>"
)
{
...
...
@@ -475,7 +481,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) {
s
=
string
(
body
)
t
.
Logf
(
"body: %s
\n
"
,
string
(
body
))
if
!
strings
.
Contains
(
s
,
"Index of
/"
)
{
if
!
matchPathOrBreadcrumbs
(
s
,
"
/"
)
{
t
.
Fatalf
(
"expected a path in directory listing"
)
}
if
!
strings
.
Contains
(
s
,
"<a href=
\"
/
\"
>"
)
{
...
...
@@ -508,7 +514,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) {
s
=
string
(
body
)
t
.
Logf
(
"body: %s
\n
"
,
string
(
body
))
if
!
strings
.
Contains
(
s
,
"Index of /ipns/example.net/foo? #<'/bar/
"
)
{
if
!
matchPathOrBreadcrumbs
(
s
,
"/ipns/<a href=
\"
/ipns/example.net
\"
>example.net</a>/<a href=
\"
/ipns/example.net/foo%3F%20%23%3C%27
\"
>foo? #<'</a>/<a href=
\"
/ipns/example.net/foo%3F%20%23%3C%27/bar
\"
>bar</a>
"
)
{
t
.
Fatalf
(
"expected a path in directory listing"
)
}
if
!
strings
.
Contains
(
s
,
"<a href=
\"
/foo%3F%20%23%3C%27/bar/./..
\"
>"
)
{
...
...
@@ -542,7 +548,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) {
s
=
string
(
body
)
t
.
Logf
(
"body: %s
\n
"
,
string
(
body
))
if
!
strings
.
Contains
(
s
,
"Index of /ipns/example.net
"
)
{
if
!
matchPathOrBreadcrumbs
(
s
,
"/ipns/<a href=
\"
/ipns/example.net
\"
>example.net</a>
"
)
{
t
.
Fatalf
(
"expected a path in directory listing"
)
}
if
!
strings
.
Contains
(
s
,
"<a href=
\"
/good-prefix/
\"
>"
)
{
...
...
@@ -584,7 +590,7 @@ func TestIPNSHostnameBacklinks(t *testing.T) {
s
=
string
(
body
)
t
.
Logf
(
"body: %s
\n
"
,
string
(
body
))
if
!
strings
.
Contains
(
s
,
"Index of
/"
)
{
if
!
matchPathOrBreadcrumbs
(
s
,
"
/"
)
{
t
.
Fatalf
(
"expected a path in directory listing"
)
}
if
!
strings
.
Contains
(
s
,
"<a href=
\"
/
\"
>"
)
{
...
...
test/sharness/t0111-gateway-writeable.sh
View file @
2feff332
...
...
@@ -63,7 +63,7 @@ test_expect_success "HTTP GET empty directory" '
URL="http://127.0.0.1:$port/ipfs/$HASH_EMPTY_DIR/" &&
echo "GET $URL" &&
curl -so outfile "$URL" 2>curl_getEmpty.out &&
grep "Index of /ipfs/$HASH_EMPTY_DIR/" outfile
cat outfile | tr -s "\n" " " | grep "Index of /ipfs/<a href=\"/ipfs/$HASH_EMPTY_DIR\">$HASH_EMPTY_DIR</a>"
'
test_expect_success
"HTTP PUT file to construct a hierarchy"
'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment