@@ -1031,8 +1031,8 @@ func TestPki_RolePatch(t *testing.T) {
1031
1031
func TestPKI_RolePolicyInformation_Flat (t * testing.T ) {
1032
1032
t .Parallel ()
1033
1033
type TestCase struct {
1034
- Input interface {}
1035
- ASN interface {}
1034
+ Input string
1035
+ ASN string
1036
1036
OidList []string
1037
1037
}
1038
1038
@@ -1051,9 +1051,9 @@ func TestPKI_RolePolicyInformation_Flat(t *testing.T) {
1051
1051
OidList : expectedSimpleOidList ,
1052
1052
},
1053
1053
{
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" ),
1057
1057
},
1058
1058
}
1059
1059
@@ -1076,10 +1076,6 @@ func TestPKI_RolePolicyInformation_Flat(t *testing.T) {
1076
1076
}
1077
1077
1078
1078
for index , testCase := range testCases {
1079
- var roleResp * logical.Response
1080
- var issueResp * logical.Response
1081
- var err error
1082
-
1083
1079
// Create/update the role
1084
1080
roleData := map [string ]interface {}{}
1085
1081
roleData [policyIdentifiersParam ] = testCase .Input
@@ -1091,15 +1087,16 @@ func TestPKI_RolePolicyInformation_Flat(t *testing.T) {
1091
1087
Data : roleData ,
1092
1088
}
1093
1089
1094
- roleResp , err = b .HandleRequest (context .Background (), roleReq )
1090
+ roleResp , err : = b .HandleRequest (context .Background (), roleReq )
1095
1091
if err != nil || (roleResp != nil && roleResp .IsError ()) {
1096
1092
t .Fatalf ("bad [%d], setting policy identifier %v err: %v resp: %#v" , index , testCase .Input , err , roleResp )
1097
1093
}
1098
1094
1099
1095
// 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
+ }
1103
1100
1104
1101
issueReq := & logical.Request {
1105
1102
Operation : logical .UpdateOperation ,
@@ -1108,10 +1105,13 @@ func TestPKI_RolePolicyInformation_Flat(t *testing.T) {
1108
1105
Data : issueData ,
1109
1106
}
1110
1107
1111
- issueResp , err = b .HandleRequest (context .Background (), issueReq )
1108
+ issueResp , err : = b .HandleRequest (context .Background (), issueReq )
1112
1109
if err != nil || (issueResp != nil && issueResp .IsError ()) {
1113
1110
t .Fatalf ("bad [%d], setting policy identifier %v err: %v resp: %#v" , index , testCase .Input , err , issueResp )
1114
1111
}
1112
+ if issueResp == nil || issueResp .Data == nil {
1113
+ t .Fatalf ("bad [%d], setting policy identifier %v no response" , index , testCase .Input )
1114
+ }
1115
1115
1116
1116
// Validate the OIDs
1117
1117
policyIdentifiers , err := getPolicyIdentifiersOffCertificate (* issueResp )
@@ -1131,10 +1131,8 @@ func TestPKI_RolePolicyInformation_Flat(t *testing.T) {
1131
1131
if err != nil {
1132
1132
t .Fatalf ("bad [%d], getting extension from %v err: %v resp: %#v" , index , testCase .Input , err , issueResp )
1133
1133
}
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 )
1138
1136
}
1139
1137
}
1140
1138
0 commit comments