PasswordUtil Object
Supported on UFT One versions 2021 R1 and later.
Description
Enables you to use a credential management service to manage secrets and passwords used in your UFT One tests.
Currently, UFT One supports only AWS Secrets Manager and Azure Key Vault service.
Methods
Connect | Connects UFT One to a credential management service. |
Disconnect | Disconnects UFT One from a credential management service. |
GetSecret | Gets the value of a secret stored in a credential management service. |
ListSecrets | Lists the names of secrets stored in a credential management service. |
SetSecret | Creates a secret to be saved in a credential management service. |
Setting | Enables you to configure settings for connecting to a credential management service. |
Connect Method
Description
Connects UFT One to a credential management service.
Syntax
PasswordUtil.Connect(serviceName, [settings])
Argument | Type | Description |
---|---|---|
serviceName | String | The credential management service you want UFT One to connect to. Possible values:
|
settings | String | Optional. The settings required to connect to a credential management service. |
Return Value
A Boolean.
IMPORTANT
Use one of the following ways to connect to a credential management service:
Define the connection information in the Tools > Options > GUI Testing > Credential Manager pane and then use the Connect method (use an empty string as serviceName and leave settings empty). See the example.
Note: In this case, UFT One connects to only the credential management service selected in the Credential Manager pane.
Define the connection information using the Setting method and then use the Connect method with serviceName set to a service. See the example.
Use only the Connect method with both parameters specified. See the example.
Example
Suppose you have already defined the connection information in the Tools > Options > GUI Testing > Credential Manager pane, you can use the following syntax to connect to a credential management service:
PasswordUtil.Connect("")
This example defines connection information using the Setting method and then uses the Connect method to connect to Azure Key Vault service.
PasswordUtil.Setting "keyVaultName", "xxxxx"
PasswordUtil.Setting "tenantId", "xxxxx"
PasswordUtil.Setting "clientId", "xxxxx"
PasswordUtil.Setting "clientSecret", "xxxxxx"
PasswordUtil.Connect("Azure Key Vault")
This example uses only the Connect method to connect to Azure Key Vault service.
PasswordUtil.Connect("Azure Key Vault", {
"tenantId": "xxx",
"clientId": "xxx",
"clientSecret": "xxx",
"keyVaultName": "xxx",
})
Disconnect Method
Description
Disconnects UFT One from a credential management service.
Syntax
PasswordUtil.Disconnect([serviceName])
Argument | Type | Description |
---|---|---|
serviceName | String | Optional. The credential management service you want UFT One to disconnect from. Possible values:
|
Return Value
None.
IMPORTANT
To connect to a different credential management service, make sure to add a PasswordUtil.Disconnect step to disconnect from the current connection.
The following example disconnects UFT One from AWS Secrets Manager if the connection result is successful.
ret = PasswordUtil.Connect("AWS Secrets Manager")
If ret Then
PasswordUtil.Disconnect "AWS Secrets Manager"
End If
GetSecret Method
Description
Gets the value of a secret stored in a credential management service.
Syntax
PasswordUtil.GetSecret(name)
Argument | Type | Description |
---|---|---|
name | String | The name of a secret stored in a credential management service. |
Return Value
A string.
This example first connects UFT One to Azure Key Vault service and then gets the value of a secret named FirstKey.
PasswordUtil.Connect("Azure Key Vault")
name = "FirstKey"
value = PasswordUtil.GetSecret("name")
Print value
ListSecrets Method
Description
Lists the names of secrets stored in a credential management service.
Syntax
PasswordUtil.ListSecrets
Return Value
A string array.
IMPORTANT
UFT One version 2021 R1: When listing secrets stored in AWS Secret Manager, only the 10 secrets stored earliest are listed.
This example uses the ListSecrets method to return the total number of secrets and the name and value of each secret.
Set list = Nothing
Set list = PasswordUtil.ListSecrets
If list Is Nothing Then
Reporter.ReportEvent micFail, "invalid settings", "Failed"
Else
Reporter.ReportEvent micDone, "List Count", "list=" & list.Count
For Each e in list
Reporter.ReportEvent micDone, "Key Name: "&e, "Key Secret: " & PasswordUtil.GetSecret(e)
Next
End If
SetSecret Method
Description
Creates a secret to be saved in a credential management service.
Syntax
PasswordUtil.SetSecret(name, value)
Argument | Type | Description |
---|---|---|
name | String | The name of a secret to be saved in a credential management service. |
value | String | The value of the secret. Note: For a secret to be saved in AWS Secrets Manager, you can set the value to a single string or a JSON string with key-value pairs. However, a single string cannot be converted to a key-value secret on AWS Secrets Manager service page.
|
Return Value
None
IMPORTANT
Make sure that you specify the KMS key ID before you use this method to create a secret in AWS Secrets Manager. You can either define the KMS key ID in the Tools > Options > GUI Testing > Credential Manager pane or use the Setting Method.
This example first creates a secret named FirstKey and then returns the value of the secret.
PasswordUtil.SetSecret "FirstKey", "1"
value = PasswordUtil.GetSecret("FirstKey")
Print value
Setting Method
Description
Enables you to configure settings for connecting to a credential management service.
Syntax
PasswordUtil.Setting(name, value)
Argument | Type | Description |
---|---|---|
name | String | The name of a parameter used for connecting to a credential management service. Possible values:
|
value | String | The value of the parameter. |
Return Value
None
IMPORTANT
To successfully connect to Azure Key Vault service, you must specify the values of tenantId, clientId, clientSecret, and keyVaultName.
To successfully connect to AWS Secrets Manager service, you must specify the values of regionEndpoint, accessKeyId, and secretAccessKey.
This method overwrites the existing connection information defined in the Tools > Options > GUI Testing > Credential Manager pane.
This example configures the required parameters and connects UFT One to Azure Key Vault service.
PasswordUtil.Setting "keyVaultName", "xxxxx"
PasswordUtil.Setting "tenantId", "xxxxx"
PasswordUtil.Setting "clientId", "xxxxx"
PasswordUtil.Setting "clientSecret", "xxxxxx"
PasswordUtil.Connect("Azure Key Vault")
See also:
- Crypt Object
- DataTable Object
- Description Object
- DeviceReplay Object
- DotNetFactory Object
- DTParameter Object
- DTSheet Object
- Environment Object
- Extern Object
- Parameter Object
- JSON Object
- JsonUtil Object
- MercuryTimers Object (Collection)
- MercuryTimer Object
- NV Object
- OptionalStep Object
- ParallelUtil Object
- LocalParameter Object
- PasswordUtil Object
- PathFinder Object
- PDFUtil Object
- Properties Object (Collection)
- QCUtil Object
- RandomNumber Object
- Recovery Object
- Remote Connection Object
- Reporter Object
- RepositoriesCollection Object
- Repository Object
- Services Object
- Setting Object
- SystemMonitor Object
- TestArgs Object
- TextUtil Object
- UIAutomation Object
- VisualRelation Object
- VisualRelations Object
- VisualRelationsCollection Object
- WebUtil Object
- XMLUtil Object