-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add writing managed accounts feature in terraform provider
- Loading branch information
1 parent
cddb485
commit 5fbb8d0
Showing
5 changed files
with
569 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,9 @@ import ( | |
"time" | ||
|
||
"github.com/BeyondTrust/go-client-library-passwordsafe/api/authentication" | ||
"github.com/BeyondTrust/go-client-library-passwordsafe/api/entities" | ||
logging "github.com/BeyondTrust/go-client-library-passwordsafe/api/logging" | ||
managed_accounts "github.com/BeyondTrust/go-client-library-passwordsafe/api/managed_account" | ||
"github.com/BeyondTrust/go-client-library-passwordsafe/api/secrets" | ||
"github.com/BeyondTrust/go-client-library-passwordsafe/api/utils" | ||
|
||
//"os" | ||
|
@@ -26,9 +26,9 @@ func main() { | |
// create a zap logger wrapper | ||
zapLogger := logging.NewZapLogger(logger) | ||
|
||
apiUrl := "https://example.com:443/BeyondTrust/api/public/v3/" | ||
clientId := "" | ||
clientSecret := "" | ||
apiUrl := "https://jury2310.ps-dev.beyondtrustcloud.com:443/BeyondTrust/api/public/v3" | ||
clientId := "6138d050-e266-4b05-9ced-35e7dd5093ae" | ||
clientSecret := "71svdPLh2AR97sPs5gfPjGjpqSUxZTKSPmEvvbMx89o=" | ||
separator := "/" | ||
certificate := "" | ||
certificateKey := "" | ||
|
@@ -79,38 +79,51 @@ func main() { | |
return | ||
} | ||
|
||
// instantiating secret obj | ||
secretObj, _ := secrets.NewSecretObj(*authenticate, zapLogger, maxFileSecretSizeBytes) | ||
|
||
secretPaths := []string{"fake/Client", "fake/test_file_1"} | ||
|
||
gotSecrets, _ := secretObj.GetSecrets(secretPaths, separator) | ||
|
||
// WARNING: Do not log secrets in production code, the following log statement logs test secrets for testing purposes: | ||
zapLogger.Warn(fmt.Sprintf("%v", gotSecrets)) | ||
|
||
// getting single secret | ||
gotSecret, _ := secretObj.GetSecret("fake/Test1", separator) | ||
|
||
// WARNING: Do not log secrets in production code, the following log statement logs test secrets for testing purposes: | ||
zapLogger.Warn(fmt.Sprintf("Secret Test: %v", gotSecret)) | ||
|
||
// instantiating managed account obj | ||
manageAccountObj, _ := managed_accounts.NewManagedAccountObj(*authenticate, zapLogger) | ||
|
||
newSecretPaths := []string{"fake/account01", "fake/account01"} | ||
|
||
//managedAccountList := strings.Split(paths, ",") | ||
gotManagedAccounts, _ := manageAccountObj.GetSecrets(newSecretPaths, separator) | ||
account := entities.AccountDetails{ | ||
AccountName: "ManagedAccountTestqw", | ||
Password: "Passw0rd101!*", | ||
DomainName: "exampleDomain", | ||
UserPrincipalName: "[email protected]", | ||
SAMAccountName: "samAccount", | ||
DistinguishedName: "CN=example,CN=Users,DC=domain,DC=com", | ||
PrivateKey: "privateKey", | ||
Passphrase: "passphrase", | ||
PasswordFallbackFlag: true, | ||
LoginAccountFlag: false, | ||
Description: "Sample account for testing", | ||
ApiEnabled: true, | ||
ReleaseNotificationEmail: "[email protected]", | ||
ChangeServicesFlag: false, | ||
RestartServicesFlag: false, | ||
ChangeTasksFlag: true, | ||
MaxReleaseDuration: 300000, | ||
ISAReleaseDuration: 180, | ||
MaxConcurrentRequests: 5, | ||
AutoManagementFlag: false, | ||
DSSAutoManagementFlag: false, | ||
CheckPasswordFlag: true, | ||
ResetPasswordOnMismatchFlag: false, | ||
ChangePasswordAfterAnyReleaseFlag: true, | ||
ChangeFrequencyDays: 1, | ||
ChangeTime: "", | ||
NextChangeDate: "2023-12-01", | ||
UseOwnCredentials: true, | ||
ChangeWindowsAutoLogonFlag: true, | ||
ChangeComPlusFlag: false, | ||
ObjectID: "uniqueObjectID", | ||
} | ||
|
||
// WARNING: Do not log secrets in production code, the following log statement logs test secrets for testing purposes: | ||
zapLogger.Warn(fmt.Sprintf("%v", gotManagedAccounts)) | ||
// creating a managed account in system_integration_test managed system. | ||
createResponse, err := manageAccountObj.ManageAccountCreateFlow("system_integration_test", account) | ||
|
||
// getting single managed account | ||
gotManagedAccount, _ := manageAccountObj.GetSecret("fake/account04", separator) | ||
if err != nil { | ||
zapLogger.Debug(fmt.Sprintf(" %v", err)) | ||
} | ||
|
||
// WARNING: Do not log secrets in production code, the following log statement logs test secrets for testing purposes: | ||
zapLogger.Warn(fmt.Sprintf("%v", gotManagedAccount)) | ||
zapLogger.Warn(fmt.Sprintf("Created Managed Account: %v", createResponse.AccountName)) | ||
|
||
// signing out | ||
_ = authenticate.SignOut() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.