Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
51af53d8
提交
51af53d8
authored
1月 30, 2015
作者:
Mildred Ki'Lya
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added Sharness test for HTTP Gateway
上级
c9ff778b
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
116 行增加
和
0 行删除
+116
-0
test-lib.sh
test/sharness/lib/test-lib.sh
+10
-0
t0100-http-gateway.sh
test/sharness/t0100-http-gateway.sh
+106
-0
没有找到文件。
test/sharness/lib/test-lib.sh
浏览文件 @
51af53d8
...
...
@@ -64,6 +64,16 @@ test_wait_output_n_lines_60_sec() {
test_cmp
"expected_waitn"
"actual_waitn"
}
test_wait_open_tcp_port_10_sec
()
{
for
i
in
1 2 3 4 5 6 7 8 9 10
;
do
if
[
$(
ss
-lt
"sport == :
$1
"
| wc
-l
)
-gt
1
]
;
then
return
0
fi
sleep 1
done
return
1
}
test_init_ipfs
()
{
test_expect_success
"ipfs init succeeds"
'
...
...
test/sharness/t0100-http-gateway.sh
0 → 100755
浏览文件 @
51af53d8
#!/bin/sh
#
# Copyright (c) 2014 Christian Couder
# MIT Licensed; see the LICENSE file in this repository.
#
test_description
=
"Test HTTP Gateway"
exec
3>&1 4>&2
.
lib/test-lib.sh
test_expect_success
"Configure http gateway"
'
export IPFS_PATH="$PWD/.go-ipfs";
if ! [ -e ../ipfs-path ]; then
IPFS_PATH="$PWD/../ipfs-path" ipfs init;
fi;
cp -R ../ipfs-path "$IPFS_PATH" &&
ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/5002 &&
ipfs config -bool Gateway.Writable true
'
test_expect_success
"ipfs daemon --init launches and listen to TCP port 5002"
'
export IPFS_PATH="$PWD/.go-ipfs" &&
ipfs daemon 2>&1 >actual_init &
IPFS_PID=$(ps | grep ipfs | awk "{print \$1}");
test_wait_open_tcp_port_10_sec 5002
'
test_expect_success
"HTTP gateway gives access to sample file"
'
curl -s -o welcome http://localhost:5002/ipfs/QmTTFXiXoixwT53tcGPu419udsHEHYu6AHrQC8HAKdJYaZ &&
grep "Hello and Welcome to IPFS!" welcome
'
test_expect_success
"HTTP POST file gives Hash"
'
echo "$RANDOM" >infile
curl -svX POST --data-binary @infile http://localhost:5002/ipfs/ 2>curl.out &&
grep "HTTP/1.1 201 Created" curl.out
'
test_expect_success
"We can HTTP GET file just created"
'
path=$(grep Location curl.out | cut -d" " -f3- | tr -d "\r")
curl -so outfile http://localhost:5002$path &&
diff -u infile outfile
'
test_expect_success
"HTTP PUT empty directory"
'
echo "PUT http://localhost:5002/ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn/" &&
curl -svX PUT http://localhost:5002/ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn/ 2>curl.out &&
cat curl.out &&
grep "Ipfs-Hash: QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn" curl.out &&
grep "Location: /ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn/" curl.out &&
grep "HTTP/1.1 201 Created" curl.out
'
test_expect_success
"HTTP GET empty directory"
'
echo "GET http://localhost:5002/ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn/" &&
curl -so outfile http://localhost:5002/ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn/ 2>curl.out &&
grep "Index of /ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn/" outfile
'
test_expect_success
"HTTP PUT file to construct a hierarchy"
'
echo "$RANDOM" >infile
echo "PUT http://localhost:5002/ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn/test.txt" &&
curl -svX PUT --data-binary @infile http://localhost:5002/ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn/test.txt 2>curl.out &&
grep "HTTP/1.1 201 Created" curl.out &&
grep Location curl.out
'
test_expect_success
"We can HTTP GET file just created"
'
path=$(grep Location curl.out | cut -d" " -f3- | tr -d "\r");
echo "$path" = "${path%/test.txt}/test.txt";
[ "$path" = "${path%/test.txt}/test.txt" ] &&
echo "GET http://localhost:5002$path" &&
curl -so outfile http://localhost:5002$path &&
diff -u infile outfile
'
test_expect_success
"HTTP PUT file to append to existing hierarchy"
'
echo "$RANDOM" >infile2;
echo "PUT http://localhost:5002${path%/test.txt}/test/test.txt" &&
curl -svX PUT --data-binary @infile2 http://localhost:5002${path%/test.txt}/test/test.txt 2>curl.out &&
grep "HTTP/1.1 201 Created" curl.out &&
grep Location curl.out
'
test_expect_success
"We can HTTP GET file just created"
'
path=$(grep Location curl.out | cut -d" " -f3- | tr -d "\r");
[ "$path" = "${path%/test/test.txt}/test/test.txt" ] &&
echo "GET http://localhost:5002$path" &&
curl -so outfile2 http://localhost:5002$path &&
diff -u infile2 outfile2 &&
echo "GET http://localhost:5002${path%/test/test.txt}/test.txt" &&
curl -so outfile http://localhost:5002${path%/test/test.txt}/test.txt &&
diff -u infile outfile
'
test_expect_success
"daemon is still running"
'
echo IPFS_PID=$IPFS_PID;
kill -15 $IPFS_PID
'
test_expect_success
"'ipfs daemon' can be killed"
'
test_kill_repeat_10_sec $IPFS_PID
'
test_done
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论