Skip to content

Commit

Permalink
Merge branch 'master' into remove-upgrade-md
Browse files Browse the repository at this point in the history
  • Loading branch information
zepatrik authored Aug 14, 2024
2 parents b0d105a + aaefcc6 commit 3b61076
Show file tree
Hide file tree
Showing 115 changed files with 4,672 additions and 4,162 deletions.
4 changes: 2 additions & 2 deletions .docker/Dockerfile-alpine
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM alpine:3.19
FROM alpine:3.20

RUN addgroup -S ory; \
adduser -S ory -G ory -D -h /home/ory -s /bin/nologin; \
chown -R ory:ory /home/ory

RUN apk add -U --no-cache ca-certificates
RUN apk add -U --no-cache ca-certificates libssl3 libcrypto3

COPY ory /usr/bin/ory

Expand Down
5 changes: 3 additions & 2 deletions .docker/Dockerfile-build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21-alpine3.19 AS builder
FROM golang:1.22-alpine3.20 AS builder

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

Expand All @@ -16,13 +16,14 @@ ADD . .

RUN CGO_CFLAGS="-D_LARGEFILE64_SOURCE" go build -tags sqlite,json1 -o /usr/bin/ory

FROM alpine:3.19
FROM alpine:3.20

RUN addgroup -S ory; \
adduser -S ory -G ory -D -h /home/ory -s /bin/nologin; \
chown -R ory:ory /home/ory

RUN apk add -U --no-cache ca-certificates
RUN apk upgrade --no-cache libssl3 libcrypto3

COPY --from=builder /usr/bin/ory /usr/bin/ory

Expand Down
23 changes: 13 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,23 @@ jobs:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: abhi1693/[email protected]
with:
browser: chrome
version: latest
- uses: ory/ci/checkout@master
- uses: actions/setup-go@v2
- uses: actions/setup-go@v5
with:
go-version: "1.22"
- uses: actions/cache@v4
with:
go-version: "1.21"
- run: |
make test
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('go.sum') }}
restore-keys: ${{ runner.os }}-playwright-
- run: go run github.com/playwright-community/playwright-go/cmd/playwright install chromium --with-deps
- run: make lint
- run: go test ./...
env:
ORY_RATE_LIMIT_HEADER: ${{ secrets.ORY_RATE_LIMIT_HEADER }}
ORY_CLOUD_CONSOLE_URL: https://console.staging.ory.dev
ORY_CLOUD_ORYAPIS_URL: https://staging.oryapis.dev
ORY_CONSOLE_URL: https://console.staging.ory.dev
ORY_ORYAPIS_URL: https://staging.oryapis.dev

