github.com/ralexstokes/docker@v1.6.2/daemon/daemon_unit_test.go (about) 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 }