Merge daemon_unit_test.go to daemon_test.go
| ... | ... |
@@ -11,6 +11,7 @@ import ( |
| 11 | 11 |
"github.com/docker/docker/pkg/graphdb" |
| 12 | 12 |
"github.com/docker/docker/pkg/stringid" |
| 13 | 13 |
"github.com/docker/docker/pkg/truncindex" |
| 14 |
+ "github.com/docker/docker/runconfig" |
|
| 14 | 15 |
"github.com/docker/docker/volume" |
| 15 | 16 |
"github.com/docker/docker/volume/drivers" |
| 16 | 17 |
"github.com/docker/docker/volume/local" |
| ... | ... |
@@ -514,3 +515,35 @@ func initDaemonForVolumesTest(tmp string) (*Daemon, error) {
|
| 514 | 514 |
|
| 515 | 515 |
return daemon, nil |
| 516 | 516 |
} |
| 517 |
+ |
|
| 518 |
+func TestParseSecurityOpt(t *testing.T) {
|
|
| 519 |
+ container := &Container{}
|
|
| 520 |
+ config := &runconfig.HostConfig{}
|
|
| 521 |
+ |
|
| 522 |
+ // test apparmor |
|
| 523 |
+ config.SecurityOpt = []string{"apparmor:test_profile"}
|
|
| 524 |
+ if err := parseSecurityOpt(container, config); err != nil {
|
|
| 525 |
+ t.Fatalf("Unexpected parseSecurityOpt error: %v", err)
|
|
| 526 |
+ } |
|
| 527 |
+ if container.AppArmorProfile != "test_profile" {
|
|
| 528 |
+ t.Fatalf("Unexpected AppArmorProfile, expected: \"test_profile\", got %q", container.AppArmorProfile)
|
|
| 529 |
+ } |
|
| 530 |
+ |
|
| 531 |
+ // test valid label |
|
| 532 |
+ config.SecurityOpt = []string{"label:user:USER"}
|
|
| 533 |
+ if err := parseSecurityOpt(container, config); err != nil {
|
|
| 534 |
+ t.Fatalf("Unexpected parseSecurityOpt error: %v", err)
|
|
| 535 |
+ } |
|
| 536 |
+ |
|
| 537 |
+ // test invalid label |
|
| 538 |
+ config.SecurityOpt = []string{"label"}
|
|
| 539 |
+ if err := parseSecurityOpt(container, config); err == nil {
|
|
| 540 |
+ t.Fatal("Expected parseSecurityOpt error, got nil")
|
|
| 541 |
+ } |
|
| 542 |
+ |
|
| 543 |
+ // test invalid opt |
|
| 544 |
+ config.SecurityOpt = []string{"test"}
|
|
| 545 |
+ if err := parseSecurityOpt(container, config); err == nil {
|
|
| 546 |
+ t.Fatal("Expected parseSecurityOpt error, got nil")
|
|
| 547 |
+ } |
|
| 548 |
+} |
| 517 | 549 |
deleted file mode 100644 |
| ... | ... |
@@ -1,39 +0,0 @@ |
| 1 |
-package daemon |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "testing" |
|
| 5 |
- |
|
| 6 |
- "github.com/docker/docker/runconfig" |
|
| 7 |
-) |
|
| 8 |
- |
|
| 9 |
-func TestParseSecurityOpt(t *testing.T) {
|
|
| 10 |
- container := &Container{}
|
|
| 11 |
- config := &runconfig.HostConfig{}
|
|
| 12 |
- |
|
| 13 |
- // test apparmor |
|
| 14 |
- config.SecurityOpt = []string{"apparmor:test_profile"}
|
|
| 15 |
- if err := parseSecurityOpt(container, config); err != nil {
|
|
| 16 |
- t.Fatalf("Unexpected parseSecurityOpt error: %v", err)
|
|
| 17 |
- } |
|
| 18 |
- if container.AppArmorProfile != "test_profile" {
|
|
| 19 |
- t.Fatalf("Unexpected AppArmorProfile, expected: \"test_profile\", got %q", container.AppArmorProfile)
|
|
| 20 |
- } |
|
| 21 |
- |
|
| 22 |
- // test valid label |
|
| 23 |
- config.SecurityOpt = []string{"label:user:USER"}
|
|
| 24 |
- if err := parseSecurityOpt(container, config); err != nil {
|
|
| 25 |
- t.Fatalf("Unexpected parseSecurityOpt error: %v", err)
|
|
| 26 |
- } |
|
| 27 |
- |
|
| 28 |
- // test invalid label |
|
| 29 |
- config.SecurityOpt = []string{"label"}
|
|
| 30 |
- if err := parseSecurityOpt(container, config); err == nil {
|
|
| 31 |
- t.Fatal("Expected parseSecurityOpt error, got nil")
|
|
| 32 |
- } |
|
| 33 |
- |
|
| 34 |
- // test invalid opt |
|
| 35 |
- config.SecurityOpt = []string{"test"}
|
|
| 36 |
- if err := parseSecurityOpt(container, config); err == nil {
|
|
| 37 |
- t.Fatal("Expected parseSecurityOpt error, got nil")
|
|
| 38 |
- } |
|
| 39 |
-} |