@@ -238,6 +238,41 @@ func CreateStaticCredentialUsernamePasswordCli(t testing.TB, ctx context.Context
238238 return credentialId , nil
239239}
240240
241+ // CreateStaticCredentialPasswordCli uses the cli to create a new password credential in the
242+ // provided static credential store.
243+ // Returns the id of the new credential
244+ func CreateStaticCredentialPasswordCli (t testing.TB , ctx context.Context , credentialStoreId string , password string ) (string , error ) {
245+ name , err := base62 .Random (16 )
246+ if err != nil {
247+ return "" , err
248+ }
249+
250+ output := e2e .RunCommand (ctx , "boundary" ,
251+ e2e .WithArgs (
252+ "credentials" , "create" , "password" ,
253+ "-credential-store-id" , credentialStoreId ,
254+ "-password" , "env://E2E_CREDENTIALS_PASSWORD" ,
255+ "-name" , fmt .Sprintf ("e2e Credential %s" , name ),
256+ "-description" , "e2e" ,
257+ "-format" , "json" ,
258+ ),
259+ e2e .WithEnv ("E2E_CREDENTIALS_PASSWORD" , password ),
260+ )
261+ if output .Err != nil {
262+ return "" , fmt .Errorf ("%w: %s" , output .Err , string (output .Stderr ))
263+ }
264+
265+ var createCredentialsResult credentials.CredentialCreateResult
266+ err = json .Unmarshal (output .Stdout , & createCredentialsResult )
267+ if err != nil {
268+ return "" , err
269+ }
270+
271+ credentialId := createCredentialsResult .Item .Id
272+ t .Logf ("Created Password Credential: %s" , credentialId )
273+ return credentialId , nil
274+ }
275+
241276// CreateStaticCredentialUsernamePasswordDomainCli uses the cli to create a new username password domain credential in the
242277// provided static credential store.
243278// Returns the id of the new credential
0 commit comments