@@ -10294,7 +10294,7 @@ func TestValidatePod(t *testing.T) {
10294
10294
Name: "123",
10295
10295
Namespace: "ns",
10296
10296
Annotations: map[string]string{
10297
- v1.AppArmorBetaContainerAnnotationKeyPrefix + "ctr": v1.AppArmorBetaProfileRuntimeDefault ,
10297
+ v1.DeprecatedAppArmorBetaContainerAnnotationKeyPrefix + "ctr": v1.DeprecatedAppArmorBetaProfileRuntimeDefault ,
10298
10298
},
10299
10299
},
10300
10300
Spec: validPodSpec(nil),
@@ -10304,7 +10304,7 @@ func TestValidatePod(t *testing.T) {
10304
10304
Name: "123",
10305
10305
Namespace: "ns",
10306
10306
Annotations: map[string]string{
10307
- v1.AppArmorBetaContainerAnnotationKeyPrefix + "init-ctr": v1.AppArmorBetaProfileRuntimeDefault ,
10307
+ v1.DeprecatedAppArmorBetaContainerAnnotationKeyPrefix + "init-ctr": v1.DeprecatedAppArmorBetaProfileRuntimeDefault ,
10308
10308
},
10309
10309
},
10310
10310
Spec: core.PodSpec{
@@ -10319,7 +10319,7 @@ func TestValidatePod(t *testing.T) {
10319
10319
Name: "123",
10320
10320
Namespace: "ns",
10321
10321
Annotations: map[string]string{
10322
- v1.AppArmorBetaContainerAnnotationKeyPrefix + "ctr": v1.AppArmorBetaProfileNamePrefix + "foo",
10322
+ v1.DeprecatedAppArmorBetaContainerAnnotationKeyPrefix + "ctr": v1.DeprecatedAppArmorBetaProfileNamePrefix + "foo",
10323
10323
},
10324
10324
},
10325
10325
Spec: validPodSpec(nil),
@@ -11983,9 +11983,9 @@ func TestValidatePod(t *testing.T) {
11983
11983
Name: "123",
11984
11984
Namespace: "ns",
11985
11985
Annotations: map[string]string{
11986
- v1.AppArmorBetaContainerAnnotationKeyPrefix + "ctr": v1.AppArmorBetaProfileRuntimeDefault ,
11987
- v1.AppArmorBetaContainerAnnotationKeyPrefix + "init-ctr": v1.AppArmorBetaProfileRuntimeDefault ,
11988
- v1.AppArmorBetaContainerAnnotationKeyPrefix + "fake-ctr": v1.AppArmorBetaProfileRuntimeDefault ,
11986
+ v1.DeprecatedAppArmorBetaContainerAnnotationKeyPrefix + "ctr": v1.DeprecatedAppArmorBetaProfileRuntimeDefault ,
11987
+ v1.DeprecatedAppArmorBetaContainerAnnotationKeyPrefix + "init-ctr": v1.DeprecatedAppArmorBetaProfileRuntimeDefault ,
11988
+ v1.DeprecatedAppArmorBetaContainerAnnotationKeyPrefix + "fake-ctr": v1.DeprecatedAppArmorBetaProfileRuntimeDefault ,
11989
11989
},
11990
11990
},
11991
11991
Spec: core.PodSpec{
@@ -12003,7 +12003,7 @@ func TestValidatePod(t *testing.T) {
12003
12003
Name: "123",
12004
12004
Namespace: "ns",
12005
12005
Annotations: map[string]string{
12006
- v1.AppArmorBetaContainerAnnotationKeyPrefix + "ctr": "bad-name",
12006
+ v1.DeprecatedAppArmorBetaContainerAnnotationKeyPrefix + "ctr": "bad-name",
12007
12007
},
12008
12008
},
12009
12009
Spec: validPodSpec(nil),
@@ -12016,7 +12016,7 @@ func TestValidatePod(t *testing.T) {
12016
12016
Name: "123",
12017
12017
Namespace: "ns",
12018
12018
Annotations: map[string]string{
12019
- v1.AppArmorBetaContainerAnnotationKeyPrefix + "ctr": "runtime/foo",
12019
+ v1.DeprecatedAppArmorBetaContainerAnnotationKeyPrefix + "ctr": "runtime/foo",
12020
12020
},
12021
12021
},
12022
12022
Spec: validPodSpec(nil),
@@ -12159,6 +12159,26 @@ func TestValidatePod(t *testing.T) {
12159
12159
},
12160
12160
},
12161
12161
},
12162
+ "too long AppArmor localhost profile": {
12163
+ expectedError: "Too long: may not be longer than 4095",
12164
+ spec: core.Pod{
12165
+ ObjectMeta: metav1.ObjectMeta{
12166
+ Name: "123",
12167
+ Namespace: "ns",
12168
+ },
12169
+ Spec: core.PodSpec{
12170
+ Containers: []core.Container{{Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent", TerminationMessagePolicy: "File"}},
12171
+ RestartPolicy: core.RestartPolicyAlways,
12172
+ DNSPolicy: core.DNSDefault,
12173
+ SecurityContext: &core.PodSecurityContext{
12174
+ AppArmorProfile: &core.AppArmorProfile{
12175
+ Type: core.AppArmorProfileTypeLocalhost,
12176
+ LocalhostProfile: ptr.To(strings.Repeat("a", 4096)),
12177
+ },
12178
+ },
12179
+ },
12180
+ },
12181
+ },
12162
12182
"mismatched AppArmor field and annotation types": {
12163
12183
expectedError: "Forbidden: apparmor type in annotation and field must match",
12164
12184
spec: core.Pod{
@@ -25186,11 +25206,11 @@ func TestValidateAppArmorProfileFormat(t *testing.T) {
25186
25206
expectValid bool
25187
25207
}{
25188
25208
{"", true},
25189
- {v1.AppArmorBetaProfileRuntimeDefault , true},
25190
- {v1.AppArmorBetaProfileNameUnconfined , true},
25209
+ {v1.DeprecatedAppArmorBetaProfileRuntimeDefault , true},
25210
+ {v1.DeprecatedAppArmorBetaProfileNameUnconfined , true},
25191
25211
{"baz", false}, // Missing local prefix.
25192
- {v1.AppArmorBetaProfileNamePrefix + "/usr/sbin/ntpd", true},
25193
- {v1.AppArmorBetaProfileNamePrefix + "foo-bar", true},
25212
+ {v1.DeprecatedAppArmorBetaProfileNamePrefix + "/usr/sbin/ntpd", true},
25213
+ {v1.DeprecatedAppArmorBetaProfileNamePrefix + "foo-bar", true},
25194
25214
}
25195
25215
25196
25216
for _, test := range tests {
0 commit comments