(t *testing.T)
| 670 | } |
| 671 | |
| 672 | func TestConvertServiceCapAddAndCapDrop(t *testing.T) { |
| 673 | tests := []struct { |
| 674 | title string |
| 675 | in, out composetypes.ServiceConfig |
| 676 | }{ |
| 677 | { |
| 678 | title: "default behavior", |
| 679 | }, |
| 680 | { |
| 681 | title: "some values", |
| 682 | in: composetypes.ServiceConfig{ |
| 683 | CapAdd: []string{"SYS_NICE", "CAP_NET_ADMIN"}, |
| 684 | CapDrop: []string{"CHOWN", "CAP_NET_ADMIN", "DAC_OVERRIDE", "CAP_FSETID", "CAP_FOWNER"}, |
| 685 | }, |
| 686 | out: composetypes.ServiceConfig{ |
| 687 | CapAdd: []string{"CAP_NET_ADMIN", "CAP_SYS_NICE"}, |
| 688 | CapDrop: []string{"CAP_CHOWN", "CAP_DAC_OVERRIDE", "CAP_FOWNER", "CAP_FSETID"}, |
| 689 | }, |
| 690 | }, |
| 691 | { |
| 692 | title: "adding ALL capabilities", |
| 693 | in: composetypes.ServiceConfig{ |
| 694 | CapAdd: []string{"ALL", "CAP_NET_ADMIN"}, |
| 695 | CapDrop: []string{"CHOWN", "CAP_NET_ADMIN", "DAC_OVERRIDE", "CAP_FSETID", "CAP_FOWNER"}, |
| 696 | }, |
| 697 | out: composetypes.ServiceConfig{ |
| 698 | CapAdd: []string{"ALL"}, |
| 699 | CapDrop: []string{"CAP_CHOWN", "CAP_DAC_OVERRIDE", "CAP_FOWNER", "CAP_FSETID", "CAP_NET_ADMIN"}, |
| 700 | }, |
| 701 | }, |
| 702 | { |
| 703 | title: "dropping ALL capabilities", |
| 704 | in: composetypes.ServiceConfig{ |
| 705 | CapAdd: []string{"CHOWN", "CAP_NET_ADMIN", "DAC_OVERRIDE", "CAP_FSETID", "CAP_FOWNER"}, |
| 706 | CapDrop: []string{"ALL", "CAP_NET_ADMIN", "CAP_FOO"}, |
| 707 | }, |
| 708 | out: composetypes.ServiceConfig{ |
| 709 | CapAdd: []string{"CAP_CHOWN", "CAP_DAC_OVERRIDE", "CAP_FOWNER", "CAP_FSETID", "CAP_NET_ADMIN"}, |
| 710 | CapDrop: []string{"ALL"}, |
| 711 | }, |
| 712 | }, |
| 713 | } |
| 714 | for _, tc := range tests { |
| 715 | t.Run(tc.title, func(t *testing.T) { |
| 716 | result, err := Service(Namespace{name: "foo"}, tc.in, nil, nil, nil, nil) |
| 717 | assert.NilError(t, err) |
| 718 | assert.Check(t, is.DeepEqual(result.TaskTemplate.ContainerSpec.CapabilityAdd, tc.out.CapAdd)) |
| 719 | assert.Check(t, is.DeepEqual(result.TaskTemplate.ContainerSpec.CapabilityDrop, tc.out.CapDrop)) |
| 720 | }) |
| 721 | } |
| 722 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…