Skip to content

Commit c626848

Browse files
Merge remote-tracking branch 'remotes/from/ce/main'
2 parents fc666c2 + ab62e44 commit c626848

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

builtin/logical/pki/path_roles.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ non-Hostname, non-Email address CNs.`,
373373
Type: framework.TypeCommaStringSlice,
374374
Description: `A comma-separated string or list of policy OIDs, or a JSON list of qualified policy
375375
information, which must include an oid, and may include a notice and/or cps url, using the form
376-
[{"oid"="1.3.6.1.4.1.7.8","notice"="I am a user Notice"}, {"oid"="1.3.6.1.4.1.44947.1.2.4 ","cps"="https://example.com"}].`,
376+
[{"oid"="1.3.6.1.4.1.7.8","notice"="I am a user Notice"}, {"oid"="1.3.6.1.4.1.32473.1.2.4","cps"="https://example.com"}].`,
377377
},
378378

379379
"basic_constraints_valid_for_non_ca": {
@@ -801,7 +801,7 @@ non-Hostname, non-Email address CNs.`,
801801
Type: framework.TypeCommaStringSlice,
802802
Description: `A comma-separated string or list of policy OIDs, or a JSON list of qualified policy
803803
information, which must include an oid, and may include a notice and/or cps url, using the form
804-
[{"oid"="1.3.6.1.4.1.7.8","notice"="I am a user Notice"}, {"oid"="1.3.6.1.4.1.44947.1.2.4 ","cps"="https://example.com"}].`,
804+
[{"oid"="1.3.6.1.4.1.7.8","notice"="I am a user Notice"}, {"oid"="1.3.6.1.4.1.32473.1.2.4","cps"="https://example.com"}].`,
805805
},
806806

807807
"basic_constraints_valid_for_non_ca": {

builtin/logical/pki/path_roles_test.go

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,8 +1031,8 @@ func TestPki_RolePatch(t *testing.T) {
10311031
func TestPKI_RolePolicyInformation_Flat(t *testing.T) {
10321032
t.Parallel()
10331033
type TestCase struct {
1034-
Input interface{}
1035-
ASN interface{}
1034+
Input string
1035+
ASN string
10361036
OidList []string
10371037
}
10381038

@@ -1051,9 +1051,9 @@ func TestPKI_RolePolicyInformation_Flat(t *testing.T) {
10511051
OidList: expectedSimpleOidList,
10521052
},
10531053
{
1054-
Input: "[{\"oid\":\"1.3.6.1.4.1.7.8\",\"notice\":\"I am a user Notice\"},{\"oid\":\"1.3.6.1.44947.1.2.4\",\"cps\":\"https://example.com\"}]",
1055-
ASN: "MF8wLQYHKwYBBAEHCDAiMCAGCCsGAQUFBwICMBQMEkkgYW0gYSB1c2VyIE5vdGljZTAuBgkrBgGC3xMBAgQwITAfBggrBgEFBQcCARYTaHR0cHM6Ly9leGFtcGxlLmNvbQ==",
1056-
OidList: append(*new([]string), "1.3.6.1.4.1.7.8", "1.3.6.1.44947.1.2.4"),
1054+
Input: "[{\"oid\":\"1.3.6.1.4.1.7.8\",\"notice\":\"I am a user Notice\"},{\"oid\":\"1.3.6.1.32473.1.2.4\",\"cps\":\"https://example.com\"}]",
1055+
ASN: "MF8wLQYHKwYBBAEHCDAiMCAGCCsGAQUFBwICMBQMEkkgYW0gYSB1c2VyIE5vdGljZTAuBgkrBgGB/VkBAgQwITAfBggrBgEFBQcCARYTaHR0cHM6Ly9leGFtcGxlLmNvbQ==",
1056+
OidList: append(*new([]string), "1.3.6.1.4.1.7.8", "1.3.6.1.32473.1.2.4"),
10571057
},
10581058
}
10591059

@@ -1076,10 +1076,6 @@ func TestPKI_RolePolicyInformation_Flat(t *testing.T) {
10761076
}
10771077

10781078
for index, testCase := range testCases {
1079-
var roleResp *logical.Response
1080-
var issueResp *logical.Response
1081-
var err error
1082-
10831079
// Create/update the role
10841080
roleData := map[string]interface{}{}
10851081
roleData[policyIdentifiersParam] = testCase.Input
@@ -1091,15 +1087,16 @@ func TestPKI_RolePolicyInformation_Flat(t *testing.T) {
10911087
Data: roleData,
10921088
}
10931089

1094-
roleResp, err = b.HandleRequest(context.Background(), roleReq)
1090+
roleResp, err := b.HandleRequest(context.Background(), roleReq)
10951091
if err != nil || (roleResp != nil && roleResp.IsError()) {
10961092
t.Fatalf("bad [%d], setting policy identifier %v err: %v resp: %#v", index, testCase.Input, err, roleResp)
10971093
}
10981094

10991095
// Issue Using this role
1100-
issueData := map[string]interface{}{}
1101-
issueData["common_name"] = "localhost"
1102-
issueData["ttl"] = "2s"
1096+
issueData := map[string]interface{}{
1097+
"common_name": "localhost",
1098+
"ttl": "2s",
1099+
}
11031100

11041101
issueReq := &logical.Request{
11051102
Operation: logical.UpdateOperation,
@@ -1108,10 +1105,13 @@ func TestPKI_RolePolicyInformation_Flat(t *testing.T) {
11081105
Data: issueData,
11091106
}
11101107

1111-
issueResp, err = b.HandleRequest(context.Background(), issueReq)
1108+
issueResp, err := b.HandleRequest(context.Background(), issueReq)
11121109
if err != nil || (issueResp != nil && issueResp.IsError()) {
11131110
t.Fatalf("bad [%d], setting policy identifier %v err: %v resp: %#v", index, testCase.Input, err, issueResp)
11141111
}
1112+
if issueResp == nil || issueResp.Data == nil {
1113+
t.Fatalf("bad [%d], setting policy identifier %v no response", index, testCase.Input)
1114+
}
11151115

11161116
// Validate the OIDs
11171117
policyIdentifiers, err := getPolicyIdentifiersOffCertificate(*issueResp)
@@ -1131,10 +1131,8 @@ func TestPKI_RolePolicyInformation_Flat(t *testing.T) {
11311131
if err != nil {
11321132
t.Fatalf("bad [%d], getting extension from %v err: %v resp: %#v", index, testCase.Input, err, issueResp)
11331133
}
1134-
certificateB64 := make([]byte, len(certificateAsn)*2)
1135-
base64.StdEncoding.Encode(certificateB64, certificateAsn)
1136-
certificateString := string(certificateB64[:])
1137-
assert.Contains(t, certificateString, testCase.ASN)
1134+
certificateString := base64.StdEncoding.EncodeToString(certificateAsn)
1135+
assert.Equal(t, certificateString, testCase.ASN)
11381136
}
11391137
}
11401138

changelog/_9306.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:improvement
2+
secrets/pki (enterprise): add integrations/guardium configuration endpoint.
3+
```

0 commit comments

Comments
 (0)