mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-11 19:27:51 +08:00
Merge branch 'master' into merge-release-v0.20.0
This commit is contained in:
commit
d1e2067e03
34
.github/workflows/build.yml
vendored
34
.github/workflows/build.yml
vendored
@ -14,6 +14,10 @@ concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
jobs:
|
||||
interop-prep:
|
||||
if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
|
||||
@ -44,7 +48,7 @@ jobs:
|
||||
path: cmd/ipfs/ipfs
|
||||
interop:
|
||||
needs: [interop-prep]
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ${{ fromJSON(github.repository == 'ipfs/kubo' && '["self-hosted", "linux", "x64", "2xlarge"]' || '"ubuntu-latest"') }}
|
||||
timeout-minutes: 20
|
||||
defaults:
|
||||
run:
|
||||
@ -75,7 +79,7 @@ jobs:
|
||||
npm install ipfs-interop@^10.0.1
|
||||
working-directory: interop
|
||||
# Run the interop tests while ignoring the js-js interop test cases
|
||||
- run: npx ipfs-interop -- -t node --grep '^(?!.*(js\d? -> js\d?|js-js-js))'
|
||||
- run: npx ipfs-interop -- -t node --grep '^(?!.*(js\d? -> js\d?|js-js-js))' --parallel
|
||||
env:
|
||||
LIBP2P_TCP_REUSEPORT: false
|
||||
LIBP2P_ALLOW_WEAK_RSA_KEYS: 1
|
||||
@ -156,7 +160,7 @@ jobs:
|
||||
working-directory: go-ipfs-http-client
|
||||
ipfs-webui:
|
||||
needs: [interop-prep]
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ${{ fromJSON(github.repository == 'ipfs/kubo' && '["self-hosted", "linux", "x64", "2xlarge"]' || '"ubuntu-latest"') }}
|
||||
timeout-minutes: 20
|
||||
env:
|
||||
NO_SANDBOX: true
|
||||
@ -191,14 +195,26 @@ jobs:
|
||||
key: ${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-${{ github.job }}-
|
||||
- run: |
|
||||
npm ci --prefer-offline --no-audit --progress=false
|
||||
npx playwright install
|
||||
- env:
|
||||
NPM_CACHE_DIR: ${{ steps.npm-cache-dir.outputs.dir }}
|
||||
run: |
|
||||
npm ci --prefer-offline --no-audit --progress=false --cache "$NPM_CACHE_DIR"
|
||||
npx playwright install --with-deps
|
||||
working-directory: ipfs-webui
|
||||
- name: Run ipfs-webui@main build and smoke-test to confirm the upstream repo is not broken
|
||||
run: npm test
|
||||
- id: ref
|
||||
run: echo "ref=$(git rev-parse --short HEAD)" | tee -a $GITHUB_OUTPUT
|
||||
working-directory: ipfs-webui
|
||||
- name: Test ipfs-webui@main E2E against the locally built Kubo binary
|
||||
- id: state
|
||||
env:
|
||||
GITHUB_REPOSITORY: ipfs/ipfs-webui
|
||||
GITHUB_REF: ${{ steps.ref.outputs.ref }}
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
echo "state=$(curl -L -H "Authorization: Bearer $GITHUB_TOKEN" "https://api.github.com/repos/$GITHUB_REPOSITORY/commits/$GITHUB_REF/status" --jq '.state')" | tee -a $GITHUB_OUTPUT
|
||||
- name: Build ipfs-webui@main (state=${{ steps.state.outputs.state }})
|
||||
run: npm run test:build
|
||||
working-directory: ipfs-webui
|
||||
- name: Test ipfs-webui@main (state=${{ steps.state.outputs.state }}) E2E against the locally built Kubo binary
|
||||
run: npm run test:e2e
|
||||
env:
|
||||
IPFS_GO_EXEC: ${{ github.workspace }}/cmd/ipfs/ipfs
|
||||
|
||||
7
.github/workflows/gobuild.yml
vendored
7
.github/workflows/gobuild.yml
vendored
@ -12,12 +12,9 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
go-build-runner:
|
||||
if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
|
||||
uses: ipfs/kubo/.github/workflows/runner.yml@master
|
||||
go-build:
|
||||
needs: [go-build-runner]
|
||||
runs-on: ${{ fromJSON(needs.go-build-runner.outputs.config).labels }}
|
||||
if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
|
||||
runs-on: ${{ fromJSON(github.repository == 'ipfs/kubo' && '["self-hosted", "linux", "x64", "4xlarge"]' || '"ubuntu-latest"') }}
|
||||
timeout-minutes: 20
|
||||
env:
|
||||
TEST_DOCKER: 0
|
||||
|
||||
12
.github/workflows/gotest.yml
vendored
12
.github/workflows/gotest.yml
vendored
@ -12,12 +12,9 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
go-test-runner:
|
||||
if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
|
||||
uses: ipfs/kubo/.github/workflows/runner.yml@master
|
||||
go-test:
|
||||
needs: [go-test-runner]
|
||||
runs-on: ${{ fromJSON(needs.go-test-runner.outputs.config).labels }}
|
||||
if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
|
||||
runs-on: ${{ fromJSON(github.repository == 'ipfs/kubo' && '["self-hosted", "linux", "x64", "2xlarge"]' || '"ubuntu-latest"') }}
|
||||
timeout-minutes: 20
|
||||
env:
|
||||
TEST_DOCKER: 0
|
||||
@ -41,8 +38,11 @@ jobs:
|
||||
with:
|
||||
name: ${{ github.job }}
|
||||
- name: 👉️ If this step failed, go to «Summary» (top left) → inspect the «Failures/Errors» table
|
||||
env:
|
||||
# increasing parallelism beyond 2 doesn't speed up the tests much
|
||||
PARALLEL: 2
|
||||
run: |
|
||||
make -j 2 test/unit/gotest.junit.xml &&
|
||||
make -j "$PARALLEL" test/unit/gotest.junit.xml &&
|
||||
[[ ! $(jq -s -c 'map(select(.Action == "fail")) | .[]' test/unit/gotest.json) ]]
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
|
||||
|
||||
34
.github/workflows/runner.yml
vendored
34
.github/workflows/runner.yml
vendored
@ -1,34 +0,0 @@
|
||||
name: Runner
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
outputs:
|
||||
config:
|
||||
description: "The runner's configuration"
|
||||
value: ${{ jobs.choose.outputs.config }}
|
||||
|
||||
jobs:
|
||||
choose:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 1
|
||||
outputs:
|
||||
config: ${{ steps.config.outputs.result }}
|
||||
steps:
|
||||
- uses: actions/github-script@v6
|
||||
id: config
|
||||
with:
|
||||
script: |
|
||||
if (`${context.repo.owner}/${context.repo.repo}` === 'ipfs/kubo') {
|
||||
return {
|
||||
labels: ['self-hosted', 'linux', 'x64', 'kubo'],
|
||||
parallel: 10,
|
||||
aws: true
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
labels: ['ubuntu-latest'],
|
||||
parallel: 3,
|
||||
aws: false
|
||||
}
|
||||
}
|
||||
- run: echo ${{ steps.config.outputs.result }}
|
||||
20
.github/workflows/sharness.yml
vendored
20
.github/workflows/sharness.yml
vendored
@ -12,12 +12,9 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
sharness-runner:
|
||||
if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
|
||||
uses: ipfs/kubo/.github/workflows/runner.yml@master
|
||||
sharness-test:
|
||||
needs: [sharness-runner]
|
||||
runs-on: ${{ fromJSON(needs.sharness-runner.outputs.config).labels }}
|
||||
if: github.repository == 'ipfs/kubo' || github.event_name == 'workflow_dispatch'
|
||||
runs-on: ${{ fromJSON(github.repository == 'ipfs/kubo' && '["self-hosted", "linux", "x64", "4xlarge"]' || '"ubuntu-latest"') }}
|
||||
timeout-minutes: 20
|
||||
defaults:
|
||||
run:
|
||||
@ -57,7 +54,8 @@ jobs:
|
||||
TEST_EXPENSIVE: 1
|
||||
IPFS_CHECK_RCMGR_DEFAULTS: 1
|
||||
CONTINUE_ON_S_FAILURE: 1
|
||||
PARALLEL: ${{ fromJSON(needs.sharness-runner.outputs.config).parallel }}
|
||||
# increasing parallelism beyond 10 doesn't speed up the tests much
|
||||
PARALLEL: ${{ github.repository == 'ipfs/kubo' && 10 || 3 }}
|
||||
- name: Upload coverage report
|
||||
uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
|
||||
if: failure() || success()
|
||||
@ -86,12 +84,12 @@ jobs:
|
||||
- name: Upload one-page HTML report to S3
|
||||
id: one-page
|
||||
uses: pl-strflt/tf-aws-gh-runner/.github/actions/upload-artifact@main
|
||||
if: fromJSON(needs.sharness-runner.outputs.config).aws && (failure() || success())
|
||||
if: github.repository == 'ipfs/kubo' && (failure() || success())
|
||||
with:
|
||||
source: kubo/test/sharness/test-results/sharness.html
|
||||
destination: sharness.html
|
||||
- name: Upload one-page HTML report
|
||||
if: (! fromJSON(needs.sharness-runner.outputs.config).aws) && (failure() || success())
|
||||
if: github.repository != 'ipfs/kubo' && (failure() || success())
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: sharness.html
|
||||
@ -106,18 +104,18 @@ jobs:
|
||||
- name: Upload full HTML report to S3
|
||||
id: full
|
||||
uses: pl-strflt/tf-aws-gh-runner/.github/actions/upload-artifact@main
|
||||
if: fromJSON(needs.sharness-runner.outputs.config).aws && (failure() || success())
|
||||
if: github.repository == 'ipfs/kubo' && (failure() || success())
|
||||
with:
|
||||
source: kubo/test/sharness/test-results/sharness-html
|
||||
destination: sharness-html/
|
||||
- name: Upload full HTML report
|
||||
if: (! fromJSON(needs.sharness-runner.outputs.config).aws) && (failure() || success())
|
||||
if: github.repository != 'ipfs/kubo' && (failure() || success())
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: sharness-html
|
||||
path: kubo/test/sharness/test-results/sharness-html
|
||||
- name: Add S3 links to the summary
|
||||
if: fromJSON(needs.sharness-runner.outputs.config).aws && (failure() || success())
|
||||
if: github.repository == 'ipfs/kubo' && (failure() || success())
|
||||
run: echo "$MD" >> $GITHUB_STEP_SUMMARY
|
||||
env:
|
||||
MD: |
|
||||
|
||||
@ -10,6 +10,8 @@ import (
|
||||
|
||||
cmdenv "github.com/ipfs/kubo/core/commands/cmdenv"
|
||||
|
||||
iface "github.com/ipfs/boxo/coreiface"
|
||||
"github.com/ipfs/boxo/coreiface/options"
|
||||
dag "github.com/ipfs/boxo/ipld/merkledag"
|
||||
path "github.com/ipfs/boxo/path"
|
||||
cid "github.com/ipfs/go-cid"
|
||||
@ -19,6 +21,16 @@ import (
|
||||
routing "github.com/libp2p/go-libp2p/core/routing"
|
||||
)
|
||||
|
||||
var (
|
||||
errAllowOffline = errors.New("can't put while offline: pass `--allow-offline` to override")
|
||||
)
|
||||
|
||||
const (
|
||||
dhtVerboseOptionName = "verbose"
|
||||
numProvidersOptionName = "num-providers"
|
||||
allowOfflineOptionName = "allow-offline"
|
||||
)
|
||||
|
||||
var RoutingCmd = &cmds.Command{
|
||||
Helptext: cmds.HelpText{
|
||||
Tagline: "Issue routing commands.",
|
||||
@ -34,14 +46,6 @@ var RoutingCmd = &cmds.Command{
|
||||
},
|
||||
}
|
||||
|
||||
const (
|
||||
dhtVerboseOptionName = "verbose"
|
||||
)
|
||||
|
||||
const (
|
||||
numProvidersOptionName = "num-providers"
|
||||
)
|
||||
|
||||
var findProvidersRoutingCmd = &cmds.Command{
|
||||
Helptext: cmds.HelpText{
|
||||
Tagline: "Find peers that can provide a specific value, given a key.",
|
||||
@ -420,6 +424,9 @@ identified by QmFoo.
|
||||
cmds.StringArg("key", true, false, "The key to store the value at."),
|
||||
cmds.FileArg("value-file", true, false, "A path to a file containing the value to store.").EnableStdin(),
|
||||
},
|
||||
Options: []cmds.Option{
|
||||
cmds.BoolOption(allowOfflineOptionName, "When offline, save the IPNS record to the the local datastore without broadcasting to the network instead of simply failing."),
|
||||
},
|
||||
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
|
||||
api, err := cmdenv.GetApi(env, req)
|
||||
if err != nil {
|
||||
@ -437,13 +444,22 @@ identified by QmFoo.
|
||||
return err
|
||||
}
|
||||
|
||||
err = api.Routing().Put(req.Context, req.Arguments[0], data)
|
||||
allowOffline, _ := req.Options[allowOfflineOptionName].(bool)
|
||||
|
||||
opts := []options.RoutingPutOption{
|
||||
options.Put.AllowOffline(allowOffline),
|
||||
}
|
||||
|
||||
err = api.Routing().Put(req.Context, req.Arguments[0], data, opts...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
id, err := api.Key().Self(req.Context)
|
||||
if err != nil {
|
||||
if err == iface.ErrOffline {
|
||||
err = errAllowOffline
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
|
||||
coreiface "github.com/ipfs/boxo/coreiface"
|
||||
caopts "github.com/ipfs/boxo/coreiface/options"
|
||||
"github.com/ipfs/boxo/path"
|
||||
peer "github.com/libp2p/go-libp2p/core/peer"
|
||||
)
|
||||
@ -24,9 +25,15 @@ func (r *RoutingAPI) Get(ctx context.Context, key string) ([]byte, error) {
|
||||
return r.routing.GetValue(ctx, dhtKey)
|
||||
}
|
||||
|
||||
func (r *RoutingAPI) Put(ctx context.Context, key string, value []byte) error {
|
||||
if !r.nd.IsOnline {
|
||||
return coreiface.ErrOffline
|
||||
func (r *RoutingAPI) Put(ctx context.Context, key string, value []byte, opts ...caopts.RoutingPutOption) error {
|
||||
options, err := caopts.RoutingPutOptions(opts...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = r.checkOnline(options.AllowOffline)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dhtKey, err := normalizeKey(key)
|
||||
|
||||
@ -31,7 +31,7 @@ const testPeerID = "QmTFauExutTsy4XP6JbMFcw2Wa9645HJt2bTqL6qYDCKfe"
|
||||
|
||||
type NodeProvider struct{}
|
||||
|
||||
func (NodeProvider) MakeAPISwarm(ctx context.Context, fullIdentity bool, n int) ([]coreiface.CoreAPI, error) {
|
||||
func (NodeProvider) MakeAPISwarm(ctx context.Context, fullIdentity bool, online bool, n int) ([]coreiface.CoreAPI, error) {
|
||||
mn := mocknet.New()
|
||||
|
||||
nodes := make([]*core.IpfsNode, n)
|
||||
@ -82,7 +82,7 @@ func (NodeProvider) MakeAPISwarm(ctx context.Context, fullIdentity bool, n int)
|
||||
Routing: libp2p.DHTServerOption,
|
||||
Repo: r,
|
||||
Host: mock.MockHostOption(mn),
|
||||
Online: fullIdentity,
|
||||
Online: online,
|
||||
ExtraOpts: map[string]bool{
|
||||
"pubsub": true,
|
||||
},
|
||||
@ -102,15 +102,17 @@ func (NodeProvider) MakeAPISwarm(ctx context.Context, fullIdentity bool, n int)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bsinf := bootstrap.BootstrapConfigWithPeers(
|
||||
[]peer.AddrInfo{
|
||||
nodes[0].Peerstore.PeerInfo(nodes[0].Identity),
|
||||
},
|
||||
)
|
||||
if online {
|
||||
bsinf := bootstrap.BootstrapConfigWithPeers(
|
||||
[]peer.AddrInfo{
|
||||
nodes[0].Peerstore.PeerInfo(nodes[0].Identity),
|
||||
},
|
||||
)
|
||||
|
||||
for _, n := range nodes[1:] {
|
||||
if err := n.Bootstrap(bsinf); err != nil {
|
||||
return nil, err
|
||||
for _, n := range nodes[1:] {
|
||||
if err := n.Bootstrap(bsinf); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ func TestPathUnixFSHAMTPartial(t *testing.T) {
|
||||
defer cancel()
|
||||
|
||||
// Create a node
|
||||
apis, err := NodeProvider{}.MakeAPISwarm(ctx, true, 1)
|
||||
apis, err := NodeProvider{}.MakeAPISwarm(ctx, true, true, 1)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ go 1.18
|
||||
replace github.com/ipfs/kubo => ./../../..
|
||||
|
||||
require (
|
||||
github.com/ipfs/boxo v0.8.1
|
||||
github.com/ipfs/boxo v0.8.2-0.20230503105907-8059f183d866
|
||||
github.com/ipfs/kubo v0.0.0-00010101000000-000000000000
|
||||
github.com/libp2p/go-libp2p v0.27.3
|
||||
github.com/multiformats/go-multiaddr v0.9.0
|
||||
|
||||
@ -321,8 +321,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
|
||||
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
|
||||
github.com/ipfs/boxo v0.8.1 h1:3DkKBCK+3rdEB5t77WDShUXXhktYwH99mkAsgajsKrU=
|
||||
github.com/ipfs/boxo v0.8.1/go.mod h1:xJ2hVb4La5WyD7GvKYE0lq2g1rmQZoCD2K4WNrV6aZI=
|
||||
github.com/ipfs/boxo v0.8.2-0.20230503105907-8059f183d866 h1:ThRTXD/EyoLb/jz+YW+ZlOLbjX9FyaxP0dEpgUp3cCE=
|
||||
github.com/ipfs/boxo v0.8.2-0.20230503105907-8059f183d866/go.mod h1:bORAHrH6hUtDZjbzTEaLrSpTdyhHKDIpjDRT+A14B7w=
|
||||
github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
|
||||
github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
|
||||
github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY=
|
||||
|
||||
2
go.mod
2
go.mod
@ -16,7 +16,7 @@ require (
|
||||
github.com/gogo/protobuf v1.3.2
|
||||
github.com/google/uuid v1.3.0
|
||||
github.com/hashicorp/go-multierror v1.1.1
|
||||
github.com/ipfs/boxo v0.8.1
|
||||
github.com/ipfs/boxo v0.8.2-0.20230503105907-8059f183d866
|
||||
github.com/ipfs/go-block-format v0.1.2
|
||||
github.com/ipfs/go-cid v0.4.1
|
||||
github.com/ipfs/go-cidutil v0.1.0
|
||||
|
||||
4
go.sum
4
go.sum
@ -356,8 +356,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
|
||||
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
|
||||
github.com/ipfs/boxo v0.8.1 h1:3DkKBCK+3rdEB5t77WDShUXXhktYwH99mkAsgajsKrU=
|
||||
github.com/ipfs/boxo v0.8.1/go.mod h1:xJ2hVb4La5WyD7GvKYE0lq2g1rmQZoCD2K4WNrV6aZI=
|
||||
github.com/ipfs/boxo v0.8.2-0.20230503105907-8059f183d866 h1:ThRTXD/EyoLb/jz+YW+ZlOLbjX9FyaxP0dEpgUp3cCE=
|
||||
github.com/ipfs/boxo v0.8.2-0.20230503105907-8059f183d866/go.mod h1:bORAHrH6hUtDZjbzTEaLrSpTdyhHKDIpjDRT+A14B7w=
|
||||
github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
|
||||
github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
|
||||
github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY=
|
||||
|
||||
@ -93,40 +93,29 @@ test_launch_ipfs_daemon_without_network
|
||||
|
||||
# Import test case
|
||||
# See the static fixtures in ./t0114-gateway-subdomains/
|
||||
test_expect_success "Add the test fixtures" '
|
||||
ipfs dag import ../t0114-gateway-subdomains/fixtures.car
|
||||
'
|
||||
CID_VAL="hello"
|
||||
CID_VAL=hello
|
||||
CIDv1=bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am
|
||||
CIDv0=QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN
|
||||
# CIDv0to1 is necessary because raw-leaves are enabled by default during
|
||||
# "ipfs add" with CIDv1 and disabled with CIDv0
|
||||
CIDv0to1=bafybeiffndsajwhk3lwjewwdxqntmjm4b5wxaaanokonsggenkbw6slwk4
|
||||
CIDv1_TOO_LONG=bafkrgqhhyivzstcz3hhswshfjgy6ertgmnqeleynhwt4dlfsthi4hn7zgh4uvlsb5xncykzapi3ocd4lzogukir6ksdy6wzrnz6ohnv4aglcs
|
||||
DIR_CID=bafybeiht6dtwk3les7vqm6ibpvz6qpohidvlshsfyr7l5mpysdw2vmbbhe # ./testdirlisting
|
||||
DIR_CID=bafybeiht6dtwk3les7vqm6ibpvz6qpohidvlshsfyr7l5mpysdw2vmbbhe
|
||||
|
||||
test_expect_success "Publish test text file to IPNS using RSA keys" '
|
||||
RSA_KEY=$(ipfs key gen --ipns-base=b58mh --type=rsa --size=2048 test_key_rsa | head -n1 | tr -d "\n")
|
||||
RSA_IPNS_IDv0=$(echo "$RSA_KEY" | ipfs cid format -v 0)
|
||||
RSA_IPNS_IDv1=$(echo "$RSA_KEY" | ipfs cid format -v 1 --mc libp2p-key -b base36)
|
||||
RSA_IPNS_IDv1_DAGPB=$(echo "$RSA_IPNS_IDv0" | ipfs cid format -v 1 -b base36)
|
||||
test_check_peerid "${RSA_KEY}" &&
|
||||
ipfs name publish --key test_key_rsa --allow-offline -Q "/ipfs/$CIDv1" > name_publish_out &&
|
||||
ipfs name resolve "$RSA_KEY" > output &&
|
||||
printf "/ipfs/%s\n" "$CIDv1" > expected2 &&
|
||||
test_cmp expected2 output
|
||||
'
|
||||
RSA_KEY=QmVujd5Vb7moysJj8itnGufN7MEtPRCNHkKpNuA4onsRa3
|
||||
RSA_IPNS_IDv0=QmVujd5Vb7moysJj8itnGufN7MEtPRCNHkKpNuA4onsRa3
|
||||
RSA_IPNS_IDv1=k2k4r8m7xvggw5pxxk3abrkwyer625hg01hfyggrai7lk1m63fuihi7w
|
||||
RSA_IPNS_IDv1_DAGPB=k2jmtxu61bnhrtj301lw7zizknztocdbeqhxgv76l2q9t36fn9jbzipo
|
||||
|
||||
test_expect_success "Publish test text file to IPNS using ED25519 keys" '
|
||||
ED25519_KEY=$(ipfs key gen --ipns-base=b58mh --type=ed25519 test_key_ed25519 | head -n1 | tr -d "\n")
|
||||
ED25519_IPNS_IDv0=$ED25519_KEY
|
||||
ED25519_IPNS_IDv1=$(ipfs key list -l --ipns-base=base36 | grep test_key_ed25519 | cut -d " " -f1 | tr -d "\n")
|
||||
ED25519_IPNS_IDv1_DAGPB=$(echo "$ED25519_IPNS_IDv1" | ipfs cid format -v 1 -b base36 --mc dag-pb)
|
||||
test_check_peerid "${ED25519_KEY}" &&
|
||||
ipfs name publish --key test_key_ed25519 --allow-offline -Q "/ipfs/$CIDv1" > name_publish_out &&
|
||||
ipfs name resolve "$ED25519_KEY" > output &&
|
||||
printf "/ipfs/%s\n" "$CIDv1" > expected2 &&
|
||||
test_cmp expected2 output
|
||||
ED25519_KEY=12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d
|
||||
ED25519_IPNS_IDv0=12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d
|
||||
ED25519_IPNS_IDv1=k51qzi5uqu5dk3v4rmjber23h16xnr23bsggmqqil9z2gduiis5se8dht36dam
|
||||
ED25519_IPNS_IDv1_DAGPB=k50rm9yjlt0jey4fqg6wafvqprktgbkpgkqdg27tpqje6iimzxewnhvtin9hhq
|
||||
IPNS_ED25519_B58MH=12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d
|
||||
IPNS_ED25519_B36CID=k51qzi5uqu5dk3v4rmjber23h16xnr23bsggmqqil9z2gduiis5se8dht36dam
|
||||
|
||||
test_expect_success "Add the test fixtures" '
|
||||
ipfs dag import ../t0114-gateway-subdomains/fixtures.car &&
|
||||
ipfs routing put --allow-offline /ipns/${RSA_KEY} ../t0114-gateway-subdomains/${RSA_KEY}.ipns-record &&
|
||||
ipfs routing put --allow-offline /ipns/${ED25519_KEY} ../t0114-gateway-subdomains/${ED25519_KEY}.ipns-record
|
||||
'
|
||||
|
||||
# ensure we start with empty Gateway.PublicGateways
|
||||
@ -588,11 +577,6 @@ test_expect_success \
|
||||
## https://github.com/ipfs/go-ipfs/issues/7318
|
||||
## ============================================================================
|
||||
|
||||
# ed25519 fits under 63 char limit when represented in base36
|
||||
IPNS_KEY="test_key_ed25519"
|
||||
IPNS_ED25519_B58MH=$(ipfs key list -l --ipns-base b58mh | grep $IPNS_KEY | cut -d" " -f1 | tr -d "\n")
|
||||
IPNS_ED25519_B36CID=$(ipfs key list -l --ipns-base base36 | grep $IPNS_KEY | cut -d" " -f1 | tr -d "\n")
|
||||
|
||||
# local: *.localhost
|
||||
test_localhost_gateway_response_should_contain \
|
||||
"request for a ED25519 libp2p-key at localhost/ipns/{b58mh} returns Location HTTP header for DNS-safe subdomain redirect in browsers" \
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -3,10 +3,16 @@
|
||||
- fixtures.car
|
||||
- raw CARv1
|
||||
|
||||
generated with:
|
||||
- QmUKd....ipns-record
|
||||
- ipns record, encoded with protocol buffer
|
||||
|
||||
- 12D3K....ipns-record
|
||||
- ipns record, encoded with protocol buffer
|
||||
|
||||
Generated with:
|
||||
|
||||
```sh
|
||||
# using ipfs version 0.18.1
|
||||
# using ipfs version 0.21.0-dev (03a98280e3e642774776cd3d0435ab53e5dfa867)
|
||||
|
||||
# CIDv0to1 is necessary because raw-leaves are enabled by default during
|
||||
# "ipfs add" with CIDv1 and disabled with CIDv0
|
||||
@ -17,6 +23,7 @@ CIDv0to1=$(echo "$CIDv0" | ipfs cid base32)
|
||||
# sha512 will be over 63char limit, even when represented in Base36
|
||||
CIDv1_TOO_LONG=$(echo $CID_VAL | ipfs add --cid-version 1 --hash sha2-512 -Q)
|
||||
|
||||
echo CID_VAL=${CID_VAL}
|
||||
echo CIDv1=${CIDv1}
|
||||
echo CIDv0=${CIDv0}
|
||||
echo CIDv0to1=${CIDv0to1}
|
||||
@ -32,7 +39,7 @@ echo "I am a txt file" > testdirlisting/api/file.txt &&
|
||||
echo "I am a txt file" > testdirlisting/ipfs/file.txt &&
|
||||
DIR_CID=$(ipfs add -Qr --cid-version 1 testdirlisting)
|
||||
|
||||
echo DIR_CID=${DIR_CID}
|
||||
echo DIR_CID=${DIR_CID} # ./testdirlisting
|
||||
|
||||
ipfs files mkdir /t0114/
|
||||
ipfs files cp /ipfs/${CIDv1} /t0114/
|
||||
@ -45,10 +52,60 @@ ROOT=`ipfs files stat /t0114/ --hash`
|
||||
|
||||
ipfs dag export ${ROOT} > ./fixtures.car
|
||||
|
||||
# CID_VAL="hello"
|
||||
# Then the keys
|
||||
|
||||
KEY_NAME=test_key_rsa_$RANDOM
|
||||
RSA_KEY=$(ipfs key gen --ipns-base=b58mh --type=rsa --size=2048 ${KEY_NAME} | head -n1 | tr -d "\n")
|
||||
RSA_IPNS_IDv0=$(echo "$RSA_KEY" | ipfs cid format -v 0)
|
||||
RSA_IPNS_IDv1=$(echo "$RSA_KEY" | ipfs cid format -v 1 --mc libp2p-key -b base36)
|
||||
RSA_IPNS_IDv1_DAGPB=$(echo "$RSA_IPNS_IDv0" | ipfs cid format -v 1 -b base36)
|
||||
|
||||
# publish a record valid for a 100 years
|
||||
ipfs name publish --key ${KEY_NAME} --allow-offline -Q --ttl=876600h --lifetime=876600h "/ipfs/$CIDv1"
|
||||
ipfs routing get /ipns/${RSA_KEY} > ${RSA_KEY}.ipns-record
|
||||
|
||||
echo RSA_KEY=${RSA_KEY}
|
||||
echo RSA_IPNS_IDv0=${RSA_IPNS_IDv0}
|
||||
echo RSA_IPNS_IDv1=${RSA_IPNS_IDv1}
|
||||
echo RSA_IPNS_IDv1_DAGPB=${RSA_IPNS_IDv1_DAGPB}
|
||||
|
||||
KEY_NAME=test_key_ed25519_$RANDOM
|
||||
ED25519_KEY=$(ipfs key gen --ipns-base=b58mh --type=ed25519 ${KEY_NAME} | head -n1 | tr -d "\n")
|
||||
ED25519_IPNS_IDv0=$ED25519_KEY
|
||||
ED25519_IPNS_IDv1=$(ipfs key list -l --ipns-base=base36 | grep ${KEY_NAME} | cut -d " " -f1 | tr -d "\n")
|
||||
ED25519_IPNS_IDv1_DAGPB=$(echo "$ED25519_IPNS_IDv1" | ipfs cid format -v 1 -b base36 --mc dag-pb)
|
||||
|
||||
# ed25519 fits under 63 char limit when represented in base36
|
||||
IPNS_ED25519_B58MH=$(ipfs key list -l --ipns-base b58mh | grep $KEY_NAME | cut -d" " -f1 | tr -d "\n")
|
||||
IPNS_ED25519_B36CID=$(ipfs key list -l --ipns-base base36 | grep $KEY_NAME | cut -d" " -f1 | tr -d "\n")
|
||||
|
||||
# publish a record valid for a 100 years
|
||||
ipfs name publish --key ${KEY_NAME} --allow-offline -Q --ttl=876600h --lifetime=876600h "/ipfs/$CIDv1"
|
||||
ipfs routing get /ipns/${ED25519_KEY} > ${ED25519_KEY}.ipns-record
|
||||
|
||||
echo ED25519_KEY=${ED25519_KEY}
|
||||
echo ED25519_IPNS_IDv0=${ED25519_IPNS_IDv0}
|
||||
echo ED25519_IPNS_IDv1=${ED25519_IPNS_IDv1}
|
||||
echo ED25519_IPNS_IDv1_DAGPB=${ED25519_IPNS_IDv1_DAGPB}
|
||||
echo IPNS_ED25519_B58MH=${IPNS_ED25519_B58MH}
|
||||
echo IPNS_ED25519_B36CID=${IPNS_ED25519_B36CID}
|
||||
|
||||
# CID_VAL=hello
|
||||
# CIDv1=bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am
|
||||
# CIDv0=QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN
|
||||
# CIDv0to1=bafybeiffndsajwhk3lwjewwdxqntmjm4b5wxaaanokonsggenkbw6slwk4
|
||||
# CIDv1_TOO_LONG=bafkrgqhhyivzstcz3hhswshfjgy6ertgmnqeleynhwt4dlfsthi4hn7zgh4uvlsb5xncykzapi3ocd4lzogukir6ksdy6wzrnz6ohnv4aglcs
|
||||
# DIR_CID=bafybeiht6dtwk3les7vqm6ibpvz6qpohidvlshsfyr7l5mpysdw2vmbbhe # ./testdirlisting
|
||||
|
||||
# RSA_KEY=QmVujd5Vb7moysJj8itnGufN7MEtPRCNHkKpNuA4onsRa3
|
||||
# RSA_IPNS_IDv0=QmVujd5Vb7moysJj8itnGufN7MEtPRCNHkKpNuA4onsRa3
|
||||
# RSA_IPNS_IDv1=k2k4r8m7xvggw5pxxk3abrkwyer625hg01hfyggrai7lk1m63fuihi7w
|
||||
# RSA_IPNS_IDv1_DAGPB=k2jmtxu61bnhrtj301lw7zizknztocdbeqhxgv76l2q9t36fn9jbzipo
|
||||
|
||||
# ED25519_KEY=12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d
|
||||
# ED25519_IPNS_IDv0=12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d
|
||||
# ED25519_IPNS_IDv1=k51qzi5uqu5dk3v4rmjber23h16xnr23bsggmqqil9z2gduiis5se8dht36dam
|
||||
# ED25519_IPNS_IDv1_DAGPB=k50rm9yjlt0jey4fqg6wafvqprktgbkpgkqdg27tpqje6iimzxewnhvtin9hhq
|
||||
# IPNS_ED25519_B58MH=12D3KooWLQzUv2FHWGVPXTXSZpdHs7oHbXub2G5WC8Tx4NQhyd2d
|
||||
# IPNS_ED25519_B36CID=k51qzi5uqu5dk3v4rmjber23h16xnr23bsggmqqil9z2gduiis5se8dht36dam
|
||||
```
|
||||
|
||||
@ -25,24 +25,18 @@ test_launch_ipfs_daemon_without_network
|
||||
# Caching of things like raw blocks, CARs, dag-json and dag-cbor
|
||||
# is tested in their respective suites.
|
||||
|
||||
# Import test case
|
||||
# See the static fixtures in ./t0116-gateway-cache/
|
||||
test_expect_success "Add the test directory" '
|
||||
ipfs dag import ../t0116-gateway-cache/fixtures.car
|
||||
'
|
||||
ROOT1_CID=bafybeib3ffl2teiqdncv3mkz4r23b5ctrwkzrrhctdbne6iboayxuxk5ui # ./
|
||||
ROOT2_CID=bafybeih2w7hjocxjg6g2ku25hvmd53zj7og4txpby3vsusfefw5rrg5sii # ./root2
|
||||
ROOT3_CID=bafybeiawdvhmjcz65x5egzx4iukxc72hg4woks6v6fvgyupiyt3oczk5ja # ./root2/root3
|
||||
ROOT4_CID=bafybeifq2rzpqnqrsdupncmkmhs3ckxxjhuvdcbvydkgvch3ms24k5lo7q # ./root2/root3/root4
|
||||
FILE_CID=bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am # ./root2/root3/root4/index.html
|
||||
TEST_IPNS_ID=k51qzi5uqu5dlxdsdu5fpuu7h69wu4ohp32iwm9pdt9nq3y5rpn3ln9j12zfhe
|
||||
|
||||
test_expect_success "Prepare IPNS unixfs content path for testing" '
|
||||
TEST_IPNS_ID=$(ipfs key gen --ipns-base=base36 --type=ed25519 cache_test_key | head -n1 | tr -d "\n")
|
||||
ipfs name publish --key cache_test_key --allow-offline -Q "/ipfs/$ROOT1_CID" > name_publish_out &&
|
||||
test_check_peerid "${TEST_IPNS_ID}" &&
|
||||
ipfs name resolve "${TEST_IPNS_ID}" > output &&
|
||||
printf "/ipfs/%s\n" "$ROOT1_CID" > expected &&
|
||||
test_cmp expected output
|
||||
# Import test case
|
||||
# See the static fixtures in ./t0116-gateway-cache/
|
||||
test_expect_success "Add the test directory" '
|
||||
ipfs dag import ../t0116-gateway-cache/fixtures.car
|
||||
ipfs routing put --allow-offline /ipns/${TEST_IPNS_ID} ../t0116-gateway-cache/${TEST_IPNS_ID}.ipns-record
|
||||
'
|
||||
|
||||
# GET /ipfs/
|
||||
|
||||
@ -6,7 +6,8 @@
|
||||
generated with:
|
||||
|
||||
```sh
|
||||
# using ipfs version 0.18.1
|
||||
# using ipfs version 0.21.0-dev (03a98280e3e642774776cd3d0435ab53e5dfa867)
|
||||
|
||||
mkdir -p root2/root3/root4 &&
|
||||
echo "hello" > root2/root3/root4/index.html &&
|
||||
ROOT1_CID=$(ipfs add -Qrw --cid-version 1 root2)
|
||||
@ -15,11 +16,17 @@ ROOT3_CID=$(ipfs resolve -r /ipfs/$ROOT1_CID/root2/root3 | cut -d "/" -f3)
|
||||
ROOT4_CID=$(ipfs resolve -r /ipfs/$ROOT1_CID/root2/root3/root4 | cut -d "/" -f3)
|
||||
FILE_CID=$(ipfs resolve -r /ipfs/$ROOT1_CID/root2/root3/root4/index.html | cut -d "/" -f3)
|
||||
|
||||
echo ROOT1_CID=${ROOT1_CID}
|
||||
echo ROOT2_CID=${ROOT2_CID}
|
||||
echo ROOT3_CID=${ROOT3_CID}
|
||||
echo ROOT4_CID=${ROOT4_CID}
|
||||
echo FILE_CID=${FILE_CID}
|
||||
TEST_IPNS_ID=$(ipfs key gen --ipns-base=base36 --type=ed25519 cache_test_key | head -n1 | tr -d "\n")
|
||||
# publish a record valid for a 100 years
|
||||
ipfs name publish --key cache_test_key --allow-offline -Q --ttl=876600h --lifetime=876600h "/ipfs/$ROOT1_CID"
|
||||
ipfs routing get /ipns/${TEST_IPNS_ID} > ${TEST_IPNS_ID}.ipns-record
|
||||
|
||||
echo ROOT1_CID=${ROOT1_CID} # ./
|
||||
echo ROOT2_CID=${ROOT2_CID} # ./root2
|
||||
echo ROOT3_CID=${ROOT3_CID} # ./root2/root3
|
||||
echo ROOT4_CID=${ROOT4_CID} # ./root2/root3/root4
|
||||
echo FILE_CID=${FILE_CID} # ./root2/root3/root4/index.html
|
||||
echo TEST_IPNS_ID=${TEST_IPNS_ID}
|
||||
|
||||
ipfs dag export ${ROOT1_CID} > ./fixtures.car
|
||||
|
||||
@ -28,4 +35,5 @@ ipfs dag export ${ROOT1_CID} > ./fixtures.car
|
||||
# ROOT3_CID=bafybeiawdvhmjcz65x5egzx4iukxc72hg4woks6v6fvgyupiyt3oczk5ja # ./root2/root3
|
||||
# ROOT4_CID=bafybeifq2rzpqnqrsdupncmkmhs3ckxxjhuvdcbvydkgvch3ms24k5lo7q # ./root2/root3/root4
|
||||
# FILE_CID=bafkreicysg23kiwv34eg2d7qweipxwosdo2py4ldv42nbauguluen5v6am # ./root2/root3/root4/index.html
|
||||
# TEST_IPNS_ID=k51qzi5uqu5dlxdsdu5fpuu7h69wu4ohp32iwm9pdt9nq3y5rpn3ln9j12zfhe
|
||||
```
|
||||
|
||||
Binary file not shown.
@ -163,6 +163,14 @@ test_expect_success "Add CARs for path traversal and DAG-PB representation tests
|
||||
test_should_contain $DAG_PB_CID import_output
|
||||
'
|
||||
|
||||
IPNS_ID_DAG_JSON=k51qzi5uqu5dhjghbwdvbo6mi40htrq6e2z4pwgp15pgv3ho1azvidttzh8yy2
|
||||
IPNS_ID_DAG_CBOR=k51qzi5uqu5dghjous0agrwavl8vzl64xckoqzwqeqwudfr74kfd11zcyk3b7l
|
||||
|
||||
test_expect_success "Add ipns records for path traversal and DAG-PB representation tests" '
|
||||
ipfs routing put --allow-offline /ipns/${IPNS_ID_DAG_JSON} ../t0123-gateway-json-cbor/${IPNS_ID_DAG_JSON}.ipns-record &&
|
||||
ipfs routing put --allow-offline /ipns/${IPNS_ID_DAG_CBOR} ../t0123-gateway-json-cbor/${IPNS_ID_DAG_CBOR}.ipns-record
|
||||
'
|
||||
|
||||
test_expect_success "GET DAG-JSON traversal returns 501 if there is path remainder" '
|
||||
curl -sD - "http://127.0.0.1:$GWAY_PORT/ipfs/$DAG_JSON_TRAVERSAL_CID/foo?format=dag-json" > curl_output 2>&1 &&
|
||||
test_should_contain "501 Not Implemented" curl_output &&
|
||||
@ -197,6 +205,7 @@ test_native_dag () {
|
||||
format=$2
|
||||
disposition=$3
|
||||
CID=$4
|
||||
IPNS_ID=$5
|
||||
|
||||
# GET without explicit format and Accept: text/html returns raw block
|
||||
|
||||
@ -313,15 +322,6 @@ test_native_dag () {
|
||||
# IPNS behavior (should be same as immutable /ipfs, but with different caching headers)
|
||||
# To keep tests small we only confirm payload is the same, and then only test delta around caching headers.
|
||||
|
||||
test_expect_success "Prepare IPNS with dag-$format" '
|
||||
IPNS_ID=$(ipfs key gen --ipns-base=base36 --type=ed25519 ${format}_test_key | head -n1 | tr -d "\n") &&
|
||||
ipfs name publish --key ${format}_test_key --allow-offline -Q "/ipfs/$CID" > name_publish_out &&
|
||||
test_check_peerid "${IPNS_ID}" &&
|
||||
ipfs name resolve "${IPNS_ID}" > output &&
|
||||
printf "/ipfs/%s\n" "$CID" > expected &&
|
||||
test_cmp expected output
|
||||
'
|
||||
|
||||
test_expect_success "GET $name from /ipns without explicit format returns the same payload as /ipfs" '
|
||||
curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipfs/$CID" -o ipfs_output &&
|
||||
curl -sX GET "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_ID" -o ipns_output &&
|
||||
@ -369,8 +369,8 @@ test_native_dag () {
|
||||
|
||||
}
|
||||
|
||||
test_native_dag "DAG-JSON" "json" "inline" "$DAG_JSON_TRAVERSAL_CID"
|
||||
test_native_dag "DAG-CBOR" "cbor" "attachment" "$DAG_CBOR_TRAVERSAL_CID"
|
||||
test_native_dag "DAG-JSON" "json" "inline" "$DAG_JSON_TRAVERSAL_CID" ${IPNS_ID_DAG_JSON}
|
||||
test_native_dag "DAG-CBOR" "cbor" "attachment" "$DAG_CBOR_TRAVERSAL_CID" ${IPNS_ID_DAG_CBOR}
|
||||
|
||||
test_kill_ipfs_daemon
|
||||
|
||||
|
||||
@ -14,7 +14,8 @@
|
||||
generated with:
|
||||
|
||||
```sh
|
||||
# using ipfs version 0.18.1
|
||||
# using ipfs version 0.21.0-dev (03a98280e3e642774776cd3d0435ab53e5dfa867)
|
||||
|
||||
mkdir -p rootDir/ipfs &&
|
||||
mkdir -p rootDir/ipns &&
|
||||
mkdir -p rootDir/api &&
|
||||
@ -37,8 +38,29 @@ echo FILE_SIZE=${FILE_SIZE}
|
||||
|
||||
ipfs dag export ${DIR_CID} > fixtures.car
|
||||
|
||||
DAG_CBOR_TRAVERSAL_CID="bafyreibs4utpgbn7uqegmd2goqz4bkyflre2ek2iwv743fhvylwi4zeeim"
|
||||
DAG_JSON_TRAVERSAL_CID="baguqeeram5ujjqrwheyaty3w5gdsmoz6vittchvhk723jjqxk7hakxkd47xq"
|
||||
DAG_PB_CID="bafybeiegxwlgmoh2cny7qlolykdf7aq7g6dlommarldrbm7c4hbckhfcke"
|
||||
|
||||
test_native_dag() {
|
||||
NAME=$1
|
||||
CID=$2
|
||||
|
||||
IPNS_ID=$(ipfs key gen --ipns-base=base36 --type=ed25519 ${NAME}_test_key | head -n1 | tr -d "\n")
|
||||
ipfs name publish --key ${NAME}_test_key --allow-offline --ttl=876600h --lifetime=876600h -Q "/ipfs/${CID}" > name_publish_out
|
||||
|
||||
ipfs routing get /ipns/${IPNS_ID} > ${IPNS_ID}.ipns-record
|
||||
|
||||
echo "IPNS_ID_${NAME}=${IPNS_ID}"
|
||||
}
|
||||
|
||||
test_native_dag "DAG_JSON" "$DAG_JSON_TRAVERSAL_CID"
|
||||
test_native_dag "DAG_CBOR" "$DAG_CBOR_TRAVERSAL_CID"
|
||||
|
||||
# DIR_CID=bafybeiafyvqlazbbbtjnn6how5d6h6l6rxbqc4qgpbmteaiskjrffmyy4a # ./rootDir
|
||||
# FILE_JSON_CID=bafkreibrppizs3g7axs2jdlnjua6vgpmltv7k72l7v7sa6mmht6mne3qqe # ./rootDir/ą/ę/t.json
|
||||
# FILE_CID=bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm # ./rootDir/ą/ę/file-źł.txt
|
||||
# FILE_SIZE=34
|
||||
# IPNS_ID_DAG_JSON=k51qzi5uqu5dhjghbwdvbo6mi40htrq6e2z4pwgp15pgv3ho1azvidttzh8yy2
|
||||
# IPNS_ID_DAG_CBOR=k51qzi5uqu5dghjous0agrwavl8vzl64xckoqzwqeqwudfr74kfd11zcyk3b7l
|
||||
```
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -7,10 +7,16 @@ test_description="Test HTTP Gateway IPNS Record (application/vnd.ipfs.ipns-recor
|
||||
test_init_ipfs
|
||||
test_launch_ipfs_daemon
|
||||
|
||||
# Import test case
|
||||
# See the static fixtures in ./t0124-gateway-ipns-record/
|
||||
IPNS_KEY=k51qzi5uqu5dh71qgwangrt6r0nd4094i88nsady6qgd1dhjcyfsaqmpp143ab
|
||||
FILE_CID=bafkreidfdrlkeq4m4xnxuyx6iae76fdm4wgl5d4xzsb77ixhyqwumhz244 # A file containing Hello IPFS
|
||||
test_expect_success "Add the test directory & IPNS records" '
|
||||
ipfs dag import ../t0124-gateway-ipns-record/fixtures.car &&
|
||||
ipfs routing put /ipns/${IPNS_KEY} ../t0124-gateway-ipns-record/${IPNS_KEY}.ipns-record
|
||||
'
|
||||
|
||||
test_expect_success "Create and Publish IPNS Key" '
|
||||
FILE_CID=$(echo "Hello IPFS" | ipfs add --cid-version 1 -q) &&
|
||||
IPNS_KEY=$(ipfs key gen ipns-record) &&
|
||||
ipfs name publish /ipfs/$FILE_CID --key=ipns-record --ttl=30m &&
|
||||
curl "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_KEY" > curl_output_filename &&
|
||||
test_should_contain "Hello IPFS" curl_output_filename
|
||||
'
|
||||
@ -31,14 +37,14 @@ test_expect_success "GET KEY with format=ipns-record has expected HTTP headers"
|
||||
curl -sD - "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_KEY?format=ipns-record" > curl_output_filename 2>&1 &&
|
||||
test_should_contain "Content-Disposition: attachment;" curl_output_filename &&
|
||||
test_should_contain "Content-Type: application/vnd.ipfs.ipns-record" curl_output_filename &&
|
||||
test_should_contain "Cache-Control: public, max-age=1800" curl_output_filename
|
||||
test_should_contain "Cache-Control: public, max-age=3155760000" curl_output_filename
|
||||
'
|
||||
|
||||
test_expect_success "GET KEY with 'Accept: application/vnd.ipfs.ipns-record' has expected HTTP headers" '
|
||||
curl -H "Accept: application/vnd.ipfs.ipns-record" -sD - "http://127.0.0.1:$GWAY_PORT/ipns/$IPNS_KEY" > curl_output_filename 2>&1 &&
|
||||
test_should_contain "Content-Disposition: attachment;" curl_output_filename &&
|
||||
test_should_contain "Content-Type: application/vnd.ipfs.ipns-record" curl_output_filename &&
|
||||
test_should_contain "Cache-Control: public, max-age=1800" curl_output_filename
|
||||
test_should_contain "Cache-Control: public, max-age=3155760000" curl_output_filename
|
||||
'
|
||||
|
||||
test_expect_success "GET KEY with expliciy ?filename= succeeds with modified Content-Disposition header" '
|
||||
|
||||
27
test/sharness/t0124-gateway-ipns-record/README.md
Normal file
27
test/sharness/t0124-gateway-ipns-record/README.md
Normal file
@ -0,0 +1,27 @@
|
||||
# Dataset description/sources
|
||||
|
||||
- fixtures.car
|
||||
- raw CARv1
|
||||
|
||||
- k51....ipns-record
|
||||
- ipns record, encoded with protocol buffer
|
||||
|
||||
generated with:
|
||||
|
||||
```sh
|
||||
# using ipfs version 0.21.0-dev (03a98280e3e642774776cd3d0435ab53e5dfa867)
|
||||
FILE_CID=$(echo "Hello IPFS" | ipfs add --cid-version 1 -q)
|
||||
IPNS_KEY=$(ipfs key gen ipns-record)
|
||||
|
||||
ipfs dag export ${FILE_CID} > fixtures.car
|
||||
|
||||
# publish a record valid for a 100 years
|
||||
ipfs name publish --key=ipns-record --quieter --ttl=876600h --lifetime=876600h /ipfs/${FILE_CID}
|
||||
ipfs routing get /ipns/${IPNS_KEY} > ${IPNS_KEY}.ipns-record
|
||||
|
||||
echo IPNS_KEY=${IPNS_KEY}
|
||||
echo FILE_CID=${FILE_CID} # A file containing "Hello IPFS"
|
||||
|
||||
# IPNS_KEY=k51qzi5uqu5dh71qgwangrt6r0nd4094i88nsady6qgd1dhjcyfsaqmpp143ab
|
||||
# FILE_CID=bafkreidfdrlkeq4m4xnxuyx6iae76fdm4wgl5d4xzsb77ixhyqwumhz244 # A file containing Hello IPFS
|
||||
```
|
||||
BIN
test/sharness/t0124-gateway-ipns-record/fixtures.car
Normal file
BIN
test/sharness/t0124-gateway-ipns-record/fixtures.car
Normal file
Binary file not shown.
Binary file not shown.
@ -11,7 +11,7 @@ import (
|
||||
var CurrentCommit string
|
||||
|
||||
// CurrentVersionNumber is the current application's version literal
|
||||
const CurrentVersionNumber = "0.20.0"
|
||||
const CurrentVersionNumber = "0.21.0-dev"
|
||||
|
||||
const ApiVersion = "/kubo/" + CurrentVersionNumber + "/" //nolint
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user