Browse code

integration-cli: test load/import with authz plugins

Signed-off-by: Antonio Murdaca <runcom@redhat.com>

Antonio Murdaca authored on 2016/05/05 01:42:36
Showing 1 changed files
... ...
@@ -9,6 +9,7 @@ import (
9 9
 	"net/http"
10 10
 	"net/http/httptest"
11 11
 	"os"
12
+	"path/filepath"
12 13
 	"strings"
13 14
 
14 15
 	"bufio"
... ...
@@ -17,13 +18,14 @@ import (
17 17
 	"strconv"
18 18
 	"time"
19 19
 
20
+	"net"
21
+	"net/http/httputil"
22
+	"net/url"
23
+
20 24
 	"github.com/docker/docker/pkg/authorization"
21 25
 	"github.com/docker/docker/pkg/integration/checker"
22 26
 	"github.com/docker/docker/pkg/plugins"
23 27
 	"github.com/go-check/check"
24
-	"net"
25
-	"net/http/httputil"
26
-	"net/url"
27 28
 )
28 29
 
29 30
 const (
... ...
@@ -415,6 +417,33 @@ func (s *DockerAuthzSuite) TestAuthZPluginEnsureNoDuplicatePluginRegistration(c
415 415
 	c.Assert(s.ctrl.psResponseCnt, check.Equals, 1)
416 416
 }
417 417
 
418
+func (s *DockerAuthzSuite) TestAuthZPluginEnsureLoadImportWorking(c *check.C) {
419
+	c.Assert(s.d.Start("--authorization-plugin="+testAuthZPlugin, "--authorization-plugin="+testAuthZPlugin), check.IsNil)
420
+	s.ctrl.reqRes.Allow = true
421
+	s.ctrl.resRes.Allow = true
422
+	c.Assert(s.d.LoadBusybox(), check.IsNil)
423
+
424
+	tmp, err := ioutil.TempDir("", "test-authz-load-import")
425
+	c.Assert(err, check.IsNil)
426
+	defer os.RemoveAll(tmp)
427
+
428
+	savedImagePath := filepath.Join(tmp, "save.tar")
429
+
430
+	out, err := s.d.Cmd("save", "-o", savedImagePath, "busybox")
431
+	c.Assert(err, check.IsNil, check.Commentf(out))
432
+	out, err = s.d.Cmd("load", "--input", savedImagePath)
433
+	c.Assert(err, check.IsNil, check.Commentf(out))
434
+
435
+	exportedImagePath := filepath.Join(tmp, "export.tar")
436
+
437
+	out, err = s.d.Cmd("run", "-d", "--name", "testexport", "busybox")
438
+	c.Assert(err, check.IsNil, check.Commentf(out))
439
+	out, err = s.d.Cmd("export", "-o", exportedImagePath, "testexport")
440
+	c.Assert(err, check.IsNil, check.Commentf(out))
441
+	out, err = s.d.Cmd("import", exportedImagePath)
442
+	c.Assert(err, check.IsNil, check.Commentf(out))
443
+}
444
+
418 445
 // assertURIRecorded verifies that the given URI was sent and recorded in the authz plugin
419 446
 func assertURIRecorded(c *check.C, uris []string, uri string) {
420 447
 	var found bool