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 all 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
2 changes: 1 addition & 1 deletion .docker/Dockerfile-alpine
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.15
FROM alpine:3.18.4

RUN addgroup -S ory; \
adduser -S ory -G ory -D -h /home/ory -s /bin/nologin; \
Expand Down
2 changes: 1 addition & 1 deletion .docker/Dockerfile-build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19-alpine3.16 AS builder
FROM golang:1.21-alpine3.18 AS builder

RUN apk -U --no-cache add build-base git gcc bash

Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export GO111MODULE := on
export PATH := .bin:${PATH}
export PWD := $(shell pwd)

GOLANGCI_LINT_VERSION = 1.48.0
GOLANGCI_LINT_VERSION = 1.55.2

GO_DEPENDENCIES = github.com/ory/go-acc \
github.com/golang/mock/mockgen \
Expand Down Expand Up @@ -72,7 +72,6 @@ licenses: .bin/licenses node_modules # checks open-source licenses
docker:
docker build -f .docker/Dockerfile-build -t oryd/ory:latest-sqlite .


# Runs tests in short mode, without database adapters
.PHONY: post-release
post-release:
Expand Down
5 changes: 0 additions & 5 deletions cmd/cloudx/accountexperience/accountexperience_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,9 @@ import (
"testing"

"github.com/stretchr/testify/require"

"github.com/ory/cli/cmd/cloudx/testhelpers"
)

var _, _, _, _, defaultProject, defaultCmd = testhelpers.CreateDefaultAssets()

func TestOpenAXPages(t *testing.T) {

t.Run("is able to open login page", func(t *testing.T) {
var pages = [5]string{"login", "registration", "recovery", "verification", "settings"}
for _, p := range pages {
Expand Down
21 changes: 21 additions & 0 deletions cmd/cloudx/accountexperience/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright © 2023 Ory Corp
// SPDX-License-Identifier: Apache-2.0

package accountexperience_test

import (
"testing"

"github.com/ory/cli/cmd/cloudx/testhelpers"
"github.com/ory/x/cmdx"
)

var (
defaultProject, defaultConfig, defaultEmail, defaultPassword string
defaultCmd *cmdx.CommandExecuter
)

func TestMain(m *testing.M) {
defaultConfig, defaultEmail, defaultPassword, _, defaultProject, defaultCmd = testhelpers.CreateDefaultAssets()
testhelpers.RunAgainstStaging(m)
}
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
21 changes: 21 additions & 0 deletions cmd/cloudx/client/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright © 2023 Ory Corp
// SPDX-License-Identifier: Apache-2.0

package client_test

import (
"testing"

"github.com/ory/cli/cmd/cloudx/testhelpers"
"github.com/ory/x/cmdx"
)

var (
defaultProject, defaultConfig, defaultEmail, defaultPassword string
defaultCmd *cmdx.CommandExecuter
)

func TestMain(m *testing.M) {
defaultConfig, defaultEmail, defaultPassword, _, defaultProject, defaultCmd = testhelpers.CreateDefaultAssets()
testhelpers.RunAgainstStaging(m)
}
Loading
Loading