Skip to content

Commit

Permalink
enable private cert API
Browse files Browse the repository at this point in the history
  • Loading branch information
ShacharN committed Apr 14, 2022
1 parent 2516b70 commit 73eaaba
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 36 deletions.
60 changes: 33 additions & 27 deletions secretsmanagerv1/secrets_manager_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -2331,7 +2331,7 @@ type ConfigAction struct {
// The Subject Alternative Names to define for the CA certificate, in a comma-delimited list.
//
// The alternative names can be host names or email addresses.
AltNames *string `json:"alt_names,omitempty"`
AltNames []string `json:"alt_names,omitempty"`

// The IP Subject Alternative Names to define for the CA certificate, in a comma-delimited list.
IPSans *string `json:"ip_sans,omitempty"`
Expand Down Expand Up @@ -2609,7 +2609,7 @@ type ConfigElementActionResultConfig struct {
// The Subject Alternative Names to define for the CA certificate, in a comma-delimited list.
//
// The alternative names can be host names or email addresses.
AltNames *string `json:"alt_names,omitempty"`
AltNames []string `json:"alt_names,omitempty"`

// The IP Subject Alternative Names to define for the CA certificate, in a comma-delimited list.
IPSans *string `json:"ip_sans,omitempty"`
Expand Down Expand Up @@ -2950,7 +2950,7 @@ type ConfigElementDefConfig struct {
// The Subject Alternative Names to define for the CA certificate, in a comma-delimited list.
//
// The alternative names can be host names or email addresses.
AltNames *string `json:"alt_names,omitempty"`
AltNames []string `json:"alt_names,omitempty"`

// The IP Subject Alternative Names to define for the CA certificate, in a comma-delimited list.
IPSans *string `json:"ip_sans,omitempty"`
Expand Down Expand Up @@ -2982,6 +2982,9 @@ type ConfigElementDefConfig struct {
KeyType *string `json:"key_type,omitempty"`

// The number of bits to use when generating the private key.
//
// Allowable values for RSA keys are: 2048 and 4096. Allowable values for EC keys are: 224, 256, 384 And 521. The
// default for RSA keys is 2048, and the default for EC keys is 256.
KeyBits *int64 `json:"key_bits,omitempty"`

// The maximum path length to encode in the generated certificate. `-1` means no limit.
Expand Down Expand Up @@ -3202,9 +3205,8 @@ const (
// Constants associated with the ConfigElementDefConfig.KeyType property.
// The type of private key to generate.
const (
ConfigElementDefConfigKeyTypeEcConst = "ec"
ConfigElementDefConfigKeyTypeEd25519Const = "ed25519"
ConfigElementDefConfigKeyTypeRsaConst = "rsa"
ConfigElementDefConfigKeyTypeEcConst = "ec"
ConfigElementDefConfigKeyTypeRsaConst = "rsa"
)

// Constants associated with the ConfigElementDefConfig.SigningMethod property.
Expand Down Expand Up @@ -8803,7 +8805,7 @@ type CertificateTemplateConfig struct {
// The value can be supplied as a string representation of a duration, such as `12h`. Hour (`h`) is the largest time
// suffix. The value can't exceed the `max_ttl` that is defined in the associated certificate template. Note that in
// the API response the value is returned in seconds (integer).
TTL interface{} `json:"ttl,omitempty"`
TTL *string `json:"ttl,omitempty"`

// Determines whether to allow `localhost` to be included as one of the requested common names.
AllowLocalhost *bool `json:"allow_localhost,omitempty"`
Expand Down Expand Up @@ -8878,11 +8880,13 @@ type CertificateTemplateConfig struct {
// The type of private key to generate for private certificates and the type of key that is expected for submitted
// certificate signing requests (CSRs).
//
// Allowable values are: `rsa`, `ec` and `any`. A value of `any` allow keys of either type and with any bit size. The
// bit size must be greater than 1024 bits for RSA keys.
// Allowable values are: `rsa` and `ec`.
KeyType *string `json:"key_type,omitempty"`

// The number of bits to use when generating the private key.
//
// Allowable values for RSA keys are: 2048 and 4096. Allowable values for EC keys are: 224, 256, 384 And 521. The
// default for RSA keys is 2048, and the default for EC keys is 256.
KeyBits *int64 `json:"key_bits,omitempty"`

// The allowed key usage constraint to define for private certificates.
Expand Down Expand Up @@ -8964,10 +8968,8 @@ type CertificateTemplateConfig struct {
// The type of private key to generate for private certificates and the type of key that is expected for submitted
// certificate signing requests (CSRs).
//
// Allowable values are: `rsa`, `ec` and `any`. A value of `any` allow keys of either type and with any bit size. The
// bit size must be greater than 1024 bits for RSA keys.
// Allowable values are: `rsa` and `ec`.
const (
CertificateTemplateConfigKeyTypeAnyConst = "any"
CertificateTemplateConfigKeyTypeEcConst = "ec"
CertificateTemplateConfigKeyTypeRsaConst = "rsa"
)
Expand Down Expand Up @@ -9701,7 +9703,7 @@ type IamCredentialsSecretResource struct {
// or `24h`.
//
// Minimum duration is 1 minute. Maximum is 90 days.
TTL interface{} `json:"ttl,omitempty"`
TTL *string `json:"ttl,omitempty"`

// The access groups that define the capabilities of the service ID and API key that are generated for an
// `iam_credentials` secret. If you prefer to use an existing service ID that is already assigned the access policies
Expand Down Expand Up @@ -10100,7 +10102,7 @@ type IntermediateCertificateAuthorityConfig struct {
// The Subject Alternative Names to define for the CA certificate, in a comma-delimited list.
//
// The alternative names can be host names or email addresses.
AltNames *string `json:"alt_names,omitempty"`
AltNames []string `json:"alt_names,omitempty"`

// The IP Subject Alternative Names to define for the CA certificate, in a comma-delimited list.
IPSans *string `json:"ip_sans,omitempty"`
Expand All @@ -10125,6 +10127,9 @@ type IntermediateCertificateAuthorityConfig struct {
KeyType *string `json:"key_type,omitempty"`

// The number of bits to use when generating the private key.
//
// Allowable values for RSA keys are: 2048 and 4096. Allowable values for EC keys are: 224, 256, 384 And 521. The
// default for RSA keys is 2048, and the default for EC keys is 256.
KeyBits *int64 `json:"key_bits,omitempty"`

// Controls whether the common name is excluded from Subject Alternative Names (SANs).
Expand Down Expand Up @@ -10208,9 +10213,8 @@ const (
// Constants associated with the IntermediateCertificateAuthorityConfig.KeyType property.
// The type of private key to generate.
const (
IntermediateCertificateAuthorityConfigKeyTypeEcConst = "ec"
IntermediateCertificateAuthorityConfigKeyTypeEd25519Const = "ed25519"
IntermediateCertificateAuthorityConfigKeyTypeRsaConst = "rsa"
IntermediateCertificateAuthorityConfigKeyTypeEcConst = "ec"
IntermediateCertificateAuthorityConfigKeyTypeRsaConst = "rsa"
)

// NewIntermediateCertificateAuthorityConfig : Instantiate IntermediateCertificateAuthorityConfig (Generic Model Constructor)
Expand Down Expand Up @@ -10816,7 +10820,7 @@ type PrivateCertificateSecretMetadata struct {
// The Subject Alternative Names to define for the CA certificate, in a comma-delimited list.
//
// The alternative names can be host names or email addresses.
AltNames *string `json:"alt_names,omitempty"`
AltNames []string `json:"alt_names,omitempty"`

// The IP Subject Alternative Names to define for the CA certificate, in a comma-delimited list.
IPSans *string `json:"ip_sans,omitempty"`
Expand Down Expand Up @@ -11120,7 +11124,7 @@ type PrivateCertificateSecretResource struct {
// The Subject Alternative Names to define for the CA certificate, in a comma-delimited list.
//
// The alternative names can be host names or email addresses.
AltNames *string `json:"alt_names,omitempty"`
AltNames []string `json:"alt_names,omitempty"`

// The IP Subject Alternative Names to define for the CA certificate, in a comma-delimited list.
IPSans *string `json:"ip_sans,omitempty"`
Expand Down Expand Up @@ -12392,7 +12396,7 @@ type RootCertificateAuthorityConfig struct {
// The Subject Alternative Names to define for the CA certificate, in a comma-delimited list.
//
// The alternative names can be host names or email addresses.
AltNames *string `json:"alt_names,omitempty"`
AltNames []string `json:"alt_names,omitempty"`

// The IP Subject Alternative Names to define for the CA certificate, in a comma-delimited list.
IPSans *string `json:"ip_sans,omitempty"`
Expand Down Expand Up @@ -12424,6 +12428,9 @@ type RootCertificateAuthorityConfig struct {
KeyType *string `json:"key_type,omitempty"`

// The number of bits to use when generating the private key.
//
// Allowable values for RSA keys are: 2048 and 4096. Allowable values for EC keys are: 224, 256, 384 And 521. The
// default for RSA keys is 2048, and the default for EC keys is 256.
KeyBits *int64 `json:"key_bits,omitempty"`

// The maximum path length to encode in the generated certificate. `-1` means no limit.
Expand Down Expand Up @@ -12505,9 +12512,8 @@ const (
// Constants associated with the RootCertificateAuthorityConfig.KeyType property.
// The type of private key to generate.
const (
RootCertificateAuthorityConfigKeyTypeEcConst = "ec"
RootCertificateAuthorityConfigKeyTypeEd25519Const = "ed25519"
RootCertificateAuthorityConfigKeyTypeRsaConst = "rsa"
RootCertificateAuthorityConfigKeyTypeEcConst = "ec"
RootCertificateAuthorityConfigKeyTypeRsaConst = "rsa"
)

// NewRootCertificateAuthorityConfig : Instantiate RootCertificateAuthorityConfig (Generic Model Constructor)
Expand Down Expand Up @@ -12971,7 +12977,7 @@ type SignCsrAction struct {
// The Subject Alternative Names to define for the CA certificate, in a comma-delimited list.
//
// The alternative names can be host names or email addresses.
AltNames *string `json:"alt_names,omitempty"`
AltNames []string `json:"alt_names,omitempty"`

// The IP Subject Alternative Names to define for the CA certificate, in a comma-delimited list.
IPSans *string `json:"ip_sans,omitempty"`
Expand Down Expand Up @@ -13168,7 +13174,7 @@ type SignCsrActionResult struct {
// The Subject Alternative Names to define for the CA certificate, in a comma-delimited list.
//
// The alternative names can be host names or email addresses.
AltNames *string `json:"alt_names,omitempty"`
AltNames []string `json:"alt_names,omitempty"`

// The IP Subject Alternative Names to define for the CA certificate, in a comma-delimited list.
IPSans *string `json:"ip_sans,omitempty"`
Expand Down Expand Up @@ -13363,7 +13369,7 @@ type SignIntermediateAction struct {
// The Subject Alternative Names to define for the CA certificate, in a comma-delimited list.
//
// The alternative names can be host names or email addresses.
AltNames *string `json:"alt_names,omitempty"`
AltNames []string `json:"alt_names,omitempty"`

// The IP Subject Alternative Names to define for the CA certificate, in a comma-delimited list.
IPSans *string `json:"ip_sans,omitempty"`
Expand Down Expand Up @@ -13561,7 +13567,7 @@ type SignIntermediateActionResult struct {
// The Subject Alternative Names to define for the CA certificate, in a comma-delimited list.
//
// The alternative names can be host names or email addresses.
AltNames *string `json:"alt_names,omitempty"`
AltNames []string `json:"alt_names,omitempty"`

// The IP Subject Alternative Names to define for the CA certificate, in a comma-delimited list.
IPSans *string `json:"ip_sans,omitempty"`
Expand Down
18 changes: 9 additions & 9 deletions secretsmanagerv1/secrets_manager_v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5926,7 +5926,7 @@ var _ = Describe(`SecretsManagerV1`, func() {
// Construct an instance of the SignCsrAction model
configActionModel := new(secretsmanagerv1.SignCsrAction)
configActionModel.CommonName = core.StringPtr("example.com")
configActionModel.AltNames = core.StringPtr("testString")
configActionModel.AltNames = []string{"testString"}
configActionModel.IPSans = core.StringPtr("testString")
configActionModel.URISans = core.StringPtr("testString")
configActionModel.OtherSans = []string{"testString"}
Expand Down Expand Up @@ -6006,7 +6006,7 @@ var _ = Describe(`SecretsManagerV1`, func() {
// Set mock response
res.Header().Set("Content-type", "application/json")
res.WriteHeader(200)
fmt.Fprintf(res, "%s", `{"metadata": {"collection_type": "application/vnd.ibm.secrets-manager.config+json", "collection_total": 1}, "resources": [{"name": "Name", "type": "letsencrypt", "config": {"common_name": "example.com", "alt_names": "AltNames", "ip_sans": "IPSans", "uri_sans": "URISans", "other_sans": ["OtherSans"], "ttl": "12h", "format": "pem", "max_path_length": 13, "exclude_cn_from_sans": false, "permitted_dns_domains": ["PermittedDNSDomains"], "use_csr_values": false, "ou": ["Ou"], "organization": ["Organization"], "country": ["Country"], "locality": ["Locality"], "province": ["Province"], "street_address": ["StreetAddress"], "postal_code": ["PostalCode"], "serial_number": "d9:be:fe:35:ba:09:42:b5", "data": {"certificate": "Certificate", "serial_number": "d9:be:fe:35:ba:09:42:b5", "issuing_ca": "IssuingCa", "ca_chain": ["CaChain"], "expiration": 10}, "csr": "Csr"}}]}`)
fmt.Fprintf(res, "%s", `{"metadata": {"collection_type": "application/vnd.ibm.secrets-manager.config+json", "collection_total": 1}, "resources": [{"name": "Name", "type": "letsencrypt", "config": {"common_name": "example.com", "alt_names": ["AltNames"], "ip_sans": "IPSans", "uri_sans": "URISans", "other_sans": ["OtherSans"], "ttl": "12h", "format": "pem", "max_path_length": 13, "exclude_cn_from_sans": false, "permitted_dns_domains": ["PermittedDNSDomains"], "use_csr_values": false, "ou": ["Ou"], "organization": ["Organization"], "country": ["Country"], "locality": ["Locality"], "province": ["Province"], "street_address": ["StreetAddress"], "postal_code": ["PostalCode"], "serial_number": "d9:be:fe:35:ba:09:42:b5", "data": {"certificate": "Certificate", "serial_number": "d9:be:fe:35:ba:09:42:b5", "issuing_ca": "IssuingCa", "ca_chain": ["CaChain"], "expiration": 10}, "csr": "Csr"}}]}`)
}))
})
It(`Invoke ActionOnConfigElement successfully with retries`, func() {
Expand All @@ -6021,7 +6021,7 @@ var _ = Describe(`SecretsManagerV1`, func() {
// Construct an instance of the SignCsrAction model
configActionModel := new(secretsmanagerv1.SignCsrAction)
configActionModel.CommonName = core.StringPtr("example.com")
configActionModel.AltNames = core.StringPtr("testString")
configActionModel.AltNames = []string{"testString"}
configActionModel.IPSans = core.StringPtr("testString")
configActionModel.URISans = core.StringPtr("testString")
configActionModel.OtherSans = []string{"testString"}
Expand Down Expand Up @@ -6104,7 +6104,7 @@ var _ = Describe(`SecretsManagerV1`, func() {
// Set mock response
res.Header().Set("Content-type", "application/json")
res.WriteHeader(200)
fmt.Fprintf(res, "%s", `{"metadata": {"collection_type": "application/vnd.ibm.secrets-manager.config+json", "collection_total": 1}, "resources": [{"name": "Name", "type": "letsencrypt", "config": {"common_name": "example.com", "alt_names": "AltNames", "ip_sans": "IPSans", "uri_sans": "URISans", "other_sans": ["OtherSans"], "ttl": "12h", "format": "pem", "max_path_length": 13, "exclude_cn_from_sans": false, "permitted_dns_domains": ["PermittedDNSDomains"], "use_csr_values": false, "ou": ["Ou"], "organization": ["Organization"], "country": ["Country"], "locality": ["Locality"], "province": ["Province"], "street_address": ["StreetAddress"], "postal_code": ["PostalCode"], "serial_number": "d9:be:fe:35:ba:09:42:b5", "data": {"certificate": "Certificate", "serial_number": "d9:be:fe:35:ba:09:42:b5", "issuing_ca": "IssuingCa", "ca_chain": ["CaChain"], "expiration": 10}, "csr": "Csr"}}]}`)
fmt.Fprintf(res, "%s", `{"metadata": {"collection_type": "application/vnd.ibm.secrets-manager.config+json", "collection_total": 1}, "resources": [{"name": "Name", "type": "letsencrypt", "config": {"common_name": "example.com", "alt_names": ["AltNames"], "ip_sans": "IPSans", "uri_sans": "URISans", "other_sans": ["OtherSans"], "ttl": "12h", "format": "pem", "max_path_length": 13, "exclude_cn_from_sans": false, "permitted_dns_domains": ["PermittedDNSDomains"], "use_csr_values": false, "ou": ["Ou"], "organization": ["Organization"], "country": ["Country"], "locality": ["Locality"], "province": ["Province"], "street_address": ["StreetAddress"], "postal_code": ["PostalCode"], "serial_number": "d9:be:fe:35:ba:09:42:b5", "data": {"certificate": "Certificate", "serial_number": "d9:be:fe:35:ba:09:42:b5", "issuing_ca": "IssuingCa", "ca_chain": ["CaChain"], "expiration": 10}, "csr": "Csr"}}]}`)
}))
})
It(`Invoke ActionOnConfigElement successfully`, func() {
Expand All @@ -6124,7 +6124,7 @@ var _ = Describe(`SecretsManagerV1`, func() {
// Construct an instance of the SignCsrAction model
configActionModel := new(secretsmanagerv1.SignCsrAction)
configActionModel.CommonName = core.StringPtr("example.com")
configActionModel.AltNames = core.StringPtr("testString")
configActionModel.AltNames = []string{"testString"}
configActionModel.IPSans = core.StringPtr("testString")
configActionModel.URISans = core.StringPtr("testString")
configActionModel.OtherSans = []string{"testString"}
Expand Down Expand Up @@ -6171,7 +6171,7 @@ var _ = Describe(`SecretsManagerV1`, func() {
// Construct an instance of the SignCsrAction model
configActionModel := new(secretsmanagerv1.SignCsrAction)
configActionModel.CommonName = core.StringPtr("example.com")
configActionModel.AltNames = core.StringPtr("testString")
configActionModel.AltNames = []string{"testString"}
configActionModel.IPSans = core.StringPtr("testString")
configActionModel.URISans = core.StringPtr("testString")
configActionModel.OtherSans = []string{"testString"}
Expand Down Expand Up @@ -6239,7 +6239,7 @@ var _ = Describe(`SecretsManagerV1`, func() {
// Construct an instance of the SignCsrAction model
configActionModel := new(secretsmanagerv1.SignCsrAction)
configActionModel.CommonName = core.StringPtr("example.com")
configActionModel.AltNames = core.StringPtr("testString")
configActionModel.AltNames = []string{"testString"}
configActionModel.IPSans = core.StringPtr("testString")
configActionModel.URISans = core.StringPtr("testString")
configActionModel.OtherSans = []string{"testString"}
Expand Down Expand Up @@ -6938,7 +6938,7 @@ var _ = Describe(`SecretsManagerV1`, func() {
configActionModel := new(secretsmanagerv1.SignCsrAction)
Expect(configActionModel).ToNot(BeNil())
configActionModel.CommonName = core.StringPtr("example.com")
configActionModel.AltNames = core.StringPtr("testString")
configActionModel.AltNames = []string{"testString"}
configActionModel.IPSans = core.StringPtr("testString")
configActionModel.URISans = core.StringPtr("testString")
configActionModel.OtherSans = []string{"testString"}
Expand All @@ -6958,7 +6958,7 @@ var _ = Describe(`SecretsManagerV1`, func() {
configActionModel.SerialNumber = core.StringPtr("d9:be:fe:35:ba:09:42:b5")
configActionModel.Csr = core.StringPtr("testString")
Expect(configActionModel.CommonName).To(Equal(core.StringPtr("example.com")))
Expect(configActionModel.AltNames).To(Equal(core.StringPtr("testString")))
Expect(configActionModel.AltNames).To(Equal([]string{"testString"}))
Expect(configActionModel.IPSans).To(Equal(core.StringPtr("testString")))
Expect(configActionModel.URISans).To(Equal(core.StringPtr("testString")))
Expect(configActionModel.OtherSans).To(Equal([]string{"testString"}))
Expand Down

0 comments on commit 73eaaba

Please sign in to comment.