Skip to content

Commit

Permalink
Bugfix improve connection test (#174)
Browse files Browse the repository at this point in the history
* Improve connection testing

for each connection:
- Perform simple test
- improve error message per connection

* Update sync.go
  • Loading branch information
ChrisPates authored Mar 4, 2024
1 parent 7bf47b6 commit 27254c2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions internal/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@ func DoSync(ctx context.Context, cfg *config.Config) error {

googleClient, err := google.NewClient(ctx, cfg.GoogleAdmin, creds)
if err != nil {
log.WithField("error", err).Warn("Problem establising a connection to Google directory")
return err
}

Expand All @@ -731,6 +732,7 @@ func DoSync(ctx context.Context, cfg *config.Config) error {
Token: cfg.SCIMAccessToken,
})
if err != nil {
log.WithField("error", err).Warn("Problem establising a SCIM connection to AWS IAM Identity Center")
return err
}

Expand All @@ -741,12 +743,24 @@ func DoSync(ctx context.Context, cfg *config.Config) error {
})

if err != nil {
log.WithField("error", err).Warn("Problem establising a session for Identity Store")
return err
}

// Initialize AWS Identity Store Public API Client with session
identityStoreClient := identitystore.New(sess)

response, err := identityStoreClient.ListGroups(
&identitystore.ListGroupsInput{IdentityStoreId: &cfg.IdentityStoreID})

if err != nil {
log.WithField("error", err).Warn("Problem performing test query against Identity Store")
return err
} else {

Check failure on line 759 in internal/sync.go

View workflow job for this annotation

GitHub Actions / test

if block ends with a return statement, so drop this else and outdent its block
log.WithField("Groups", response).Info("Test call for groups successful")

}

// Initialize sync client with
// 1. SCIM API client
// 2. Google Directory API client
Expand Down

0 comments on commit 27254c2

Please sign in to comment.