-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix 1.8 regression preventing email addresses being used as common na…
…me within pki certificates (#12336) (#12716) * Fix 1.8 regression preventing email addresses being used as common name within pki certs (#12336) * Add changelog
- Loading branch information
1 parent
b435f09
commit 70012cd
Showing
3 changed files
with
65 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,7 +164,8 @@ func TestPki_PermitFQDNs(t *testing.T) { | |
|
||
cases := map[string]struct { | ||
input *inputBundle | ||
expected []string | ||
expectedDnsNames []string | ||
expectedEmails []string | ||
}{ | ||
"base valid case": { | ||
input: &inputBundle{ | ||
|
@@ -181,7 +182,8 @@ func TestPki_PermitFQDNs(t *testing.T) { | |
EnforceHostnames: true, | ||
}, | ||
}, | ||
expected: []string{"example.com."}, | ||
expectedDnsNames: []string{"example.com."}, | ||
expectedEmails: []string{}, | ||
}, | ||
"case insensitivity validation": { | ||
input: &inputBundle{ | ||
|
@@ -199,20 +201,65 @@ func TestPki_PermitFQDNs(t *testing.T) { | |
MaxTTL: 3600, | ||
}, | ||
}, | ||
expected: []string{"Example.Net", "eXaMPLe.COM"}, | ||
expectedDnsNames: []string{"Example.Net", "eXaMPLe.COM"}, | ||
expectedEmails: []string{}, | ||
}, | ||
"case email as AllowedDomain with bare domains": { | ||
input: &inputBundle{ | ||
apiData: &framework.FieldData{ | ||
Schema: fields, | ||
Raw: map[string]interface{}{ | ||
"common_name": "[email protected]", | ||
"ttl": 3600, | ||
}, | ||
}, | ||
role: &roleEntry{ | ||
AllowedDomains: []string{"[email protected]"}, | ||
AllowBareDomains: true, | ||
MaxTTL: 3600, | ||
}, | ||
}, | ||
expectedDnsNames: []string{}, | ||
expectedEmails: []string{"[email protected]"}, | ||
}, | ||
"case email common name with bare domains": { | ||
input: &inputBundle{ | ||
apiData: &framework.FieldData{ | ||
Schema: fields, | ||
Raw: map[string]interface{}{ | ||
"common_name": "[email protected]", | ||
"ttl": 3600, | ||
}, | ||
}, | ||
role: &roleEntry{ | ||
AllowedDomains: []string{"testemail.com"}, | ||
AllowBareDomains: true, | ||
MaxTTL: 3600, | ||
}, | ||
}, | ||
expectedDnsNames: []string{}, | ||
expectedEmails: []string{"[email protected]"}, | ||
}, | ||
} | ||
|
||
for _, testCase := range cases { | ||
cb, err := generateCreationBundle(&b, testCase.input, nil, nil) | ||
if err != nil { | ||
t.Fatalf("Error: %v", err) | ||
} | ||
for name, testCase := range cases { | ||
t.Run(name, func(t *testing.T) { | ||
cb, err := generateCreationBundle(&b, testCase.input, nil, nil) | ||
if err != nil { | ||
t.Fatalf("Error: %v", err) | ||
} | ||
|
||
actual := cb.Params.DNSNames | ||
actualDnsNames := cb.Params.DNSNames | ||
|
||
if !reflect.DeepEqual(testCase.expected, actual) { | ||
t.Fatalf("Expected %v, got %v", testCase.expected, actual) | ||
} | ||
if !reflect.DeepEqual(testCase.expectedDnsNames, actualDnsNames) { | ||
t.Fatalf("Expected dns names %v, got %v", testCase.expectedDnsNames, actualDnsNames) | ||
} | ||
|
||
actualEmails := cb.Params.EmailAddresses | ||
|
||
if !reflect.DeepEqual(testCase.expectedEmails, actualEmails) { | ||
t.Fatalf("Expected email addresses %v, got %v", testCase.expectedEmails, actualEmails) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:bug | ||
pki: Fix regression preventing email addresses being used as a common name within certificates | ||
``` |