diff --git a/test/integration/ipdr/main.go b/test/integration/ipdr/main.go deleted file mode 100644 index ae853c80..00000000 --- a/test/integration/ipdr/main.go +++ /dev/null @@ -1,94 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0 - -package main - -import ( - "context" - "fmt" - "os" - - "github.com/comrade-coop/apocryph/pkg/crypto" - tpipdr "github.com/comrade-coop/apocryph/pkg/ipdr" - tpipfs "github.com/comrade-coop/apocryph/pkg/ipfs" - pb "github.com/comrade-coop/apocryph/pkg/proto" - imageCopy "github.com/containers/image/v5/copy" - "github.com/containers/image/v5/signature" - "github.com/containers/image/v5/transports" - "github.com/containers/image/v5/transports/alltransports" - "github.com/containers/image/v5/types" -) - -func main() { - err := mainErr() - if err != nil { - fmt.Printf("error %v\n", err) - os.Exit(1) - } -} - -func mainErr() error { - ipfs, _, err := tpipfs.GetIpfsClient("") - if err != nil { - return err - } - transports.Register(tpipdr.NewIpdrTransport(ipfs)) - - srcImageReference, err := alltransports.ParseImageName(os.Args[1]) - if err != nil { - return err - } - - dstImageReference, err := alltransports.ParseImageName(os.Args[2]) - if err != nil { - return err - } - - copyOptions := &imageCopy.Options{ - DestinationCtx: &types.SystemContext{}, - SourceCtx: &types.SystemContext{}, - } - - if len(os.Args) > 3 { - key := &pb.Key{} - err := pb.UnmarshalFile(os.Args[3], "", key) - if err != nil || len(key.Data) == 0 { - key, err = crypto.NewKey(crypto.KeyTypeOcicrypt) - if err != nil { - return err - } - err = pb.MarshalFile(os.Args[3], "", key) - if err != nil { - return err - } - } - - cryptoConfig, err := crypto.GetCryptoConfigKey(key) - if err != nil { - return err - } - - copyOptions.OciEncryptConfig = cryptoConfig.EncryptConfig - copyOptions.OciDecryptConfig = cryptoConfig.DecryptConfig - if dstImageReference.Transport().Name() == "ipdr" { - copyOptions.OciEncryptLayers = &[]int{} - } - } - - policy, err := signature.DefaultPolicy(nil) - if err != nil { - return err - } - - pc, _ := signature.NewPolicyContext(policy) - defer pc.Destroy() - - _, err = imageCopy.Image(context.Background(), pc, dstImageReference, srcImageReference, copyOptions) - if err != nil { - return err - } - - fmt.Println("Written image to:") - fmt.Println(transports.ImageName(dstImageReference)) - - return nil -} diff --git a/test/integration/ipdr/run-test.sh b/test/integration/ipdr/run-test.sh deleted file mode 100755 index ac1d2c55..00000000 --- a/test/integration/ipdr/run-test.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: GPL-3.0 - -set -e - -trap 'kill $(jobs -p) &>/dev/null' EXIT - -cd "$(dirname "$0")" - -which go >/dev/null -which ipfs >/dev/null -which docker >/dev/null -which jq >/dev/null - -set -v - -ipfs daemon >/dev/null || true & -{ while ! [ -f ${IPFS_PATH:-~/.ipfs}/api ]; do sleep 0.5; done; } 2>/dev/null - -docker image pull hello-world - -## 1. Test docker daemon <-> our IPDR - -docker image rm hello-world-copy &>/dev/null || true - -RUN_OUTPUT=$(mktemp) -go run . docker-daemon:hello-world:latest ipdr: | tee $RUN_OUTPUT -IPDR_REFERENCE=$(tail -n 1 $RUN_OUTPUT) -go run . "$IPDR_REFERENCE" docker-daemon:hello-world-copy:latest - -diff <(docker image inspect hello-world | jq '.[].RootFS') <(docker image inspect hello-world-copy | jq '.[].RootFS') -q - -## 2. Test docker daemon <-> our IPDR (encrypted) - -docker image rm hello-world-copy &>/dev/null || true - -RUN_OUTPUT=$(mktemp) -KEY_FILE=$(mktemp --suffix=".json"); echo $KEY_FILE -go run . docker-daemon:hello-world:latest ipdr: "$KEY_FILE" | tee $RUN_OUTPUT - -IPDR_REFERENCE=$(tail -n 1 $RUN_OUTPUT) - -go run . "$IPDR_REFERENCE" docker-daemon:hello-world-copy:latest "$KEY_FILE" - -diff <(docker image inspect hello-world | jq '.[].RootFS') <(docker image inspect hello-world-copy | jq '.[].RootFS') -q - -## 3. Test docker daemon -> orig IPDR -> our IPDR -> docker daemon - -which ipdr >/dev/null # Rest of the test checks for compatibility with ipdr - -docker image rm hello-world-copy &>/dev/null || true - -IPDR_OUTPUT=$(mktemp) -ipdr push hello-world | tee $IPDR_OUTPUT -IPDR_REFERENCE_2=$(tail -n 1 $IPDR_OUTPUT) -go run . "ipdr:$IPDR_REFERENCE_2" docker-daemon:hello-world-copy:latest - -diff <(docker image inspect hello-world | jq '.[].RootFS') <(docker image inspect hello-world-copy | jq '.[].RootFS') -q - -## 4. Test docker daemon -> our IPDR -> orig IPDR -> docker daemon -# ipdr pull "$IPDR_REFERENCE" - ipdr pull is rather buggy and not quite testable, sadly. Maybe when they fix it one day - -## 5. - -echo success! - -kill $(jobs -p) &>/dev/null