summaryrefslogtreecommitdiff
path: root/pkg/bindings/test/manifests_test.go
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2020-03-04 10:14:07 -0600
committerBrent Baude <bbaude@redhat.com>2020-03-16 10:03:55 -0500
commitabbbeacd68b4d4973a55a8d7263bd0a27f5c4e8e (patch)
treed0612ea3340bb61cafbf2dfd52897dcfec4adbc1 /pkg/bindings/test/manifests_test.go
parent9c7481dbd1e6ea7e20ee03c85d4710c42ba81c6e (diff)
downloadpodman-abbbeacd68b4d4973a55a8d7263bd0a27f5c4e8e.tar.gz
podman-abbbeacd68b4d4973a55a8d7263bd0a27f5c4e8e.tar.bz2
podman-abbbeacd68b4d4973a55a8d7263bd0a27f5c4e8e.zip
apiv2 addition of manifests
add endpoints for create, add, remove, inspect, and push. this allows manifests to be managed through the restful interfaces. also added go-bindings and tests Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/bindings/test/manifests_test.go')
-rw-r--r--pkg/bindings/test/manifests_test.go124
1 files changed, 124 insertions, 0 deletions
diff --git a/pkg/bindings/test/manifests_test.go b/pkg/bindings/test/manifests_test.go
new file mode 100644
index 000000000..23c3d8194
--- /dev/null
+++ b/pkg/bindings/test/manifests_test.go
@@ -0,0 +1,124 @@
+package test_bindings
+
+import (
+ "net/http"
+ "time"
+
+ "github.com/containers/libpod/libpod/image"
+ "github.com/containers/libpod/pkg/bindings"
+ "github.com/containers/libpod/pkg/bindings/images"
+ "github.com/containers/libpod/pkg/bindings/manifests"
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gexec"
+)
+
+var _ = Describe("Podman containers ", func() {
+ var (
+ bt *bindingTest
+ s *gexec.Session
+ )
+
+ BeforeEach(func() {
+ bt = newBindingTest()
+ bt.RestoreImagesFromCache()
+ s = bt.startAPIService()
+ time.Sleep(1 * time.Second)
+ err := bt.NewConnection()
+ Expect(err).To(BeNil())
+ })
+
+ AfterEach(func() {
+ s.Kill()
+ bt.cleanup()
+ })
+
+ It("create manifest", func() {
+ // create manifest list without images
+ id, err := manifests.Create(bt.conn, []string{"quay.io/libpod/foobar:latest"}, []string{}, nil)
+ Expect(err).To(BeNil())
+ list, err := manifests.Inspect(bt.conn, id)
+ Expect(err).To(BeNil())
+ Expect(len(list.Manifests)).To(BeZero())
+
+ // creating a duplicate should fail as a 500
+ _, err = manifests.Create(bt.conn, []string{"quay.io/libpod/foobar:latest"}, []string{}, nil)
+ Expect(err).ToNot(BeNil())
+ code, _ := bindings.CheckResponseCode(err)
+ Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
+
+ _, err = images.Remove(bt.conn, id, nil)
+ Expect(err).To(BeNil())
+
+ // create manifest list with images
+ id, err = manifests.Create(bt.conn, []string{"quay.io/libpod/foobar:latest"}, []string{alpine.name}, nil)
+ Expect(err).To(BeNil())
+ list, err = manifests.Inspect(bt.conn, id)
+ Expect(err).To(BeNil())
+ Expect(len(list.Manifests)).To(BeNumerically("==", 1))
+ })
+
+ It("inspect bogus manifest", func() {
+ _, err := manifests.Inspect(bt.conn, "larry")
+ Expect(err).ToNot(BeNil())
+ code, _ := bindings.CheckResponseCode(err)
+ Expect(code).To(BeNumerically("==", http.StatusNotFound))
+ })
+
+ It("add manifest", func() {
+ // add to bogus should 404
+ _, err := manifests.Add(bt.conn, "foobar", image.ManifestAddOpts{})
+ Expect(err).ToNot(BeNil())
+ code, _ := bindings.CheckResponseCode(err)
+ Expect(code).To(BeNumerically("==", http.StatusNotFound))
+
+ id, err := manifests.Create(bt.conn, []string{"quay.io/libpod/foobar:latest"}, []string{}, nil)
+ Expect(err).To(BeNil())
+ opts := image.ManifestAddOpts{Images: []string{alpine.name}}
+ _, err = manifests.Add(bt.conn, id, opts)
+ Expect(err).To(BeNil())
+ list, err := manifests.Inspect(bt.conn, id)
+ Expect(err).To(BeNil())
+ Expect(len(list.Manifests)).To(BeNumerically("==", 1))
+
+ // add bogus name to existing list should fail
+ opts.Images = []string{"larry"}
+ _, err = manifests.Add(bt.conn, id, opts)
+ Expect(err).ToNot(BeNil())
+ code, _ = bindings.CheckResponseCode(err)
+ Expect(code).To(BeNumerically("==", http.StatusInternalServerError))
+ })
+
+ It("remove manifest", func() {
+ // removal on bogus manifest list should be 404
+ _, err := manifests.Remove(bt.conn, "larry", "1234")
+ Expect(err).ToNot(BeNil())
+ code, _ := bindings.CheckResponseCode(err)
+ Expect(code).To(BeNumerically("==", http.StatusNotFound))
+
+ id, err := manifests.Create(bt.conn, []string{"quay.io/libpod/foobar:latest"}, []string{alpine.name}, nil)
+ Expect(err).To(BeNil())
+ data, err := manifests.Inspect(bt.conn, id)
+ Expect(err).To(BeNil())
+ Expect(len(data.Manifests)).To(BeNumerically("==", 1))
+
+ // removal on a good manifest list with a bad digest should be 400
+ _, err = manifests.Remove(bt.conn, id, "!234")
+ Expect(err).ToNot(BeNil())
+ code, _ = bindings.CheckResponseCode(err)
+ Expect(code).To(BeNumerically("==", http.StatusBadRequest))
+
+ digest := data.Manifests[0].Digest.String()
+ _, err = manifests.Remove(bt.conn, id, digest)
+ Expect(err).To(BeNil())
+
+ // removal on good manifest with good digest should work
+ data, err = manifests.Inspect(bt.conn, id)
+ Expect(err).To(BeNil())
+ Expect(len(data.Manifests)).To(BeZero())
+ })
+
+ It("push manifest", func() {
+ Skip("TODO")
+ })
+})