mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-09 23:42:20 +08:00
more serious CORS tests.
this commit introduces more serious CORS tests that check status response codes, and run real HTTP requests. License: MIT Signed-off-by: Juan Batiz-Benet <juan@benet.ai>
This commit is contained in:
@ -6,6 +6,7 @@ import (
|
||||
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
|
||||
"github.com/ipfs/go-ipfs/blocks/blockstore"
|
||||
blockservice "github.com/ipfs/go-ipfs/blockservice"
|
||||
commands "github.com/ipfs/go-ipfs/commands"
|
||||
core "github.com/ipfs/go-ipfs/core"
|
||||
"github.com/ipfs/go-ipfs/exchange/offline"
|
||||
mdag "github.com/ipfs/go-ipfs/merkledag"
|
||||
@ -27,7 +28,7 @@ import (
|
||||
|
||||
// NewMockNode constructs an IpfsNode for use in tests.
|
||||
func NewMockNode() (*core.IpfsNode, error) {
|
||||
ctx := context.TODO()
|
||||
ctx := context.Background()
|
||||
|
||||
// Generate Identity
|
||||
ident, err := testutil.RandIdentity()
|
||||
@ -82,3 +83,34 @@ func NewMockNode() (*core.IpfsNode, error) {
|
||||
|
||||
return nd, nil
|
||||
}
|
||||
|
||||
func MockCmdsCtx() (commands.Context, error) {
|
||||
// Generate Identity
|
||||
ident, err := testutil.RandIdentity()
|
||||
if err != nil {
|
||||
return commands.Context{}, err
|
||||
}
|
||||
p := ident.ID()
|
||||
|
||||
conf := config.Config{
|
||||
Identity: config.Identity{
|
||||
PeerID: p.String(),
|
||||
},
|
||||
}
|
||||
|
||||
node, err := core.NewIPFSNode(context.Background(), core.Offline(&repo.Mock{
|
||||
D: ds2.CloserWrap(syncds.MutexWrap(datastore.NewMapDatastore())),
|
||||
C: conf,
|
||||
}))
|
||||
|
||||
return commands.Context{
|
||||
Online: true,
|
||||
ConfigRoot: "/tmp/.mockipfsconfig",
|
||||
LoadConfig: func(path string) (*config.Config, error) {
|
||||
return &conf, nil
|
||||
},
|
||||
ConstructNode: func() (*core.IpfsNode, error) {
|
||||
return node, nil
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user