@@ -11,6 +11,7 @@ import (
1111
1212 "github.com/aws/aws-sdk-go-v2/aws"
1313 "github.com/aws/aws-sdk-go-v2/config"
14+ "github.com/aws/aws-sdk-go-v2/service/acmpca/types"
1415 "github.com/cert-manager/aws-privateca-issuer/pkg/api/v1beta1"
1516 clientV1beta1 "github.com/cert-manager/aws-privateca-issuer/pkg/clientset/v1beta1"
1617 cmclientv1 "github.com/cert-manager/cert-manager/pkg/client/clientset/versioned/typed/certmanager/v1"
@@ -31,7 +32,7 @@ type TestContext struct {
3132 xaCfg aws.Config
3233 caArns map [string ]string
3334
34- region , accessKey , secretKey , endEntityResourceShareArn , subordinateCaResourceShareArn , userName , policyArn string
35+ region , partition , accessKey , secretKey , endEntityResourceShareArn , subordinateCaResourceShareArn , userName , policyArn string
3536}
3637
3738// These are variables specific to each test
@@ -111,6 +112,8 @@ func InitializeTestSuite(suiteCtx *godog.TestSuiteContext) {
111112 panic (cfgErr .Error ())
112113 }
113114
115+ testContext .partition = getPartition (ctx , cfg )
116+
114117 testContext .iclient , err = clientV1beta1 .NewForConfig (clientConfig )
115118
116119 if err != nil {
@@ -124,22 +127,22 @@ func InitializeTestSuite(suiteCtx *godog.TestSuiteContext) {
124127 }
125128
126129 // Create CAs to be used in testing
127- testContext .caArns [ "RSA" ] = createCertificateAuthority (ctx , cfg , true )
130+ testContext .createCertificateAuthority (ctx , cfg , "RSA" , types . SigningAlgorithmSha256withrsa )
128131 log .Printf ("Created RSA CA with arn %s" , testContext .caArns ["RSA" ])
129132
130- testContext .caArns [ "ECDSA" ] = createCertificateAuthority (ctx , cfg , false )
133+ testContext .createCertificateAuthority (ctx , cfg , "ECDSA" , types . SigningAlgorithmSha256withecdsa )
131134 log .Printf ("Created EC CA with arn %s" , testContext .caArns ["ECDSA" ])
132135
133136 xaRole , xaRoleExists := os .LookupEnv (CrossAccountRoleKey )
134137 if xaRoleExists {
135138 testContext .xaCfg = assumeRole (ctx , cfg , xaRole , testContext .region )
136139
137- testContext .caArns [ "XA" ] = createCertificateAuthority (ctx , testContext .xaCfg , true )
140+ testContext .createCertificateAuthority (ctx , testContext .xaCfg , "XA" , types . SigningAlgorithmSha256withrsa )
138141
139142 log .Printf ("Created XA CA with arn %s" , testContext .caArns ["XA" ])
140143
141- endEntityResourcePermission := "arn:aws :ram::aws:permission/AWSRAMDefaultPermissionCertificateAuthority"
142- subordinateCaResourcePermission := "arn:aws :ram::aws:permission/AWSRAMSubordinateCACertificatePathLen0IssuanceCertificateAuthority"
144+ endEntityResourcePermission := "arn:" + testContext . partition + " :ram::aws:permission/AWSRAMDefaultPermissionCertificateAuthority"
145+ subordinateCaResourcePermission := "arn:" + testContext . partition + " :ram::aws:permission/AWSRAMSubordinateCACertificatePathLen0IssuanceCertificateAuthority"
143146
144147 testContext .endEntityResourceShareArn = shareCA (ctx , cfg , testContext .xaCfg , testContext .caArns ["XA" ], endEntityResourcePermission )
145148 testContext .subordinateCaResourceShareArn = shareCA (ctx , cfg , testContext .xaCfg , testContext .caArns ["XA" ], subordinateCaResourcePermission )
@@ -174,10 +177,10 @@ func InitializeTestSuite(suiteCtx *godog.TestSuiteContext) {
174177 panic (cfgErr .Error ())
175178 }
176179
177- deleteCertificateAuthority (ctx , cfg , testContext . caArns [ "RSA" ] )
180+ testContext . deleteCertificateAuthority (ctx , cfg , "RSA" )
178181 log .Printf ("Deleted the RSA CA" )
179182
180- deleteCertificateAuthority (ctx , cfg , testContext . caArns [ "ECDSA" ] )
183+ testContext . deleteCertificateAuthority (ctx , cfg , "ECDSA" )
181184 log .Printf ("Deleted the EC CA" )
182185
183186 deleteAccessKey (ctx , cfg , testContext .userName , testContext .accessKey )
@@ -198,7 +201,7 @@ func InitializeTestSuite(suiteCtx *godog.TestSuiteContext) {
198201 deleteResourceShare (ctx , testContext .xaCfg , testContext .subordinateCaResourceShareArn )
199202 log .Printf ("Deleted resource shares associated with XA CA" )
200203
201- deleteCertificateAuthority (ctx , testContext .xaCfg , testContext . caArns [ "XA" ] )
204+ testContext . deleteCertificateAuthority (ctx , testContext .xaCfg , "XA" )
202205 log .Printf ("Deleted the XA CA" )
203206 }
204207 })
0 commit comments