Skip to content

Commit

Permalink
chore: synchronize workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Apr 5, 2024
1 parent f3b7ed0 commit f811fe5
Show file tree
Hide file tree
Showing 5 changed files with 352 additions and 15 deletions.
6 changes: 5 additions & 1 deletion cmd/cmd_create_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,11 @@ To encrypt an auto-generated OAuth2 Client Secret, use flags ` + "`--pgp-key`" +
}

secret := flagx.MustGetString(cmd, flagClientSecret)
cl := clientFromFlags(cmd)
cl.ClientId = pointerx.Ptr(flagx.MustGetString(cmd, flagClientId))

//nolint:bodyclose
client, _, err := m.OAuth2Api.CreateOAuth2Client(cmd.Context()).OAuth2Client(clientFromFlags(cmd)).Execute()
client, _, err := m.OAuth2Api.CreateOAuth2Client(cmd.Context()).OAuth2Client(cl).Execute()
if err != nil {
return cmdx.PrintOpenAPIError(cmd, err)
}
Expand All @@ -112,5 +115,6 @@ To encrypt an auto-generated OAuth2 Client Secret, use flags ` + "`--pgp-key`" +
},
}
registerClientFlags(cmd.Flags())
cmd.Flags().String(flagClientId, "", "Provide the client's id.")
return cmd
}
2 changes: 0 additions & 2 deletions cmd/cmd_helper_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ func clientFromFlags(cmd *cobra.Command) hydra.OAuth2Client {
Audience: flagx.MustGetStringSlice(cmd, flagClientAudience),
BackchannelLogoutSessionRequired: pointerx.Bool(flagx.MustGetBool(cmd, flagClientBackChannelLogoutSessionRequired)),
BackchannelLogoutUri: pointerx.String(flagx.MustGetString(cmd, flagClientBackchannelLogoutCallback)),
ClientId: pointerx.String(flagx.MustGetString(cmd, flagClientId)),
ClientName: pointerx.String(flagx.MustGetString(cmd, flagClientName)),
ClientSecret: pointerx.String(flagx.MustGetString(cmd, flagClientSecret)),
ClientUri: pointerx.String(flagx.MustGetString(cmd, flagClientClientURI)),
Expand Down Expand Up @@ -78,7 +77,6 @@ func registerClientFlags(flags *pflag.FlagSet) {
flags.String(flagClientLogoURI, "", "A URL string that references a logo for the client")
flags.StringSlice(flagClientAllowedCORSOrigin, []string{}, "The list of URLs allowed to make CORS requests. Requires CORS_ENABLED.")
flags.String(flagClientSubjectType, "public", "A identifier algorithm. Valid values are `public` and `pairwise`.")
flags.String(flagClientId, "", "Provide the client's id.")
flags.String(flagClientSecret, "", "Provide the client's secret.")
flags.String(flagClientName, "", "The client's name.")
flags.StringSlice(flagClientPostLogoutCallback, []string{}, "List of allowed URLs to be redirected to after a logout.")
Expand Down
4 changes: 0 additions & 4 deletions cmd/cmd_update_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ To encrypt an auto-generated OAuth2 Client Secret, use flags ` + "`--pgp-key`" +
}

id := args[0]
if f := cmd.Flag(flagClientId); f.Changed {
_, _ = fmt.Fprintf(cmd.ErrOrStderr(), "client id cannot be updated")
return cmdx.FailSilently(cmd)
}
cc := clientFromFlags(cmd)

client, _, err := m.OAuth2Api.SetOAuth2Client(context.Background(), id).OAuth2Client(cc).Execute() //nolint:bodyclose
Expand Down
8 changes: 0 additions & 8 deletions cmd/cmd_update_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,4 @@ func TestUpdateClient(t *testing.T) {

snapshotx.SnapshotT(t, json.RawMessage(actual.Raw), snapshotExcludedClientFields...)
})

t.Run("case=clientID error", func(t *testing.T) {
actual := gjson.Parse(cmdx.ExecExpectedErr(t, c,
original.GetID(),
"--id", "new-id",
))
assert.Empty(t, actual)
})
}
Loading

0 comments on commit f811fe5

Please sign in to comment.