docs:
name: Generate docs
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cve-scan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
severity-cutoff: critical
add-cpes-if-none: true
- name: Inspect action SARIF report
run: cat ${{ steps.scan.outputs.sarif }}
run: cat ${{ steps.scan.outputs.sarif }}
- name: Upload SARIF report
uses: github/codeql-action/upload-sarif@v2
with:
Expand All @@ -45,4 +45,4 @@ jobs:
output-format: table
fail-build: true
severity-cutoff: critical
add-cpes-if-none: true
add-cpes-if-none: true
2 changes: 1 addition & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.21
go-version: 1.22
- run: make format
- name: Indicate formatting issues
run: git diff HEAD --exit-code --color
2 changes: 1 addition & 1 deletion .github/workflows/licenses.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "1.21"
go-version: "1.22"
- uses: actions/setup-node@v2
with:
node-version: "18"
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "^1.21"
go-version: "1.22"
- uses: actions/setup-node@v2
with:
node-version: "16"
- run: |
go build -o ory .
./ory tunnel http://localhost:4001 --project admiring-tu-swczqlujc0 --quiet &
./ory tunnel http://localhost:4001 --quiet &
env:
ORY_API_KEY: ${{ secrets.ORY_PROJECT_API_KEY }}
- name: Install dependencies and run server
ORY_PROJECT_API_KEY: ${{ secrets.ORY_PROJECT_API_KEY }}
ORY_PROJECT_SLUG: admiring-tu-swczqlujc0
- name: Install dependencies
working-directory: cmd/cloudx/e2e
run: |
npm ci
Expand Down Expand Up @@ -53,15 +54,16 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "^1.21"
go-version: "1.22"
- uses: actions/setup-node@v2
with:
node-version: "16"
- run: |
go build -o ory .
./ory proxy https://ory-network-httpbin-ijakee5waq-ez.a.run.app/anything --rewrite-host --project admiring-tu-swczqlujc0 --quiet &
./ory proxy https://ory-network-httpbin-ijakee5waq-ez.a.run.app/anything --rewrite-host --quiet &
env:
ORY_API_KEY: ${{ secrets.ORY_PROJECT_API_KEY }}
ORY_PROJECT_API_KEY: ${{ secrets.ORY_PROJECT_API_KEY }}
ORY_PROJECT_SLUG: admiring-tu-swczqlujc0
- name: Install Node
working-directory: cmd/cloudx/e2e
run: |
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "^1.21"
go-version: "1.22"
- uses: actions/setup-node@v2
with:
node-version: "16"
- run: npm ci
- run: go build -o ory .
- run: |
go build -o ory .
./ory proxy https://ory-network-httpbin-ijakee5waq-ez.a.run.app --quiet --rewrite-host &
npm run test
env:
ORY_SDK_URL: https://affectionate-archimedes-s9mkjq77k0.projects.staging.oryapis.dev
ORY_CLOUD_CONSOLE_URL: https://console.staging.ory.dev
ORY_CLOUD_ORYAPIS_URL: https://staging.oryapis.dev
ORY_PROJECT_API_KEY: nokey
ORY_PROJECT_SLUG: affectionate-archimedes-s9mkjq77k0
ORY_CONSOLE_URL: https://console.staging.ory.dev
ORY_ORYAPIS_URL: https://staging.oryapis.dev
ORY_RATE_LIMIT_HEADER: ${{ secrets.ORY_RATE_LIMIT_HEADER }}
14 changes: 9 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,12 @@ checklist to contribute an example:
not get mixed up.
1. Add a descriptive prefix to commits. This ensures a uniform commit history
and helps structure the changelog. Please refer to this
[list of prefixes for CLI](https://github.com/ory/cli/blob/master/.github/semantic.yml)
for an overview.
[Convential Commits configuration](https://github.com/ory/cli/blob/master/.github/workflows/conventional_commits.yml)
for the list of accepted prefixes. You can read more about the Conventional
Commit specification
[at their site](https://www.conventionalcommits.org/en/v1.0.0/).
1. Create a `README.md` that explains how to use the example. (Use
[the README template](https://github.com/ory/examples/blob/master/_common/README)).
[the README template](https://github.com/ory/examples/blob/master/_common/README.md)).
1. Open a pull request and maintainers will review and merge your example.

## Contribute code
Expand All @@ -171,8 +173,10 @@ request, go through this checklist:
1. Run `make format`
1. Add a descriptive prefix to commits. This ensures a uniform commit history
and helps structure the changelog. Please refer to this
[list of prefixes for CLI](https://github.com/ory/cli/blob/master/.github/semantic.yml)
for an overview.
[Convential Commits configuration](https://github.com/ory/cli/blob/master/.github/workflows/conventional_commits.yml)
for the list of accepted prefixes. You can read more about the Conventional
Commit specification
[at their site](https://www.conventionalcommits.org/en/v1.0.0/).

If a pull request is not ready to be reviewed yet
[it should be marked as a "Draft"](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-stage-of-a-pull-request).
Expand Down
6 changes: 1 addition & 5 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.55.2
GOLANGCI_LINT_VERSION = 1.59.1

GO_DEPENDENCIES = github.com/ory/go-acc \
github.com/golang/mock/mockgen \
Expand Down Expand Up @@ -49,10 +49,6 @@ lint: .bin/golangci-lint-$(GOLANGCI_LINT_VERSION)
install:
GO111MODULE=on go install -tags sqlite .

.PHONY: test
test: lint
go test -p 1 -tags sqlite -count=1 -failfast ./...

.PHONY: refresh
refresh:
UPDATE_SNAPSHOTS=true go test -tags sqlite,json1,refresh ./...
Expand Down
79 changes: 36 additions & 43 deletions cmd/cloudx/accountexperience/accountexperience.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,65 +5,58 @@ package accountexperience

import (
"fmt"
"os"
"path"

"os/exec"

"github.com/pkg/browser"
"github.com/pkg/errors"
"github.com/spf13/cobra"

client "github.com/ory/cli/cmd/cloudx/client"
cloud "github.com/ory/client-go"
"github.com/ory/x/flagx"
"github.com/ory/x/stringsx"

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

func NewAccountExperienceOpenCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "account-experience [project-id]",
Args: cobra.MaximumNArgs(1),
Use: "account-experience <login|registration|recovery|verification|settings>",
Aliases: []string{"ax", "ui"},
Args: func(cmd *cobra.Command, args []string) error {
if err := cobra.ExactArgs(1)(cmd, args); err != nil {
return err
}
switch f := stringsx.SwitchExact(args[0]); {
case f.AddCase("login", "registration", "recovery", "verification", "settings"):
return nil
default:
return errors.Wrap(f.ToUnknownCaseErr(), "unknown flow type")
}
},
Short: "Open Ory Account Experience Pages",
}
var pages = [5]string{"login", "registration", "recovery", "verification", "settings"}
for _, p := range pages {
cmd.AddCommand(NewAxCmd(p))
}

return cmd
}

func NewAxCmd(cmd string) *cobra.Command {
return &cobra.Command{
Use: cmd,
Short: "Open " + cmd + " page",
RunE: func(cmd *cobra.Command, args []string) error {
h, err := client.NewCommandHelper(cmd)
h, err := client.NewCobraCommandHelper(cmd)
if err != nil {
return err
}
id, err := getSelectedProjectId(h, args)
if err != nil {
return cmdx.PrintOpenAPIError(cmd, err)
}
project, err := h.GetProject(id)

project, err := h.GetSelectedProject(cmd.Context())
if err != nil {
return cmdx.PrintOpenAPIError(cmd, err)
}
return AxWrapper(cmd, project)

}}
}

func AxWrapper(cmd *cobra.Command, p *cloud.Project) error {
url := fmt.Sprintf("https://%s.projects.oryapis.com/ui/%s", p.GetSlug(), cmd.CalledAs())

err := browser.OpenURL(url)
if err != nil {

// #nosec G204 - this is ok
if err := exec.Command("open", url); err != nil {
_, _ = fmt.Fprintf(os.Stderr, "Unable to automatically open the %s page in your browser. Please open it manually!", cmd.CalledAs())
}
url := client.CloudAPIsURL(project.Slug + ".projects")
url.Path = path.Join(url.Path, "ui", args[0])
if flagx.MustGetBool(cmd, cmdx.FlagQuiet) {
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "%s\n", url)
return nil
}
if err := h.OpenURL(url.String()); err != nil {
_, _ = fmt.Fprintf(cmd.ErrOrStderr(), "%s\n\nUnable to automatically open %s in your browser. Please open it manually!\n", err, url)
return cmdx.FailSilently(cmd)
}
return nil
},
}

return nil
cmdx.RegisterNoiseFlags(cmd.Flags())
return cmd
}
40 changes: 31 additions & 9 deletions cmd/cloudx/accountexperience/accountexperience_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,52 @@
package accountexperience_test

import (
"context"
"strings"
"testing"

cloud "github.com/ory/client-go"
"github.com/ory/x/cmdx"

"github.com/stretchr/testify/assert"

"github.com/stretchr/testify/require"

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

var (
defaultProject, defaultConfig, defaultEmail, defaultPassword string
defaultCmd *cmdx.CommandExecuter
ctx context.Context
project *cloud.Project
cmd *cmdx.CommandExecuter
)

func TestMain(m *testing.M) {
defaultConfig, defaultEmail, defaultPassword, _, defaultProject, defaultCmd = testhelpers.CreateDefaultAssets()
testhelpers.RunAgainstStaging(m)
ctx, _, _, project, cmd = testhelpers.CreateDefaultAssetsBrowser()
testhelpers.UseStaging()
m.Run()
}

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 {
_, stderr, err := defaultCmd.Exec(nil, "open", "account-experience", p, "--project", defaultProject)
t.Run("is able to open all pages", func(t *testing.T) {
for _, flowType := range []string{"login", "registration", "recovery", "verification", "settings"} {
cmd := testhelpers.Cmd(client.ContextWithOptions(ctx, client.WithOpenBrowserHook(func(uri string) error {
assert.Truef(t, strings.HasPrefix(uri, "https://"+project.Slug), "expected %q to have prefix %q", uri, "https://"+project.Slug)
assert.Contains(t, uri, flowType)
return nil
})))

stdout, stderr, err := cmd.Exec(nil, "open", "account-experience", flowType, "--quiet")
require.NoError(t, err, stderr)
assert.Contains(t, stdout, "https://"+project.Slug)
assert.Contains(t, stdout, flowType)
}
})

t.Run("errors on unknown flow type", func(t *testing.T) {
stdout, stderr, err := cmd.Exec(nil, "open", "account-experience", "unknown", "--quiet")
require.Error(t, err)
assert.Contains(t, stderr, "unknown flow type", stdout)
})
}
Loading

0 comments on commit 3b61076

Please sign in to comment.