Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
mybee
Commits
05eb3092
Unverified
Commit
05eb3092
authored
Aug 23, 2021
by
istae
Committed by
GitHub
Aug 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: added encrypt and pin headers for file uploads in api/pin tests (#2411)
parent
8c40f5e2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
17 deletions
+20
-17
pin_test.go
pkg/api/pin_test.go
+20
-17
No files found.
pkg/api/pin_test.go
View file @
05eb3092
...
...
@@ -25,7 +25,7 @@ import (
"github.com/ethersphere/bee/pkg/traversal"
)
func
checkPinHandlers
(
t
*
testing
.
T
,
client
*
http
.
Client
,
rootHash
string
)
{
func
checkPinHandlers
(
t
*
testing
.
T
,
client
*
http
.
Client
,
rootHash
string
,
createPin
bool
)
{
t
.
Helper
()
const
pinsBasePath
=
"/pins"
...
...
@@ -45,12 +45,14 @@ func checkPinHandlers(t *testing.T, client *http.Client, rootHash string) {
}),
)
jsonhttptest
.
Request
(
t
,
client
,
http
.
MethodPost
,
pinsReferencePath
,
http
.
StatusCreated
,
jsonhttptest
.
WithExpectedJSONResponse
(
jsonhttp
.
StatusResponse
{
Message
:
http
.
StatusText
(
http
.
StatusCreated
),
Code
:
http
.
StatusCreated
,
}),
)
if
createPin
{
jsonhttptest
.
Request
(
t
,
client
,
http
.
MethodPost
,
pinsReferencePath
,
http
.
StatusCreated
,
jsonhttptest
.
WithExpectedJSONResponse
(
jsonhttp
.
StatusResponse
{
Message
:
http
.
StatusText
(
http
.
StatusCreated
),
Code
:
http
.
StatusCreated
,
}),
)
}
jsonhttptest
.
Request
(
t
,
client
,
http
.
MethodGet
,
pinsReferencePath
,
http
.
StatusOK
,
jsonhttptest
.
WithExpectedJSONResponse
(
struct
{
...
...
@@ -100,7 +102,7 @@ func TestPinHandlers(t *testing.T) {
Reference
:
swarm
.
MustParseHexAddress
(
rootHash
),
}),
)
checkPinHandlers
(
t
,
client
,
rootHash
)
checkPinHandlers
(
t
,
client
,
rootHash
,
true
)
})
t
.
Run
(
"bzz"
,
func
(
t
*
testing
.
T
)
{
...
...
@@ -114,23 +116,24 @@ func TestPinHandlers(t *testing.T) {
jsonhttptest
.
WithRequestHeader
(
api
.
SwarmPostageBatchIdHeader
,
batchOkStr
),
jsonhttptest
.
WithRequestBody
(
tarReader
),
jsonhttptest
.
WithRequestHeader
(
"Content-Type"
,
api
.
ContentTypeTar
),
jsonhttptest
.
WithRequestHeader
(
api
.
SwarmCollectionHeader
,
"True"
),
jsonhttptest
.
WithRequestHeader
(
api
.
SwarmCollectionHeader
,
"true"
),
jsonhttptest
.
WithRequestHeader
(
api
.
SwarmPinHeader
,
"true"
),
jsonhttptest
.
WithExpectedJSONResponse
(
api
.
BzzUploadResponse
{
Reference
:
swarm
.
MustParseHexAddress
(
rootHash
),
}),
)
checkPinHandlers
(
t
,
client
,
rootHash
)
checkPinHandlers
(
t
,
client
,
rootHash
,
false
)
rootHash
=
"dd13a5a6cc9db3ef514d645e6719178dbfb1a90b49b9262cafce35b0d27cf245"
jsonhttptest
.
Request
(
t
,
client
,
http
.
MethodPost
,
"/bzz?name=somefile.txt"
,
http
.
StatusCreated
,
header
:=
jsonhttptest
.
Request
(
t
,
client
,
http
.
MethodPost
,
"/bzz?name=somefile.txt"
,
http
.
StatusCreated
,
jsonhttptest
.
WithRequestHeader
(
api
.
SwarmPostageBatchIdHeader
,
batchOkStr
),
jsonhttptest
.
WithRequestHeader
(
"Content-Type"
,
"text/plain"
),
jsonhttptest
.
WithRequestHeader
(
api
.
SwarmEncryptHeader
,
"true"
),
jsonhttptest
.
WithRequestHeader
(
api
.
SwarmPinHeader
,
"true"
),
jsonhttptest
.
WithRequestBody
(
strings
.
NewReader
(
"this is a simple text"
)),
jsonhttptest
.
WithExpectedJSONResponse
(
api
.
BzzUploadResponse
{
Reference
:
swarm
.
MustParseHexAddress
(
rootHash
),
}),
)
checkPinHandlers
(
t
,
client
,
rootHash
)
rootHash
=
strings
.
Trim
(
header
.
Get
(
"ETag"
),
"
\"
"
)
checkPinHandlers
(
t
,
client
,
rootHash
,
false
)
})
t
.
Run
(
"chunk"
,
func
(
t
*
testing
.
T
)
{
...
...
@@ -145,6 +148,6 @@ func TestPinHandlers(t *testing.T) {
Reference
:
chunk
.
Address
(),
}),
)
checkPinHandlers
(
t
,
client
,
rootHash
)
checkPinHandlers
(
t
,
client
,
rootHash
,
true
)
})
}
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