Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade go SDK #319

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/cloudx/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func TestAuthenticator(t *testing.T) {
c, err := client.NewKratosClient()
require.NoError(t, err)

flow, _, err := c.FrontendApi.CreateNativeSettingsFlow(context.Background()).XSessionToken(ac.SessionToken).Execute()
flow, _, err := c.FrontendAPI.CreateNativeSettingsFlow(context.Background()).XSessionToken(ac.SessionToken).Execute()
require.NoError(t, err)

var secret string
Expand All @@ -136,7 +136,7 @@ func TestAuthenticator(t *testing.T) {
code, err := totp.GenerateCode(secret, time.Now())
require.NoError(t, err)

_, _, err = c.FrontendApi.UpdateSettingsFlow(context.Background()).XSessionToken(ac.SessionToken).Flow(flow.Id).UpdateSettingsFlowBody(cloud.UpdateSettingsFlowBody{
_, _, err = c.FrontendAPI.UpdateSettingsFlow(context.Background()).XSessionToken(ac.SessionToken).Flow(flow.Id).UpdateSettingsFlowBody(cloud.UpdateSettingsFlowBody{
UpdateSettingsFlowWithTotpMethod: &cloud.UpdateSettingsFlowWithTotpMethod{
TotpCode: pointerx.String(code),
Method: "totp",
Expand Down
5 changes: 5 additions & 0 deletions cmd/cloudx/client/form.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ func renderForm(stdin *bufio.Reader, pwReader passwordReader, stderr io.Writer,
continue
}

// Skip details like Company, Phone, etc.
if strings.HasPrefix(attrs.Name, "traits.details") {
continue
}

if attrs.Name == "traits.consent.tos" {
for {
ok, err := cmdx.AskScannerForConfirmation(getLabel(attrs, &node), stdin, stderr)
Expand Down
30 changes: 15 additions & 15 deletions cmd/cloudx/client/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func (h *CommandHelper) HasValidContext() (*AuthContext, bool, error) {
return nil, false, err
}

sess, _, err := client.FrontendApi.ToSession(h.Ctx).XSessionToken(c.SessionToken).Execute()
sess, _, err := client.FrontendAPI.ToSession(h.Ctx).XSessionToken(c.SessionToken).Execute()
if err != nil {
return nil, false, nil
} else if sess == nil {
Expand Down Expand Up @@ -282,7 +282,7 @@ func (h *CommandHelper) getField(i interface{}, path string) (*gjson.Result, err
}

func (h *CommandHelper) signup(c *cloud.APIClient) (*AuthContext, error) {
flow, _, err := c.FrontendApi.CreateNativeRegistrationFlow(h.Ctx).Execute()
flow, _, err := c.FrontendAPI.CreateNativeRegistrationFlow(h.Ctx).Execute()
if err != nil {
return nil, err
}
Expand All @@ -299,7 +299,7 @@ retryRegistration:
return nil, err
}

signup, _, err := c.FrontendApi.UpdateRegistrationFlow(h.Ctx).
signup, _, err := c.FrontendAPI.UpdateRegistrationFlow(h.Ctx).
Flow(flow.Id).UpdateRegistrationFlowBody(cloud.UpdateRegistrationFlowBody{
UpdateRegistrationFlowWithPasswordMethod: &form,
}).Execute()
Expand All @@ -319,7 +319,7 @@ retryRegistration:
}

sessionToken := *signup.SessionToken
sess, _, err := c.FrontendApi.ToSession(h.Ctx).XSessionToken(sessionToken).Execute()
sess, _, err := c.FrontendAPI.ToSession(h.Ctx).XSessionToken(sessionToken).Execute()
if err != nil {
return nil, err
}
Expand All @@ -328,7 +328,7 @@ retryRegistration:
}

func (h *CommandHelper) signin(c *cloud.APIClient, sessionToken string) (*AuthContext, error) {
req := c.FrontendApi.CreateNativeLoginFlow(h.Ctx)
req := c.FrontendAPI.CreateNativeLoginFlow(h.Ctx)
if len(sessionToken) > 0 {
req = req.XSessionToken(sessionToken).Aal("aal2")
}
Expand Down Expand Up @@ -382,7 +382,7 @@ retryLogin:
panic("unexpected type")
}

login, _, err := c.FrontendApi.UpdateLoginFlow(h.Ctx).XSessionToken(sessionToken).
login, _, err := c.FrontendAPI.UpdateLoginFlow(h.Ctx).XSessionToken(sessionToken).
Flow(flow.Id).UpdateLoginFlowBody(body).Execute()
if err != nil {
if e, ok := err.(*cloud.GenericOpenAPIError); ok {
Expand All @@ -400,7 +400,7 @@ retryLogin:
}

sessionToken = stringsx.Coalesce(*login.SessionToken, sessionToken)
sess, _, err := c.FrontendApi.ToSession(h.Ctx).XSessionToken(sessionToken).Execute()
sess, _, err := c.FrontendAPI.ToSession(h.Ctx).XSessionToken(sessionToken).Execute()
if err == nil {
return h.sessionToContext(sess, sessionToken)
}
Expand Down Expand Up @@ -510,7 +510,7 @@ func (h *CommandHelper) ListProjects() ([]cloud.ProjectMetadata, error) {
return nil, err
}

projects, res, err := c.ProjectApi.ListProjects(h.Ctx).Execute()
projects, res, err := c.ProjectAPI.ListProjects(h.Ctx).Execute()
if err != nil {
return nil, handleError("unable to list projects", res, err)
}
Expand Down Expand Up @@ -555,7 +555,7 @@ func (h *CommandHelper) GetProject(projectOrSlug string) (*cloud.Project, error)
}
}

project, res, err := c.ProjectApi.GetProject(h.Ctx, id.String()).Execute()
project, res, err := c.ProjectAPI.GetProject(h.Ctx, id.String()).Execute()
if err != nil {
return nil, handleError("unable to get project", res, err)
}
Expand All @@ -574,7 +574,7 @@ func (h *CommandHelper) CreateProject(name string, setDefault bool) (*cloud.Proj
return nil, err
}

project, res, err := c.ProjectApi.CreateProject(h.Ctx).CreateProjectBody(*cloud.NewCreateProjectBody(strings.TrimSpace(name))).Execute()
project, res, err := c.ProjectAPI.CreateProject(h.Ctx).CreateProjectBody(*cloud.NewCreateProjectBody(strings.TrimSpace(name))).Execute()
if err != nil {
return nil, handleError("unable to list projects", res, err)
}
Expand Down Expand Up @@ -666,7 +666,7 @@ func (h *CommandHelper) PatchProject(id string, raw []json.RawMessage, add, repl
patches = append(patches, cloud.JsonPatch{Op: "remove", Path: del})
}

res, _, err := c.ProjectApi.PatchProject(h.Ctx, id).JsonPatch(patches).Execute()
res, _, err := c.ProjectAPI.PatchProject(h.Ctx, id).JsonPatch(patches).Execute()
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -730,14 +730,14 @@ func (h *CommandHelper) UpdateProject(id string, name string, configs []json.Raw
if name != "" {
payload.Name = name
} else if payload.Name == "" {
res, _, err := c.ProjectApi.GetProject(h.Ctx, id).Execute()
res, _, err := c.ProjectAPI.GetProject(h.Ctx, id).Execute()
if err != nil {
return nil, errors.WithStack(err)
}
payload.Name = res.Name
}

res, _, err := c.ProjectApi.SetProject(h.Ctx, id).SetProject(payload).Execute()
res, _, err := c.ProjectAPI.SetProject(h.Ctx, id).SetProject(payload).Execute()
if err != nil {
return nil, err
}
Expand All @@ -756,7 +756,7 @@ func (h *CommandHelper) CreateAPIKey(projectIdOrSlug, name string) (*cloud.Proje
return nil, err
}

token, _, err := c.ProjectApi.CreateProjectApiKey(h.Ctx, projectIdOrSlug).CreateProjectApiKeyRequest(cloud.CreateProjectApiKeyRequest{Name: name}).Execute()
token, _, err := c.ProjectAPI.CreateProjectApiKey(h.Ctx, projectIdOrSlug).CreateProjectApiKeyRequest(cloud.CreateProjectApiKeyRequest{Name: name}).Execute()
if err != nil {
return nil, err
}
Expand All @@ -775,7 +775,7 @@ func (h *CommandHelper) DeleteAPIKey(projectIdOrSlug, id string) error {
return err
}

if _, err := c.ProjectApi.DeleteProjectApiKey(h.Ctx, projectIdOrSlug, id).Execute(); err != nil {
if _, err := c.ProjectAPI.DeleteProjectApiKey(h.Ctx, projectIdOrSlug, id).Execute(); err != nil {
return err
}

Expand Down
5 changes: 3 additions & 2 deletions cmd/cloudx/testhelpers/testhelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func AssertConfig(t *testing.T, configDir string, email string, name string, new
c, err := client.NewKratosClient()
require.NoError(t, err)

res, _, err := c.FrontendApi.ToSession(context.Background()).XSessionToken(ac.SessionToken).Execute()
res, _, err := c.FrontendAPI.ToSession(context.Background()).XSessionToken(ac.SessionToken).Execute()
require.NoError(t, err)

traits, err := json.Marshal(res.Identity.Traits)
Expand All @@ -83,7 +83,8 @@ func AssertConfig(t *testing.T, configDir string, email string, name string, new
"consent": {
"newsletter": `+fmt.Sprintf("%v", newsletter)+`,
"tos": ""
}
},
"details": {}
}`), json.RawMessage(traits), []string{"consent.tos"})
assert.NotEmpty(t, gjson.GetBytes(traits, "consent.tos").String())
}
Expand Down
26 changes: 13 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ require (
github.com/hashicorp/go-retryablehttp v0.7.1
github.com/imdario/mergo v0.3.13
github.com/jackc/pgx/v4 v4.17.2
github.com/ory/client-go v1.1.4
github.com/ory/client-go v1.3.0
github.com/ory/gochimp3 v0.0.0-20200417124117-ccd242db3655
github.com/ory/graceful v0.1.3
github.com/ory/herodot v0.9.13
Expand All @@ -38,19 +38,20 @@ require (
github.com/ory/keto v0.10.0-alpha.0.0.20221026143738-31e323a91b68
github.com/ory/kratos v0.10.2-0.20221108163448-d3d148b3a589
github.com/ory/x v0.0.511-0.20221108105728-3fed9bc99daf
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
github.com/pkg/errors v0.9.1
github.com/pquerna/otp v1.3.0
github.com/rs/cors v1.8.2
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06
github.com/spf13/cobra v1.6.1
github.com/spf13/pflag v1.0.5
github.com/square/go-jose/v3 v3.0.0-20200630053402-0a67ce9b0693
github.com/stretchr/testify v1.8.1
github.com/stretchr/testify v1.8.4
github.com/tidwall/gjson v1.14.3
github.com/tidwall/sjson v1.2.5
github.com/urfave/negroni v1.0.0
golang.org/x/term v0.3.0
golang.org/x/text v0.5.0
golang.org/x/term v0.14.0
golang.org/x/text v0.14.0
gopkg.in/yaml.v2 v2.4.0
)

Expand Down Expand Up @@ -144,7 +145,7 @@ require (
github.com/golang/glog v1.0.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/certificate-transparency-go v1.1.2-0.20210511102531-373a877eec92 // indirect
github.com/google/go-github/v27 v27.0.1 // indirect
Expand Down Expand Up @@ -231,7 +232,6 @@ require (
github.com/pborman/uuid v1.2.1 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/philhofer/fwd v1.1.1 // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/pkg/profile v1.7.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pquerna/cachecontrol v0.1.0 // indirect
Expand Down Expand Up @@ -311,21 +311,21 @@ require (
go.uber.org/automaxprocs v1.3.0 // indirect
go.uber.org/multierr v1.7.0 // indirect
go.uber.org/zap v1.17.0 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/crypto v0.15.0 // indirect
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/mod v0.6.0 // indirect
golang.org/x/net v0.4.0 // indirect
golang.org/x/oauth2 v0.3.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/oauth2 v0.14.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/time v0.1.0 // indirect
golang.org/x/tools v0.2.0 // indirect
golang.org/x/tools v0.6.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20221025140454-527a21cfbd71 // indirect
google.golang.org/grpc v1.50.1 // indirect
google.golang.org/protobuf v1.28.1 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/DataDog/dd-trace-go.v1 v1.43.0 // indirect
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/cheggaaa/pb.v1 v1.0.28 // indirect
Expand Down
Loading
Loading