mirror of
https://github.com/int128/kubelogin.git
synced 2026-02-16 09:29:51 +00:00
Compare commits
212 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
25fe47156d | ||
|
|
67fc68f65b | ||
|
|
3ed6a20e3e | ||
|
|
b1cc7179ff | ||
|
|
337dbd4cae | ||
|
|
04c2e0a9a6 | ||
|
|
2c574c948d | ||
|
|
cad4c5b5fb | ||
|
|
fb31f2acd9 | ||
|
|
bd3f314f1d | ||
|
|
42c223539c | ||
|
|
5f26ba4ee6 | ||
|
|
068359b93a | ||
|
|
343b9ff4ed | ||
|
|
fb6c5d7ae3 | ||
|
|
dc6dddc009 | ||
|
|
1995c2b0e5 | ||
|
|
4aef3bd299 | ||
|
|
606e1a2d11 | ||
|
|
eeee4ef026 | ||
|
|
52cd0bd25d | ||
|
|
9034eddfc7 | ||
|
|
633fd054a1 | ||
|
|
cf4b2ca415 | ||
|
|
7651acaf0c | ||
|
|
c34db522e7 | ||
|
|
7a2e2e7bad | ||
|
|
c419f36e93 | ||
|
|
a5f98600ef | ||
|
|
0ecfc8aea5 | ||
|
|
1d424fc947 | ||
|
|
e45de0575f | ||
|
|
0f0e3c7f7e | ||
|
|
976dab0196 | ||
|
|
81fcd8ab34 | ||
|
|
d0ca921fd6 | ||
|
|
19d4f627ae | ||
|
|
b05e92d466 | ||
|
|
5d091e486a | ||
|
|
1ead2a405e | ||
|
|
7989388d83 | ||
|
|
f16e12936d | ||
|
|
0f2cde3591 | ||
|
|
50b0fa3062 | ||
|
|
7fa6697bdb | ||
|
|
c2a89014d1 | ||
|
|
acd7604d4a | ||
|
|
17c849135c | ||
|
|
014878d4c7 | ||
|
|
dc3fdc434f | ||
|
|
690a1a64dc | ||
|
|
fde8528ea3 | ||
|
|
c2e1465dda | ||
|
|
4f42ac5138 | ||
|
|
5316d46238 | ||
|
|
ca4eab5f17 | ||
|
|
902e694963 | ||
|
|
aa82d3a107 | ||
|
|
799a7b138d | ||
|
|
466105839b | ||
|
|
719af34708 | ||
|
|
026ec60f04 | ||
|
|
35f20c98c2 | ||
|
|
5f786ac423 | ||
|
|
44ab98257f | ||
|
|
b73d149a9e | ||
|
|
dd741fce15 | ||
|
|
8d224ee866 | ||
|
|
bd2ce318d7 | ||
|
|
f8c33893d7 | ||
|
|
9ad7e43415 | ||
|
|
1874ea7c43 | ||
|
|
1dc2019d3b | ||
|
|
9dca11677a | ||
|
|
0a9679797e | ||
|
|
138a2a4a48 | ||
|
|
f4acfb211f | ||
|
|
d0c8c0f10e | ||
|
|
716bd0b9df | ||
|
|
f6b3bf4e63 | ||
|
|
52a54047ed | ||
|
|
d88e7f0875 | ||
|
|
1893c5fecb | ||
|
|
8bac5fb984 | ||
|
|
ee6fd70e30 | ||
|
|
73eb5c6dfa | ||
|
|
27c67eafd0 | ||
|
|
1644acc61c | ||
|
|
ca1c300ef4 | ||
|
|
de030b2d82 | ||
|
|
fd10fc8c9b | ||
|
|
6b8a7c0aa7 | ||
|
|
976dcfaa3b | ||
|
|
aeb712f271 | ||
|
|
761b246ca4 | ||
|
|
24ef676cf7 | ||
|
|
c26eab41f8 | ||
|
|
032aa041ba | ||
|
|
1396ab6b01 | ||
|
|
b89d9a8afb | ||
|
|
8b6b32f769 | ||
|
|
94b39d9bfa | ||
|
|
a993e39ed1 | ||
|
|
7fc48592de | ||
|
|
fd9d3a8e9d | ||
|
|
3981c78387 | ||
|
|
8537977819 | ||
|
|
7e2658c061 | ||
|
|
346e7a5c9d | ||
|
|
5ec3ec713f | ||
|
|
0bdeca8526 | ||
|
|
dee7333343 | ||
|
|
2c9980a400 | ||
|
|
4b19fd7d43 | ||
|
|
04ba16a2dd | ||
|
|
395cbb8ec0 | ||
|
|
7bffbf1e99 | ||
|
|
b2dbe2beda | ||
|
|
cefacba2d2 | ||
|
|
0f2f54d4bf | ||
|
|
a85488b4fc | ||
|
|
064d67043c | ||
|
|
67bcc29e3d | ||
|
|
d24340b179 | ||
|
|
56300e733e | ||
|
|
e66ac72907 | ||
|
|
ed98ee4b07 | ||
|
|
ae6fc796d1 | ||
|
|
12d5a73ed6 | ||
|
|
6b78d60eb8 | ||
|
|
1714508e08 | ||
|
|
1985d7246f | ||
|
|
659ddc99e3 | ||
|
|
a7bbe92827 | ||
|
|
db764cd328 | ||
|
|
7af43af614 | ||
|
|
c7342f301b | ||
|
|
a4e614aa85 | ||
|
|
6e6de231c2 | ||
|
|
35e8f00003 | ||
|
|
751f5f72c7 | ||
|
|
655ae5717b | ||
|
|
aa92832adb | ||
|
|
f0a5aa7f6a | ||
|
|
8c6ac0d3ff | ||
|
|
127a4ace7c | ||
|
|
dd62bd0281 | ||
|
|
2794e6c805 | ||
|
|
342ace8aec | ||
|
|
259303299e | ||
|
|
64b42f8f8c | ||
|
|
31f182cc37 | ||
|
|
57873e9338 | ||
|
|
531792ba02 | ||
|
|
bd66f19bd5 | ||
|
|
951e1c4713 | ||
|
|
aed6620066 | ||
|
|
140b612357 | ||
|
|
efc5ce1571 | ||
|
|
c20af93fd4 | ||
|
|
6c7e7f7dad | ||
|
|
1af1bb2910 | ||
|
|
e1863154df | ||
|
|
c7736355b6 | ||
|
|
93d83b9365 | ||
|
|
d5f9e3c88e | ||
|
|
4d10746b42 | ||
|
|
b26cd49178 | ||
|
|
19aeb78113 | ||
|
|
b359f0de12 | ||
|
|
c91e9bee42 | ||
|
|
88fb3c2ea8 | ||
|
|
751469d3b9 | ||
|
|
c29ab9c8ce | ||
|
|
19e4da8f4d | ||
|
|
fcb4a27cde | ||
|
|
021bc77094 | ||
|
|
f9367d6fd1 | ||
|
|
516d8bae41 | ||
|
|
22153cc1f4 | ||
|
|
45dd932876 | ||
|
|
6b108ffb9d | ||
|
|
cf3063c3bf | ||
|
|
c7060d2ca5 | ||
|
|
8002eeb191 | ||
|
|
b95872b24f | ||
|
|
2d5775315f | ||
|
|
ba2e5e5fea | ||
|
|
525cdae92d | ||
|
|
30b7f47e70 | ||
|
|
284cd851ea | ||
|
|
4cf5b302fe | ||
|
|
63dcbeb6f5 | ||
|
|
ea6b3815bf | ||
|
|
a5f746ad6e | ||
|
|
434c69407e | ||
|
|
8ec95ed141 | ||
|
|
dee9032023 | ||
|
|
cb7a9742ac | ||
|
|
a3013a12b9 | ||
|
|
bc7e71f586 | ||
|
|
19d61e70a9 | ||
|
|
3a38753ee7 | ||
|
|
56e09ad65e | ||
|
|
58a4b1399f | ||
|
|
6726d851cb | ||
|
|
21e03dc294 | ||
|
|
5f1ed82a85 | ||
|
|
abb1a564f4 | ||
|
|
6d4eee5d1d | ||
|
|
4c10146639 | ||
|
|
3121e55498 |
11
.github/renovate.json
vendored
Normal file
11
.github/renovate.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"github>int128/renovate-base",
|
||||
"github>int128/go-renovate-config#v1.9.0",
|
||||
"github>int128/go-renovate-config:go-version-with-dockerfile#v1.9.0",
|
||||
"github>int128/go-renovate-config:kubernetes#v1.9.0",
|
||||
"github>int128/go-renovate-config:github-releases#v1.9.0(**/kustomization.yaml)",
|
||||
"helpers:pinGitHubActionDigests"
|
||||
]
|
||||
}
|
||||
12
.github/renovate.json5
vendored
12
.github/renovate.json5
vendored
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"github>int128/renovate-base",
|
||||
"github>int128/go-renovate-config#v1.7.2",
|
||||
"github>int128/go-renovate-config:go-directive#v1.7.2",
|
||||
"github>int128/go-renovate-config:github-actions#v1.7.2",
|
||||
"github>int128/go-renovate-config:kubernetes#v1.7.2",
|
||||
"github>int128/go-renovate-config:kustomization-github-releases#v1.7.2",
|
||||
"helpers:pinGitHubActionDigests",
|
||||
],
|
||||
}
|
||||
34
.github/workflows/acceptance-test.yaml
vendored
Normal file
34
.github/workflows/acceptance-test.yaml
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
name: acceptance-test
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- .github/workflows/acceptance-test.yaml
|
||||
- acceptance_test/**
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- .github/workflows/acceptance-test.yaml
|
||||
- acceptance_test/**
|
||||
|
||||
jobs:
|
||||
test-makefile:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
cache-dependency-path: go.sum
|
||||
- run: make -C acceptance_test check
|
||||
- run: make -C acceptance_test
|
||||
env:
|
||||
OIDC_ISSUER_URL: https://accounts.google.com
|
||||
OIDC_CLIENT_ID: REDACTED.apps.googleusercontent.com
|
||||
YOUR_EMAIL: REDACTED@gmail.com
|
||||
- run: make -C acceptance_test delete-cluster
|
||||
- run: make -C acceptance_test clean
|
||||
23
.github/workflows/docker.yaml
vendored
23
.github/workflows/docker.yaml
vendored
@@ -28,25 +28,25 @@ jobs:
|
||||
contents: read
|
||||
packages: write
|
||||
outputs:
|
||||
image-uri: ghcr.io/${{ github.repository }}@${{ steps.build.outputs.digest }}
|
||||
image-uri: ${{ steps.build-metadata.outputs.image-uri }}
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1
|
||||
- uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
|
||||
id: metadata
|
||||
with:
|
||||
images: ghcr.io/${{ github.repository }}
|
||||
- uses: int128/docker-build-cache-config-action@622932dfa73db7d3a65e40d5fcc094f2101e659a # v1.37.0
|
||||
- uses: int128/docker-build-cache-config-action@3a4a4fababc091be29633e5a2b3bbf523996802a # v1.47.0
|
||||
id: cache
|
||||
with:
|
||||
image: ghcr.io/${{ github.repository }}/cache
|
||||
- uses: docker/setup-qemu-action@53851d14592bedcffcf25ea515637cff71ef929a # v3.3.0
|
||||
- uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
|
||||
- uses: docker/build-push-action@67a2d409c0a876cbe6b11854e3e25193efe4e62d # v6.12.0
|
||||
- uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
|
||||
- uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
|
||||
- uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
|
||||
id: build
|
||||
with:
|
||||
push: ${{ github.event_name == 'push' }}
|
||||
@@ -58,9 +58,14 @@ jobs:
|
||||
linux/amd64
|
||||
linux/arm64
|
||||
linux/ppc64le
|
||||
- uses: int128/docker-build-metadata-action@84d7e640b499144c1ea8f428a9cdf83b5fc7bb35 # v2.0.0
|
||||
id: build-metadata
|
||||
with:
|
||||
tags: ${{ steps.metadata.outputs.tags }}
|
||||
digest: ${{ steps.build.outputs.digest }}
|
||||
|
||||
test:
|
||||
if: github.event_name == 'push'
|
||||
if: needs.build.outputs.image-uri != ''
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
|
||||
26
.github/workflows/go.yaml
vendored
26
.github/workflows/go.yaml
vendored
@@ -29,8 +29,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
cache-dependency-path: go.sum
|
||||
@@ -47,8 +47,8 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
cache-dependency-path: go.sum
|
||||
@@ -58,22 +58,22 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
|
||||
with:
|
||||
go-version-file: tools/go.mod
|
||||
cache-dependency-path: tools/go.sum
|
||||
go-version-file: go.mod
|
||||
cache-dependency-path: go.sum
|
||||
- run: make lint
|
||||
|
||||
generate:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
|
||||
with:
|
||||
go-version-file: tools/go.mod
|
||||
cache-dependency-path: tools/go.sum
|
||||
go-version-file: go.mod
|
||||
cache-dependency-path: go.sum
|
||||
- run: go mod tidy
|
||||
- run: make generate
|
||||
- uses: int128/update-generated-files-action@65b9a7ae3ededc5679d78343f58fbebcf1ebd785 # v2.57.0
|
||||
- uses: int128/update-generated-files-action@d3f65c7154e5db6d92286d52217476f469239629 # v2.80.0
|
||||
|
||||
6
.github/workflows/release.yaml
vendored
6
.github/workflows/release.yaml
vendored
@@ -57,8 +57,8 @@ jobs:
|
||||
CGO_ENABLED: ${{ matrix.platform.CGO_ENABLED }}
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
cache-dependency-path: go.sum
|
||||
@@ -74,5 +74,5 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- uses: rajatjindal/krew-release-bot@3d9faef30a82761d610544f62afddca00993eef9 # v0.0.47
|
||||
|
||||
4
.github/workflows/system-test.yaml
vendored
4
.github/workflows/system-test.yaml
vendored
@@ -22,8 +22,8 @@ jobs:
|
||||
system-test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
cache-dependency-path: go.sum
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
outpkg: "{{.PackageName}}_mock"
|
||||
dir: "mocks/{{.PackagePath}}_mock"
|
||||
|
||||
dir: mocks/{{.SrcPackagePath}}_mock
|
||||
pkgname: '{{.SrcPackageName}}_mock'
|
||||
filename: mocks.go
|
||||
template: testify
|
||||
packages:
|
||||
github.com/int128/kubelogin:
|
||||
config:
|
||||
@@ -8,4 +9,4 @@ packages:
|
||||
recursive: true
|
||||
io:
|
||||
interfaces:
|
||||
Closer:
|
||||
Closer: {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM --platform=$BUILDPLATFORM golang:1.23 AS builder
|
||||
FROM --platform=$BUILDPLATFORM golang:1.25.6@sha256:06d1251c59a75761ce4ebc8b299030576233d7437c886a68b43464bad62d4bb1 AS builder
|
||||
|
||||
WORKDIR /builder
|
||||
|
||||
|
||||
8
Makefile
8
Makefile
@@ -11,12 +11,10 @@ integration-test:
|
||||
|
||||
.PHONY: generate
|
||||
generate:
|
||||
$(MAKE) -C tools
|
||||
./tools/bin/wire ./pkg/di
|
||||
go tool github.com/google/wire/cmd/wire ./pkg/di
|
||||
rm -fr mocks/
|
||||
./tools/bin/mockery
|
||||
go tool mockery
|
||||
|
||||
.PHONY: lint
|
||||
lint:
|
||||
$(MAKE) -C tools
|
||||
./tools/bin/golangci-lint run
|
||||
go tool golangci-lint run
|
||||
|
||||
@@ -21,7 +21,7 @@ Install the latest release from [Homebrew](https://brew.sh/), [Krew](https://git
|
||||
|
||||
```sh
|
||||
# Homebrew (macOS and Linux)
|
||||
brew install int128/kubelogin/kubelogin
|
||||
brew install kubelogin
|
||||
|
||||
# Krew (macOS, Linux, Windows and ARM)
|
||||
kubectl krew install oidc-login
|
||||
@@ -83,8 +83,8 @@ If the refresh token has expired, it will perform re-authentication.
|
||||
|
||||
### Token cache
|
||||
|
||||
If the OS keyring is available, kubelogin stores the token cache to the OS keyring.
|
||||
Otherwise, kubelogin stores the token cache to the file system.
|
||||
Kubelogin stores the token cache to the file system by default.
|
||||
For enhanced security, it is recommended to store it to the keyring.
|
||||
See the [token cache](docs/usage.md#token-cache) for details.
|
||||
|
||||
You can log out by deleting the token cache.
|
||||
@@ -92,7 +92,7 @@ You can log out by deleting the token cache.
|
||||
```console
|
||||
% kubectl oidc-login clean
|
||||
Deleted the token cache at /home/user/.kube/cache/oidc-login
|
||||
Deleted the token cache in the keyring
|
||||
Deleted the token cache from the keyring
|
||||
```
|
||||
|
||||
Kubelogin will ask you to log in via the browser again.
|
||||
|
||||
@@ -4,33 +4,38 @@ OUTPUT_DIR := $(CURDIR)/output
|
||||
KUBECONFIG := $(OUTPUT_DIR)/kubeconfig.yaml
|
||||
export KUBECONFIG
|
||||
|
||||
# create a Kubernetes cluster
|
||||
.PHONY: cluster
|
||||
cluster:
|
||||
# create a cluster
|
||||
# Create a cluster.
|
||||
mkdir -p $(OUTPUT_DIR)
|
||||
sed -e "s|OIDC_ISSUER_URL|$(OIDC_ISSUER_URL)|" -e "s|OIDC_CLIENT_ID|$(OIDC_CLIENT_ID)|" cluster.yaml > $(OUTPUT_DIR)/cluster.yaml
|
||||
kind create cluster --name $(CLUSTER_NAME) --config $(OUTPUT_DIR)/cluster.yaml
|
||||
# set up access control
|
||||
|
||||
# Set up the access control.
|
||||
kubectl create clusterrole cluster-readonly --verb=get,watch,list --resource='*.*'
|
||||
kubectl create clusterrolebinding cluster-readonly --clusterrole=cluster-readonly --user=$(YOUR_EMAIL)
|
||||
# set up kubectl
|
||||
|
||||
# Set up kubectl.
|
||||
kubectl config set-credentials oidc \
|
||||
--exec-api-version=client.authentication.k8s.io/v1beta1 \
|
||||
--exec-api-version=client.authentication.k8s.io/v1 \
|
||||
--exec-interactive-mode=Never \
|
||||
--exec-command=$(CURDIR)/../kubelogin \
|
||||
--exec-arg=get-token \
|
||||
--exec-arg=--token-cache-dir=$(OUTPUT_DIR)/token-cache \
|
||||
--exec-arg=--oidc-issuer-url=$(OIDC_ISSUER_URL) \
|
||||
--exec-arg=--oidc-client-id=$(OIDC_CLIENT_ID) \
|
||||
--exec-arg=--oidc-client-secret=$(OIDC_CLIENT_SECRET) \
|
||||
--exec-arg=--oidc-extra-scope=email
|
||||
# switch the default user
|
||||
|
||||
# Switch the default user.
|
||||
kubectl config set-context --current --user=oidc
|
||||
|
||||
# clean up the resources
|
||||
# Show the kubeconfig.
|
||||
kubectl config view
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-rm -r $(OUTPUT_DIR)
|
||||
|
||||
.PHONY: delete-cluster
|
||||
delete-cluster:
|
||||
kind delete cluster --name $(CLUSTER_NAME)
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
# kubelogin/acceptance_test
|
||||
|
||||
This is a manual test for verifying Kubernetes OIDC authentication with your OIDC provider.
|
||||
|
||||
This is a manual test to verify if the Kubernetes OIDC authentication works with your OIDC provider.
|
||||
|
||||
## Purpose
|
||||
|
||||
This test checks the following points:
|
||||
|
||||
1. You can set up your OIDC provider using [setup guide](../docs/setup.md).
|
||||
1. You can set up your OIDC provider using the [setup guide](../docs/setup.md).
|
||||
1. The plugin works with your OIDC provider.
|
||||
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Prerequisite
|
||||
@@ -22,7 +20,7 @@ make -C ..
|
||||
```
|
||||
|
||||
You need to set up your provider.
|
||||
See [setup guide](../docs/setup.md) for more.
|
||||
See the [setup guide](../docs/setup.md) for more.
|
||||
|
||||
You need to install the following tools:
|
||||
|
||||
@@ -44,7 +42,6 @@ For example, you can create a cluster with Google account authentication.
|
||||
```sh
|
||||
make OIDC_ISSUER_URL=https://accounts.google.com \
|
||||
OIDC_CLIENT_ID=REDACTED.apps.googleusercontent.com \
|
||||
OIDC_CLIENT_SECRET=REDACTED \
|
||||
YOUR_EMAIL=REDACTED@gmail.com
|
||||
```
|
||||
|
||||
|
||||
179
docs/setup.md
179
docs/setup.md
@@ -12,163 +12,32 @@ Let's see the following steps:
|
||||
|
||||
## 1. Set up the OIDC provider
|
||||
|
||||
Kubelogin supports the following authentication flows:
|
||||
Kubelogin supports the authentication flows such as Device Authorization Grant or Authorization Code Flow.
|
||||
For the details of flows supported in Kubelogin, see the [usage](usage.md).
|
||||
For the details of your provider, ask the administrator of your provider.
|
||||
|
||||
- Authorization code flow
|
||||
- Device authorization grant
|
||||
- Resource owner password credentials grant
|
||||
## 2. Authenticate with the OpenID Connect Provider
|
||||
|
||||
See the [usage](usage.md) for the details.
|
||||
|
||||
### Google Identity Platform
|
||||
|
||||
You can log in with a Google account.
|
||||
|
||||
Open [Google APIs Console](https://console.developers.google.com/apis/credentials) and create an OAuth client with the following setting:
|
||||
|
||||
- Application Type: Other
|
||||
|
||||
Check the client ID and secret.
|
||||
Replace the following variables in the later sections.
|
||||
|
||||
| Variable | Value |
|
||||
| ---------------- | -------------------------------- |
|
||||
| `ISSUER_URL` | `https://accounts.google.com` |
|
||||
| `YOUR_CLIENT_ID` | `xxx.apps.googleusercontent.com` |
|
||||
|
||||
### Keycloak
|
||||
|
||||
You can log in with a user of Keycloak.
|
||||
Make sure you have an administrator role of the Keycloak realm.
|
||||
|
||||
Open Keycloak and create an OIDC client as follows:
|
||||
|
||||
- Client ID: `YOUR_CLIENT_ID`
|
||||
- Valid Redirect URLs:
|
||||
- `http://localhost:8000`
|
||||
- `http://localhost:18000` (used if the port 8000 is already in use)
|
||||
- Issuer URL: `https://keycloak.example.com/auth/realms/YOUR_REALM`
|
||||
|
||||
You can associate client roles by adding the following mapper:
|
||||
|
||||
- Name: `groups`
|
||||
- Mapper Type: `User Client Role`
|
||||
- Client ID: `YOUR_CLIENT_ID`
|
||||
- Client Role prefix: `kubernetes:`
|
||||
- Token Claim Name: `groups`
|
||||
- Add to ID token: on
|
||||
|
||||
For example, if you have `admin` role of the client, you will get a JWT with the claim `{"groups": ["kubernetes:admin"]}`.
|
||||
|
||||
Replace the following variables in the later sections.
|
||||
|
||||
| Variable | Value |
|
||||
| ---------------- | ----------------------------------------------------- |
|
||||
| `ISSUER_URL` | `https://keycloak.example.com/auth/realms/YOUR_REALM` |
|
||||
| `YOUR_CLIENT_ID` | `YOUR_CLIENT_ID` |
|
||||
|
||||
### Dex with GitHub
|
||||
|
||||
You can log in with a GitHub account.
|
||||
|
||||
Open [GitHub OAuth Apps](https://github.com/settings/developers) and create an application with the following setting:
|
||||
|
||||
- Application name: (any)
|
||||
- Homepage URL: `https://dex.example.com`
|
||||
- Authorization callback URL: `https://dex.example.com/callback`
|
||||
|
||||
Deploy [Dex](https://github.com/dexidp/dex) with the following config:
|
||||
|
||||
```yaml
|
||||
issuer: https://dex.example.com
|
||||
connectors:
|
||||
- type: github
|
||||
id: github
|
||||
name: GitHub
|
||||
config:
|
||||
clientID: YOUR_GITHUB_CLIENT_ID
|
||||
clientSecret: YOUR_GITHUB_CLIENT_SECRET
|
||||
redirectURI: https://dex.example.com/callback
|
||||
staticClients:
|
||||
- id: YOUR_CLIENT_ID
|
||||
name: Kubernetes
|
||||
redirectURIs:
|
||||
- http://localhost:8000
|
||||
- http://localhost:18000
|
||||
secret: YOUR_DEX_CLIENT_SECRET
|
||||
```
|
||||
|
||||
Replace the following variables in the later sections.
|
||||
|
||||
| Variable | Value |
|
||||
| -------------------- | ------------------------- |
|
||||
| `ISSUER_URL` | `https://dex.example.com` |
|
||||
| `YOUR_CLIENT_ID` | `YOUR_CLIENT_ID` |
|
||||
| `YOUR_CLIENT_SECRET` | `YOUR_DEX_CLIENT_SECRET` |
|
||||
|
||||
### Okta
|
||||
|
||||
You can log in with an Okta user.
|
||||
Okta supports [the authorization code flow with PKCE](https://developer.okta.com/docs/guides/implement-auth-code-pkce/overview/)
|
||||
and this section explains how to set up it.
|
||||
|
||||
Open your Okta organization and create an application with the following options:
|
||||
|
||||
- Application type: Native
|
||||
- Initiate login URI: `http://localhost:8000`
|
||||
- Login redirect URIs:
|
||||
- `http://localhost:8000`
|
||||
- `http://localhost:18000` (used if the port 8000 is already in use)
|
||||
- Allowed grant types: Authorization Code
|
||||
- Client authentication: Use PKCE (for public clients)
|
||||
|
||||
Replace the following variables in the later sections.
|
||||
|
||||
| Variable | Value |
|
||||
| ---------------- | ------------------------------------ |
|
||||
| `ISSUER_URL` | `https://YOUR_ORGANIZATION.okta.com` |
|
||||
| `YOUR_CLIENT_ID` | random string |
|
||||
|
||||
You do not need to set `YOUR_CLIENT_SECRET`.
|
||||
|
||||
If you need `groups` claim for access control,
|
||||
see [jetstack/okta-kubectl-auth](https://github.com/jetstack/okta-kubectl-auth/blob/master/docs/okta-setup.md) and [#250](https://github.com/int128/kubelogin/issues/250).
|
||||
|
||||
### Ping Identity
|
||||
|
||||
Login with an account that has permissions to create applications.
|
||||
Create an OIDC application with the following configuration:
|
||||
|
||||
- Redirect URIs:
|
||||
- `http://localhost:8000`
|
||||
- `http://localhost:18000` (used if the port 8000 is already in use)
|
||||
- Grant type: Authorization Code
|
||||
- PKCE Enforcement: Required
|
||||
|
||||
Leverage the following variables in the next steps.
|
||||
|
||||
| Variable | Value |
|
||||
| ---------------- | ------------------------------------------------- |
|
||||
| `ISSUER_URL` | `https://auth.pingone.com/<PingOne Tenant Id>/as` |
|
||||
| `YOUR_CLIENT_ID` | random string |
|
||||
|
||||
`YOUR_CLIENT_SECRET` is not required for this configuration.
|
||||
|
||||
## 2. Verify authentication
|
||||
|
||||
Run the following command:
|
||||
Run the following command to show the instruction to set up the configuration:
|
||||
|
||||
```sh
|
||||
kubectl oidc-login setup \
|
||||
--oidc-issuer-url=ISSUER_URL \
|
||||
--oidc-client-id=YOUR_CLIENT_ID
|
||||
kubectl oidc-login setup --oidc-issuer-url=ISSUER_URL --oidc-client-id=YOUR_CLIENT_ID
|
||||
```
|
||||
|
||||
It launches the browser and navigates to `http://localhost:8000`.
|
||||
Please log in to the provider.
|
||||
Set the following flags:
|
||||
|
||||
You can set extra options, for example, extra scope or CA certificate.
|
||||
See also the full options.
|
||||
- Set the issuer URL of your OpenID Connect provider to `--oidc-issuer-url`.
|
||||
- Set the client ID for your OpenID Connect provider to `--oidc-client-id`.
|
||||
- If your provider requires a client secret, set `--oidc-client-secret`.
|
||||
|
||||
If your provider supports the Device Authorization Grant, set `--grant-type=device-code`.
|
||||
It launches the browser and navigates to the authentication page of your provider.
|
||||
|
||||
If your provider supports the Authorization Code Flow, set `--grant-type=authcode`.
|
||||
It starts a local server for the authentication.
|
||||
It launches the browser and navigates to the authentication page of your provider.
|
||||
|
||||
You can see the full options:
|
||||
|
||||
```sh
|
||||
kubectl oidc-login setup --help
|
||||
@@ -176,14 +45,12 @@ kubectl oidc-login setup --help
|
||||
|
||||
## 3. Bind a cluster role
|
||||
|
||||
Here bind `cluster-admin` role to you.
|
||||
You can run the following command to bind `cluster-admin` role to you:
|
||||
|
||||
```sh
|
||||
kubectl create clusterrolebinding oidc-cluster-admin --clusterrole=cluster-admin --user='ISSUER_URL#YOUR_SUBJECT'
|
||||
```
|
||||
|
||||
As well as you can create a custom cluster role and bind it.
|
||||
|
||||
## 4. Set up the Kubernetes API server
|
||||
|
||||
Add the following flags to kube-apiserver:
|
||||
@@ -201,6 +68,7 @@ Add `oidc` user to the kubeconfig.
|
||||
|
||||
```sh
|
||||
kubectl config set-credentials oidc \
|
||||
--exec-interactive-mode=Never \
|
||||
--exec-api-version=client.authentication.k8s.io/v1 \
|
||||
--exec-command=kubectl \
|
||||
--exec-arg=oidc-login \
|
||||
@@ -209,6 +77,11 @@ kubectl config set-credentials oidc \
|
||||
--exec-arg=--oidc-client-id=YOUR_CLIENT_ID
|
||||
```
|
||||
|
||||
If your provider requires a client secret, add `--oidc-client-secret=YOUR_CLIENT_SECRET`.
|
||||
|
||||
For security, it is recommended to add `--token-cache-storage=keyring` to store the token cache to the keyring instead of the file system.
|
||||
If you encounter an error, see the [token cache](usage.md#token-cache) for details.
|
||||
|
||||
## 6. Verify cluster access
|
||||
|
||||
Make sure you can access the Kubernetes cluster.
|
||||
|
||||
156
docs/usage.md
156
docs/usage.md
@@ -10,18 +10,20 @@ Flags:
|
||||
--oidc-issuer-url string Issuer URL of the provider (mandatory)
|
||||
--oidc-client-id string Client ID of the provider (mandatory)
|
||||
--oidc-client-secret string Client secret of the provider
|
||||
--oidc-redirect-url string [authcode, authcode-keyboard] Redirect URL
|
||||
--oidc-extra-scope strings Scopes to request to the provider
|
||||
--oidc-use-access-token Instead of using the id_token, use the access_token to authenticate to Kubernetes
|
||||
--oidc-request-header stringToString HTTP headers to send with an authentication request (default [])
|
||||
--force-refresh If set, refresh the ID token regardless of its expiration time
|
||||
--token-cache-dir string Path to a directory of the token cache (default "~/.kube/cache/oidc-login")
|
||||
--token-cache-storage string Storage for the token cache. One of (auto|keyring|disk) (default "auto")
|
||||
--token-cache-storage string Storage for the token cache. One of (disk|keyring|none) (default "disk")
|
||||
--certificate-authority stringArray Path to a cert file for the certificate authority
|
||||
--certificate-authority-data stringArray Base64 encoded cert for the certificate authority
|
||||
--insecure-skip-tls-verify [SECURITY RISK] If set, the server's certificate will not be checked for validity
|
||||
--tls-renegotiation-once If set, allow a remote server to request renegotiation once per connection
|
||||
--tls-renegotiation-freely If set, allow a remote server to repeatedly request renegotiation
|
||||
--oidc-pkce-method string PKCE code challenge method. Automatically determined by default. One of (auto|no|S256) (default "auto")
|
||||
--grant-type string Authorization grant type to use. One of (auto|authcode|authcode-keyboard|password|device-code) (default "auto")
|
||||
--grant-type string Authorization grant type to use. One of (auto|authcode|authcode-keyboard|password|device-code|client-credentials) (default "auto")
|
||||
--listen-address strings [authcode] Address to bind to the local server. If multiple addresses are set, it will try binding in order (default [127.0.0.1:8000,127.0.0.1:18000])
|
||||
--skip-open-browser [authcode] Do not open the browser automatically
|
||||
--browser-command string [authcode] Command to open the browser
|
||||
@@ -29,9 +31,7 @@ Flags:
|
||||
--local-server-cert string [authcode] Certificate path for the local server
|
||||
--local-server-key string [authcode] Certificate key path for the local server
|
||||
--open-url-after-authentication string [authcode] If set, open the URL in the browser after authentication
|
||||
--oidc-redirect-url-hostname string [authcode] Hostname of the redirect URL (default "localhost")
|
||||
--oidc-redirect-url-authcode-keyboard string [authcode-keyboard] Redirect URL (default "urn:ietf:wg:oauth:2.0:oob")
|
||||
--oidc-auth-request-extra-params stringToString [authcode, authcode-keyboard] Extra query parameters to send with an authentication request (default [])
|
||||
--oidc-auth-request-extra-params stringToString [authcode, authcode-keyboard, client-credentials] Extra query parameters to send with an authentication request (default [])
|
||||
--username string [password] Username for resource owner password credentials grant
|
||||
--password string [password] Password for resource owner password credentials grant
|
||||
-h, --help help for get-token
|
||||
@@ -52,24 +52,6 @@ Global Flags:
|
||||
--vmodule moduleSpec comma-separated list of pattern=N settings for file-filtered logging
|
||||
```
|
||||
|
||||
Here is the sequence diagram of the credential plugin.
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
actor User
|
||||
User ->>+ kubectl: Run
|
||||
kubectl ->>+ kubelogin: Run the plugin
|
||||
kubelogin ->>+ Provider: Authentication request
|
||||
Note over User, Provider: Browser interaction
|
||||
Provider -->>- kubelogin: Authentication response
|
||||
kubelogin ->>+ Provider: Token request
|
||||
Provider -->>- kubelogin: Token response
|
||||
kubelogin -->>- kubectl: Credential
|
||||
kubectl ->>+ kube-apiserver: Request with the credential
|
||||
kube-apiserver -->>- kubectl: Response
|
||||
kubectl -->>- User: Response
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
### Authentication timeout
|
||||
@@ -107,6 +89,16 @@ you can enforce the code challenge method by `--oidc-pkce-method`.
|
||||
|
||||
For the most providers, you don't need to set this option explicitly.
|
||||
|
||||
### HTTP headers
|
||||
|
||||
If your provider requires extra HTTP headers, you can set them by `--oidc-request-header`.
|
||||
|
||||
For Azure AD Single Page Application with PKCE, you can set `Origin` header as follows:
|
||||
|
||||
```yaml
|
||||
- --oidc-request-header=Origin=localhost
|
||||
```
|
||||
|
||||
### CA certificate
|
||||
|
||||
You can use your self-signed certificate for the provider.
|
||||
@@ -123,18 +115,25 @@ See also [net/http#ProxyFromEnvironment](https://golang.org/pkg/net/http/#ProxyF
|
||||
|
||||
### Token cache
|
||||
|
||||
Kubelogin stores the token cache to the OS keyring if available.
|
||||
It depends on [zalando/go-keyring](https://github.com/zalando/go-keyring) for the keyring storage.
|
||||
Kubelogin stores the token cache to the file system by default.
|
||||
|
||||
If you encounter a problem, try `--token-cache-storage` to set the storage.
|
||||
You can store the token cache to the OS keyring for enhanced security.
|
||||
It depends on [zalando/go-keyring](https://github.com/zalando/go-keyring).
|
||||
|
||||
```yaml
|
||||
# Force to use the OS keyring
|
||||
- --token-cache-storage=keyring
|
||||
# Force to use the file system
|
||||
- --token-cache-storage=disk
|
||||
```
|
||||
|
||||
You can delete the token cache by the clean command.
|
||||
|
||||
```console
|
||||
% kubectl oidc-login clean
|
||||
Deleted the token cache at /home/user/.kube/cache/oidc-login
|
||||
Deleted the token cache from the keyring
|
||||
```
|
||||
|
||||
For systems with immutable storage and no keyring, a cache type of none is available.
|
||||
|
||||
### Home directory expansion
|
||||
|
||||
If a value in the following options begins with a tilde character `~`, it is expanded to the home directory.
|
||||
@@ -148,14 +147,36 @@ If a value in the following options begins with a tilde character `~`, it is exp
|
||||
|
||||
Kubelogin support the following flows:
|
||||
|
||||
- [Authorization code flow](#authorization-code-flow)
|
||||
- [Authorization code flow with a keyboard](#authorization-code-flow-with-a-keyboard)
|
||||
- [Device authorization grant](#device-authorization-grant)
|
||||
- [Resource owner password credentials grant](#resource-owner-password-credentials-grant)
|
||||
- [Device Authorization Grant](#device-authorization-grant)
|
||||
- [Authorization Code Flow](#authorization-code-flow)
|
||||
- [Authorization Code Flow with a Keyboard](#authorization-code-flow-with-a-keyboard)
|
||||
- [Resource Owner Password Credentials Grant](#resource-owner-password-credentials-grant)
|
||||
- [Client Credentials Flow](#client-credentials-flow)
|
||||
|
||||
### Authorization code flow
|
||||
### Device Authorization Grant
|
||||
|
||||
Kubelogin performs the [authorization code flow](https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth) by default.
|
||||
It performs the [Device Authorization Grant (RFC 8628)](https://tools.ietf.org/html/rfc8628) when `--grant-type=device-code` is set.
|
||||
|
||||
```yaml
|
||||
- --grant-type=device-code
|
||||
```
|
||||
|
||||
It automatically opens the browser.
|
||||
If the provider returns the `verification_uri_complete` parameter, you don't need to enter the code.
|
||||
Otherwise, you need to enter the code shown.
|
||||
|
||||
If you encounter a problem with the browser, you can change the browser command or skip opening the browser.
|
||||
|
||||
```yaml
|
||||
# Change the browser command
|
||||
- --browser-command=google-chrome
|
||||
# Do not open the browser
|
||||
- --skip-open-browser
|
||||
```
|
||||
|
||||
### Authorization Code Flow
|
||||
|
||||
It performs the [Authorization Code Flow](https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth) when `--grant-type=authcode` is set or the flag is not given.
|
||||
|
||||
It starts the local server at port 8000 or 18000 by default.
|
||||
You need to register the following redirect URIs to the provider:
|
||||
@@ -170,6 +191,14 @@ You can change the listening address.
|
||||
- --listen-address=127.0.0.1:23456
|
||||
```
|
||||
|
||||
The redirect URL defaults to `http://localhost` with the listening port.
|
||||
You can override the redirect URL.
|
||||
|
||||
```yaml
|
||||
- --oidc-redirect-url=http://127.0.0.1:8000/
|
||||
- --oidc-redirect-url=http://your-local-hostname:8000/
|
||||
```
|
||||
|
||||
You can specify a certificate for the local webserver if HTTPS is required by your identity provider.
|
||||
|
||||
```yaml
|
||||
@@ -177,12 +206,6 @@ You can specify a certificate for the local webserver if HTTPS is required by yo
|
||||
- --local-server-key=localhost.key
|
||||
```
|
||||
|
||||
You can change the hostname of redirect URI from the default value `localhost`.
|
||||
|
||||
```yaml
|
||||
- --oidc-redirect-url-hostname=127.0.0.1
|
||||
```
|
||||
|
||||
You can add extra parameters to the authentication request.
|
||||
|
||||
```yaml
|
||||
@@ -205,7 +228,7 @@ If you encounter a problem with the browser, you can change the browser command
|
||||
- --skip-open-browser
|
||||
```
|
||||
|
||||
### Authorization code flow with a keyboard
|
||||
### Authorization Code Flow with a keyboard
|
||||
|
||||
If you cannot access the browser, instead use the authorization code flow with a keyboard.
|
||||
|
||||
@@ -213,6 +236,13 @@ If you cannot access the browser, instead use the authorization code flow with a
|
||||
- --grant-type=authcode-keyboard
|
||||
```
|
||||
|
||||
You need to explicitly set the redirect URL.
|
||||
|
||||
```yaml
|
||||
- --oidc-redirect-url=urn:ietf:wg:oauth:2.0:oob
|
||||
- --oidc-redirect-url=http://localhost
|
||||
```
|
||||
|
||||
Kubelogin will show the URL and prompt.
|
||||
Open the URL in the browser and then copy the code shown.
|
||||
|
||||
@@ -222,43 +252,15 @@ Open https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&client_id=
|
||||
Enter code: YOUR_CODE
|
||||
```
|
||||
|
||||
The default of redirect URI is `urn:ietf:wg:oauth:2.0:oob`.
|
||||
You can overwrite it.
|
||||
|
||||
```yaml
|
||||
- oidc-redirect-url-authcode-keyboard=http://localhost
|
||||
```
|
||||
|
||||
You can add extra parameters to the authentication request.
|
||||
|
||||
```yaml
|
||||
- --oidc-auth-request-extra-params=ttl=86400
|
||||
```
|
||||
|
||||
### Device authorization grant
|
||||
### Resource Owner Password Credentials Grant
|
||||
|
||||
Kubelogin performs the [device authorization grant](https://tools.ietf.org/html/rfc8628) when `--grant-type=device-code` is set.
|
||||
|
||||
```yaml
|
||||
- --grant-type=device-code
|
||||
```
|
||||
|
||||
It automatically opens the browser.
|
||||
If the provider returns the `verification_uri_complete` parameter, you don't need to enter the code.
|
||||
Otherwise, you need to enter the code shown.
|
||||
|
||||
If you encounter a problem with the browser, you can change the browser command or skip opening the browser.
|
||||
|
||||
```yaml
|
||||
# Change the browser command
|
||||
- --browser-command=google-chrome
|
||||
# Do not open the browser
|
||||
- --skip-open-browser
|
||||
```
|
||||
|
||||
### Resource owner password credentials grant
|
||||
|
||||
Kubelogin performs the resource owner password credentials grant
|
||||
It performs the [Resource Owner Password Credentials Grant](https://datatracker.ietf.org/doc/html/rfc6749#section-4.3)
|
||||
when `--grant-type=password` or `--username` is set.
|
||||
|
||||
Note that most OIDC providers do not support this grant.
|
||||
@@ -294,6 +296,16 @@ Username: foo
|
||||
Password:
|
||||
```
|
||||
|
||||
### Client Credentials Flow
|
||||
|
||||
It performs the [OAuth 2.0 Client Credentials Flow](https://datatracker.ietf.org/doc/html/rfc6749#section-1.3.4) when `--grant-type=client-credentials` is set.
|
||||
|
||||
```yaml
|
||||
- --grant-type=client-credentials
|
||||
```
|
||||
|
||||
Per specification, this flow only returns authorization tokens.
|
||||
|
||||
## Run in Docker
|
||||
|
||||
You can run [the Docker image](https://ghcr.io/int128/kubelogin) instead of the binary.
|
||||
|
||||
277
go.mod
277
go.mod
@@ -1,66 +1,279 @@
|
||||
module github.com/int128/kubelogin
|
||||
|
||||
go 1.23.5
|
||||
go 1.25.6
|
||||
|
||||
require (
|
||||
github.com/chromedp/chromedp v0.11.2
|
||||
github.com/coreos/go-oidc/v3 v3.12.0
|
||||
github.com/gofrs/flock v0.12.1
|
||||
github.com/golang-jwt/jwt/v5 v5.2.1
|
||||
github.com/google/go-cmp v0.6.0
|
||||
github.com/google/wire v0.6.0
|
||||
github.com/int128/oauth2cli v1.14.1
|
||||
github.com/int128/oauth2dev v1.0.1
|
||||
github.com/chromedp/chromedp v0.14.2
|
||||
github.com/coreos/go-oidc/v3 v3.17.0
|
||||
github.com/gofrs/flock v0.13.0
|
||||
github.com/golang-jwt/jwt/v5 v5.3.1
|
||||
github.com/google/go-cmp v0.7.0
|
||||
github.com/google/wire v0.7.0
|
||||
github.com/int128/oauth2cli v1.18.0
|
||||
github.com/int128/oauth2dev v1.1.0
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
|
||||
github.com/spf13/cobra v1.8.1
|
||||
github.com/spf13/pflag v1.0.5
|
||||
github.com/stretchr/testify v1.10.0
|
||||
github.com/spf13/cobra v1.10.2
|
||||
github.com/spf13/pflag v1.0.10
|
||||
github.com/stretchr/testify v1.11.1
|
||||
github.com/zalando/go-keyring v0.2.6
|
||||
golang.org/x/oauth2 v0.25.0
|
||||
golang.org/x/sync v0.10.0
|
||||
golang.org/x/term v0.28.0
|
||||
golang.org/x/oauth2 v0.35.0
|
||||
golang.org/x/sync v0.19.0
|
||||
golang.org/x/term v0.39.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
k8s.io/apimachinery v0.32.1
|
||||
k8s.io/client-go v0.32.1
|
||||
k8s.io/apimachinery v0.33.4
|
||||
k8s.io/client-go v0.33.4
|
||||
k8s.io/klog/v2 v2.130.1
|
||||
)
|
||||
|
||||
require (
|
||||
4d63.com/gocheckcompilerdirectives v1.3.0 // indirect
|
||||
4d63.com/gochecknoglobals v0.2.2 // indirect
|
||||
al.essio.dev/pkg/shellescape v1.5.1 // indirect
|
||||
github.com/chromedp/cdproto v0.0.0-20241022234722-4d5d5faf59fb // indirect
|
||||
codeberg.org/chavacava/garif v0.2.0 // indirect
|
||||
codeberg.org/polyfloyd/go-errorlint v1.9.0 // indirect
|
||||
dev.gaijin.team/go/exhaustruct/v4 v4.0.0 // indirect
|
||||
dev.gaijin.team/go/golib v0.6.0 // indirect
|
||||
github.com/4meepo/tagalign v1.4.3 // indirect
|
||||
github.com/Abirdcfly/dupword v0.1.7 // indirect
|
||||
github.com/AdminBenni/iota-mixing v1.0.0 // indirect
|
||||
github.com/AlwxSin/noinlineerr v1.0.5 // indirect
|
||||
github.com/Antonboom/errname v1.1.1 // indirect
|
||||
github.com/Antonboom/nilnil v1.1.1 // indirect
|
||||
github.com/Antonboom/testifylint v1.6.4 // indirect
|
||||
github.com/BurntSushi/toml v1.6.0 // indirect
|
||||
github.com/Djarvur/go-err113 v0.1.1 // indirect
|
||||
github.com/Masterminds/semver/v3 v3.4.0 // indirect
|
||||
github.com/MirrexOne/unqueryvet v1.4.0 // indirect
|
||||
github.com/OpenPeeDeeP/depguard/v2 v2.2.1 // indirect
|
||||
github.com/alecthomas/chroma/v2 v2.21.1 // indirect
|
||||
github.com/alecthomas/go-check-sumtype v0.3.1 // indirect
|
||||
github.com/alexkohler/nakedret/v2 v2.0.6 // indirect
|
||||
github.com/alexkohler/prealloc v1.0.1 // indirect
|
||||
github.com/alfatraining/structtag v1.0.0 // indirect
|
||||
github.com/alingse/asasalint v0.0.11 // indirect
|
||||
github.com/alingse/nilnesserr v0.2.0 // indirect
|
||||
github.com/ashanbrown/forbidigo/v2 v2.3.0 // indirect
|
||||
github.com/ashanbrown/makezero/v2 v2.1.0 // indirect
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bkielbasa/cyclop v1.2.3 // indirect
|
||||
github.com/blizzy78/varnamelen v0.8.0 // indirect
|
||||
github.com/bombsimon/wsl/v4 v4.7.0 // indirect
|
||||
github.com/bombsimon/wsl/v5 v5.3.0 // indirect
|
||||
github.com/breml/bidichk v0.3.3 // indirect
|
||||
github.com/breml/errchkjson v0.4.1 // indirect
|
||||
github.com/brunoga/deep v1.2.4 // indirect
|
||||
github.com/butuzov/ireturn v0.4.0 // indirect
|
||||
github.com/butuzov/mirror v1.3.0 // indirect
|
||||
github.com/catenacyber/perfsprint v0.10.1 // indirect
|
||||
github.com/ccojocar/zxcvbn-go v1.0.4 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/charithe/durationcheck v0.0.11 // indirect
|
||||
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
|
||||
github.com/charmbracelet/lipgloss v1.1.0 // indirect
|
||||
github.com/charmbracelet/x/ansi v0.8.0 // indirect
|
||||
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
|
||||
github.com/charmbracelet/x/term v0.2.1 // indirect
|
||||
github.com/chromedp/cdproto v0.0.0-20250724212937-08a3db8b4327 // indirect
|
||||
github.com/chromedp/sysutil v1.1.0 // indirect
|
||||
github.com/ckaznocha/intrange v0.3.1 // indirect
|
||||
github.com/curioswitch/go-reassign v0.3.0 // indirect
|
||||
github.com/daixiang0/gci v0.13.7 // indirect
|
||||
github.com/danieljoos/wincred v1.2.2 // indirect
|
||||
github.com/dave/dst v0.27.3 // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/denis-tingaikin/go-header v0.5.0 // indirect
|
||||
github.com/dlclark/regexp2 v1.11.5 // indirect
|
||||
github.com/ettle/strcase v0.2.0 // indirect
|
||||
github.com/fatih/color v1.18.0 // indirect
|
||||
github.com/fatih/structs v1.1.0 // indirect
|
||||
github.com/fatih/structtag v1.2.0 // indirect
|
||||
github.com/firefart/nonamedreturns v1.0.6 // indirect
|
||||
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
||||
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
|
||||
github.com/go-jose/go-jose/v4 v4.0.2 // indirect
|
||||
github.com/go-logr/logr v1.4.2 // indirect
|
||||
github.com/fzipp/gocyclo v0.6.0 // indirect
|
||||
github.com/ghostiam/protogetter v0.3.18 // indirect
|
||||
github.com/go-critic/go-critic v0.14.3 // indirect
|
||||
github.com/go-jose/go-jose/v4 v4.1.3 // indirect
|
||||
github.com/go-json-experiment/json v0.0.0-20250725192818-e39067aee2d2 // indirect
|
||||
github.com/go-logr/logr v1.4.3 // indirect
|
||||
github.com/go-toolsmith/astcast v1.1.0 // indirect
|
||||
github.com/go-toolsmith/astcopy v1.1.0 // indirect
|
||||
github.com/go-toolsmith/astequal v1.2.0 // indirect
|
||||
github.com/go-toolsmith/astfmt v1.1.0 // indirect
|
||||
github.com/go-toolsmith/astp v1.1.0 // indirect
|
||||
github.com/go-toolsmith/strparse v1.1.0 // indirect
|
||||
github.com/go-toolsmith/typep v1.1.0 // indirect
|
||||
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
|
||||
github.com/go-xmlfmt/xmlfmt v1.1.3 // indirect
|
||||
github.com/gobwas/glob v0.2.3 // indirect
|
||||
github.com/gobwas/httphead v0.1.0 // indirect
|
||||
github.com/gobwas/pool v0.2.1 // indirect
|
||||
github.com/gobwas/ws v1.4.0 // indirect
|
||||
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
||||
github.com/godoc-lint/godoc-lint v0.11.1 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/google/gofuzz v1.2.0 // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/golangci/asciicheck v0.5.0 // indirect
|
||||
github.com/golangci/dupl v0.0.0-20250308024227-f665c8d69b32 // indirect
|
||||
github.com/golangci/go-printf-func-name v0.1.1 // indirect
|
||||
github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d // indirect
|
||||
github.com/golangci/golangci-lint/v2 v2.8.0 // indirect
|
||||
github.com/golangci/golines v0.14.0 // indirect
|
||||
github.com/golangci/misspell v0.7.0 // indirect
|
||||
github.com/golangci/plugin-module-register v0.1.2 // indirect
|
||||
github.com/golangci/revgrep v0.8.0 // indirect
|
||||
github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e // indirect
|
||||
github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e // indirect
|
||||
github.com/google/subcommands v1.2.0 // indirect
|
||||
github.com/gordonklaus/ineffassign v0.2.0 // indirect
|
||||
github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
|
||||
github.com/gostaticanalysis/comment v1.5.0 // indirect
|
||||
github.com/gostaticanalysis/forcetypeassert v0.2.0 // indirect
|
||||
github.com/gostaticanalysis/nilerr v0.1.2 // indirect
|
||||
github.com/hashicorp/go-immutable-radix/v2 v2.1.0 // indirect
|
||||
github.com/hashicorp/go-version v1.8.0 // indirect
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
|
||||
github.com/hexops/gotextdiff v1.0.3 // indirect
|
||||
github.com/huandu/xstrings v1.5.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/int128/listener v1.1.0 // indirect
|
||||
github.com/josharian/intern v1.0.0 // indirect
|
||||
github.com/int128/listener v1.3.0 // indirect
|
||||
github.com/jedib0t/go-pretty/v6 v6.6.7 // indirect
|
||||
github.com/jgautheron/goconst v1.8.2 // indirect
|
||||
github.com/jingyugao/rowserrcheck v1.1.1 // indirect
|
||||
github.com/jjti/go-spancheck v0.6.5 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/mailru/easyjson v0.7.7 // indirect
|
||||
github.com/julz/importas v0.2.0 // indirect
|
||||
github.com/karamaru-alpha/copyloopvar v1.2.2 // indirect
|
||||
github.com/kisielk/errcheck v1.9.0 // indirect
|
||||
github.com/kkHAIKE/contextcheck v1.1.6 // indirect
|
||||
github.com/knadh/koanf/maps v0.1.2 // indirect
|
||||
github.com/knadh/koanf/parsers/yaml v0.1.0 // indirect
|
||||
github.com/knadh/koanf/providers/env v1.0.0 // indirect
|
||||
github.com/knadh/koanf/providers/file v1.1.2 // indirect
|
||||
github.com/knadh/koanf/providers/posflag v0.1.0 // indirect
|
||||
github.com/knadh/koanf/providers/structs v0.1.0 // indirect
|
||||
github.com/knadh/koanf/v2 v2.3.0 // indirect
|
||||
github.com/kulti/thelper v0.7.1 // indirect
|
||||
github.com/kunwardeep/paralleltest v1.0.15 // indirect
|
||||
github.com/lasiar/canonicalheader v1.1.2 // indirect
|
||||
github.com/ldez/exptostd v0.4.5 // indirect
|
||||
github.com/ldez/gomoddirectives v0.8.0 // indirect
|
||||
github.com/ldez/grignotin v0.10.1 // indirect
|
||||
github.com/ldez/structtags v0.6.1 // indirect
|
||||
github.com/ldez/tagliatelle v0.7.2 // indirect
|
||||
github.com/ldez/usetesting v0.5.0 // indirect
|
||||
github.com/leonklingele/grouper v1.1.2 // indirect
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
||||
github.com/macabu/inamedparam v0.2.0 // indirect
|
||||
github.com/mailru/easyjson v0.9.0 // indirect
|
||||
github.com/manuelarte/embeddedstructfieldcheck v0.4.0 // indirect
|
||||
github.com/manuelarte/funcorder v0.5.0 // indirect
|
||||
github.com/maratori/testableexamples v1.0.1 // indirect
|
||||
github.com/maratori/testpackage v1.1.2 // indirect
|
||||
github.com/matoous/godox v1.1.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.16 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
||||
github.com/mgechev/revive v1.13.0 // indirect
|
||||
github.com/mitchellh/copystructure v1.2.0 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/moricho/tparallel v0.3.2 // indirect
|
||||
github.com/muesli/termenv v0.16.0 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/nakabonne/nestif v0.3.1 // indirect
|
||||
github.com/nishanths/exhaustive v0.12.0 // indirect
|
||||
github.com/nishanths/predeclared v0.2.2 // indirect
|
||||
github.com/nunnatsa/ginkgolinter v0.21.2 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/rogpeppe/go-internal v1.13.1 // indirect
|
||||
github.com/prometheus/client_golang v1.12.1 // indirect
|
||||
github.com/prometheus/client_model v0.2.0 // indirect
|
||||
github.com/prometheus/common v0.32.1 // indirect
|
||||
github.com/prometheus/procfs v0.7.3 // indirect
|
||||
github.com/quasilyte/go-ruleguard v0.4.5 // indirect
|
||||
github.com/quasilyte/go-ruleguard/dsl v0.3.23 // indirect
|
||||
github.com/quasilyte/gogrep v0.5.0 // indirect
|
||||
github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect
|
||||
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect
|
||||
github.com/raeperd/recvcheck v0.2.0 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
github.com/rogpeppe/go-internal v1.14.1 // indirect
|
||||
github.com/rs/zerolog v1.33.0 // indirect
|
||||
github.com/ryancurrah/gomodguard v1.4.1 // indirect
|
||||
github.com/ryanrolds/sqlclosecheck v0.5.1 // indirect
|
||||
github.com/sagikazarmark/locafero v0.7.0 // indirect
|
||||
github.com/sanposhiho/wastedassign/v2 v2.1.0 // indirect
|
||||
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 // indirect
|
||||
github.com/sashamelentyev/interfacebloat v1.1.0 // indirect
|
||||
github.com/sashamelentyev/usestdlibvars v1.29.0 // indirect
|
||||
github.com/securego/gosec/v2 v2.22.11 // indirect
|
||||
github.com/sirupsen/logrus v1.9.3 // indirect
|
||||
github.com/sivchari/containedctx v1.0.3 // indirect
|
||||
github.com/sonatard/noctx v0.4.0 // indirect
|
||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||
github.com/sourcegraph/go-diff v0.7.0 // indirect
|
||||
github.com/spf13/afero v1.15.0 // indirect
|
||||
github.com/spf13/cast v1.7.1 // indirect
|
||||
github.com/spf13/viper v1.20.0 // indirect
|
||||
github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect
|
||||
github.com/stbenjam/no-sprintf-host-port v0.3.1 // indirect
|
||||
github.com/stretchr/objx v0.5.2 // indirect
|
||||
github.com/subosito/gotenv v1.6.0 // indirect
|
||||
github.com/tetafro/godot v1.5.4 // indirect
|
||||
github.com/timakin/bodyclose v0.0.0-20241222091800-1db5c5ca4d67 // indirect
|
||||
github.com/timonwong/loggercheck v0.11.0 // indirect
|
||||
github.com/tomarrell/wrapcheck/v2 v2.12.0 // indirect
|
||||
github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect
|
||||
github.com/ultraware/funlen v0.2.0 // indirect
|
||||
github.com/ultraware/whitespace v0.2.0 // indirect
|
||||
github.com/uudashr/gocognit v1.2.0 // indirect
|
||||
github.com/uudashr/iface v1.4.1 // indirect
|
||||
github.com/vektra/mockery/v3 v3.6.3 // indirect
|
||||
github.com/x448/float16 v0.8.4 // indirect
|
||||
golang.org/x/crypto v0.28.0 // indirect
|
||||
golang.org/x/net v0.30.0 // indirect
|
||||
golang.org/x/sys v0.29.0 // indirect
|
||||
golang.org/x/text v0.19.0 // indirect
|
||||
golang.org/x/time v0.7.0 // indirect
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
|
||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
|
||||
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
|
||||
github.com/xen0n/gosmopolitan v1.3.0 // indirect
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
|
||||
github.com/yagipy/maintidx v1.0.0 // indirect
|
||||
github.com/yeya24/promlinter v0.3.0 // indirect
|
||||
github.com/ykadowak/zerologlint v0.1.5 // indirect
|
||||
gitlab.com/bosi/decorder v0.4.2 // indirect
|
||||
go-simpler.org/musttag v0.14.0 // indirect
|
||||
go-simpler.org/sloglint v0.11.1 // indirect
|
||||
go.augendre.info/arangolint v0.3.1 // indirect
|
||||
go.augendre.info/fatcontext v0.9.0 // indirect
|
||||
go.uber.org/automaxprocs v1.6.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.uber.org/zap v1.27.0 // indirect
|
||||
go.yaml.in/yaml/v3 v3.0.4 // indirect
|
||||
golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac // indirect
|
||||
golang.org/x/exp/typeparams v0.0.0-20251023183803-a4bb9ffd2546 // indirect
|
||||
golang.org/x/mod v0.31.0 // indirect
|
||||
golang.org/x/net v0.48.0 // indirect
|
||||
golang.org/x/sys v0.40.0 // indirect
|
||||
golang.org/x/text v0.32.0 // indirect
|
||||
golang.org/x/time v0.12.0 // indirect
|
||||
golang.org/x/tools v0.40.0 // indirect
|
||||
google.golang.org/protobuf v1.36.8 // indirect
|
||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||
honnef.co/go/tools v0.6.1 // indirect
|
||||
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
|
||||
mvdan.cc/gofumpt v0.9.2 // indirect
|
||||
mvdan.cc/unparam v0.0.0-20251027182757-5beb8c8f8f15 // indirect
|
||||
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect
|
||||
sigs.k8s.io/randfill v1.0.0 // indirect
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect
|
||||
sigs.k8s.io/yaml v1.4.0 // indirect
|
||||
)
|
||||
|
||||
tool (
|
||||
github.com/golangci/golangci-lint/v2/cmd/golangci-lint
|
||||
github.com/google/wire/cmd/wire
|
||||
github.com/vektra/mockery/v3
|
||||
)
|
||||
|
||||
@@ -20,7 +20,6 @@ func TestClean(t *testing.T) {
|
||||
"kubelogin",
|
||||
"clean",
|
||||
"--token-cache-dir", tokenCacheDir,
|
||||
"--token-cache-storage", "disk",
|
||||
}, "HEAD")
|
||||
if exitCode != 0 {
|
||||
t.Errorf("exit status wants 0 but %d", exitCode)
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
"github.com/int128/kubelogin/pkg/testing/clock"
|
||||
"github.com/int128/kubelogin/pkg/testing/logger"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
clientauthenticationv1beta1 "k8s.io/client-go/pkg/apis/clientauthentication/v1beta1"
|
||||
clientauthenticationv1 "k8s.io/client-go/pkg/apis/clientauthentication/v1"
|
||||
)
|
||||
|
||||
// Run the integration tests of the credential plugin use-case.
|
||||
@@ -50,7 +50,6 @@ func TestCredentialPlugin(t *testing.T) {
|
||||
|
||||
t.Run(name, func(t *testing.T) {
|
||||
t.Run("AuthCode", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), timeout)
|
||||
defer cancel()
|
||||
svc := oidcserver.New(t, tc.keyPair, testconfig.Config{
|
||||
@@ -77,7 +76,6 @@ func TestCredentialPlugin(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("ROPC", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), timeout)
|
||||
defer cancel()
|
||||
svc := oidcserver.New(t, tc.keyPair, testconfig.Config{
|
||||
@@ -108,7 +106,6 @@ func TestCredentialPlugin(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("TokenCacheLifecycle", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), timeout)
|
||||
defer cancel()
|
||||
svc := oidcserver.New(t, tc.keyPair, testconfig.Config{})
|
||||
@@ -203,7 +200,6 @@ func TestCredentialPlugin(t *testing.T) {
|
||||
|
||||
t.Run("PKCE", func(t *testing.T) {
|
||||
t.Run("Not supported by provider", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), timeout)
|
||||
defer cancel()
|
||||
svc := oidcserver.New(t, keypair.None, testconfig.Config{
|
||||
@@ -229,7 +225,6 @@ func TestCredentialPlugin(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Enforce", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), timeout)
|
||||
defer cancel()
|
||||
svc := oidcserver.New(t, keypair.None, testconfig.Config{
|
||||
@@ -257,7 +252,6 @@ func TestCredentialPlugin(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("TLSData", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), timeout)
|
||||
defer cancel()
|
||||
svc := oidcserver.New(t, keypair.Server, testconfig.Config{
|
||||
@@ -284,7 +278,6 @@ func TestCredentialPlugin(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("ExtraScopes", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), timeout)
|
||||
defer cancel()
|
||||
svc := oidcserver.New(t, keypair.None, testconfig.Config{
|
||||
@@ -314,7 +307,6 @@ func TestCredentialPlugin(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("OpenURLAfterAuthentication", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), timeout)
|
||||
defer cancel()
|
||||
svc := oidcserver.New(t, keypair.None, testconfig.Config{
|
||||
@@ -340,35 +332,7 @@ func TestCredentialPlugin(t *testing.T) {
|
||||
assertCredentialPluginStdout(t, &stdout, svc.LastTokenResponse().IDToken, now.Add(time.Hour))
|
||||
})
|
||||
|
||||
t.Run("RedirectURLHostname", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), timeout)
|
||||
defer cancel()
|
||||
svc := oidcserver.New(t, keypair.None, testconfig.Config{
|
||||
Want: testconfig.Want{
|
||||
Scope: "openid",
|
||||
RedirectURIPrefix: "http://127.0.0.1:",
|
||||
CodeChallengeMethod: "S256",
|
||||
},
|
||||
Response: testconfig.Response{
|
||||
IDTokenExpiry: now.Add(time.Hour),
|
||||
CodeChallengeMethodsSupported: []string{"plain", "S256"},
|
||||
},
|
||||
})
|
||||
var stdout bytes.Buffer
|
||||
runGetToken(t, ctx, getTokenConfig{
|
||||
tokenCacheDir: tokenCacheDir,
|
||||
issuerURL: svc.IssuerURL(),
|
||||
httpDriver: httpdriver.New(ctx, t, httpdriver.Config{BodyContains: "Authenticated"}),
|
||||
now: now,
|
||||
stdout: &stdout,
|
||||
args: []string{"--oidc-redirect-url-hostname", "127.0.0.1"},
|
||||
})
|
||||
assertCredentialPluginStdout(t, &stdout, svc.LastTokenResponse().IDToken, now.Add(time.Hour))
|
||||
})
|
||||
|
||||
t.Run("RedirectURLHTTPS", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), timeout)
|
||||
defer cancel()
|
||||
svc := oidcserver.New(t, keypair.None, testconfig.Config{
|
||||
@@ -401,7 +365,6 @@ func TestCredentialPlugin(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("ExtraParams", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), timeout)
|
||||
defer cancel()
|
||||
svc := oidcserver.New(t, keypair.None, testconfig.Config{
|
||||
@@ -446,11 +409,14 @@ type getTokenConfig struct {
|
||||
|
||||
func runGetToken(t *testing.T, ctx context.Context, cfg getTokenConfig) {
|
||||
cmd := di.NewCmdForHeadless(clock.Fake(cfg.now), os.Stdin, cfg.stdout, logger.New(t), cfg.httpDriver)
|
||||
t.Setenv(
|
||||
"KUBERNETES_EXEC_INFO",
|
||||
`{"kind":"ExecCredential","apiVersion":"client.authentication.k8s.io/v1","spec":{"interactive":true}}`,
|
||||
)
|
||||
exitCode := cmd.Run(ctx, append([]string{
|
||||
"kubelogin",
|
||||
"get-token",
|
||||
"--token-cache-dir", cfg.tokenCacheDir,
|
||||
"--token-cache-storage", "disk",
|
||||
"--oidc-issuer-url", cfg.issuerURL,
|
||||
"--oidc-client-id", "kubernetes",
|
||||
"--listen-address", "127.0.0.1:0",
|
||||
@@ -461,22 +427,22 @@ func runGetToken(t *testing.T, ctx context.Context, cfg getTokenConfig) {
|
||||
}
|
||||
|
||||
func assertCredentialPluginStdout(t *testing.T, stdout io.Reader, token string, expiry time.Time) {
|
||||
var got clientauthenticationv1beta1.ExecCredential
|
||||
var got clientauthenticationv1.ExecCredential
|
||||
if err := json.NewDecoder(stdout).Decode(&got); err != nil {
|
||||
t.Errorf("could not decode json of the credential plugin: %s", err)
|
||||
return
|
||||
}
|
||||
want := clientauthenticationv1beta1.ExecCredential{
|
||||
want := clientauthenticationv1.ExecCredential{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: "client.authentication.k8s.io/v1beta1",
|
||||
APIVersion: "client.authentication.k8s.io/v1",
|
||||
Kind: "ExecCredential",
|
||||
},
|
||||
Status: &clientauthenticationv1beta1.ExecCredentialStatus{
|
||||
Status: &clientauthenticationv1.ExecCredentialStatus{
|
||||
Token: token,
|
||||
ExpirationTimestamp: &metav1.Time{Time: expiry},
|
||||
},
|
||||
}
|
||||
if diff := cmp.Diff(want, got); diff != "" {
|
||||
t.Errorf("kubeconfig mismatch (-want +got):\n%s", diff)
|
||||
t.Errorf("stdout mismatch (-want +got):\n%s", diff)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,11 @@ func (c *client) Open(url string) error {
|
||||
c.t.Errorf("could not send a request: %s", err)
|
||||
return nil
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer func() {
|
||||
if err := resp.Body.Close(); err != nil {
|
||||
c.t.Errorf("could not close response body: %s", err)
|
||||
}
|
||||
}()
|
||||
if resp.StatusCode != 200 {
|
||||
c.t.Errorf("StatusCode wants 200 but %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
@@ -36,7 +36,11 @@ func readAsBase64(name string) string {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer f.Close()
|
||||
defer func() {
|
||||
if err := f.Close(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
var s strings.Builder
|
||||
e := base64.NewEncoder(base64.StdEncoding, &s)
|
||||
if _, err := io.Copy(e, f); err != nil {
|
||||
|
||||
@@ -27,7 +27,11 @@ func Create(t *testing.T, v *Values) string {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer f.Close()
|
||||
defer func() {
|
||||
if err := f.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}()
|
||||
tpl, err := template.ParseFiles("kubeconfig/testdata/kubeconfig.yaml")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -51,7 +55,11 @@ func Verify(t *testing.T, kubeconfig string, want AuthProviderConfig) {
|
||||
t.Errorf("could not open kubeconfig: %s", err)
|
||||
return
|
||||
}
|
||||
defer f.Close()
|
||||
defer func() {
|
||||
if err := f.Close(); err != nil {
|
||||
t.Errorf("could not close kubeconfig: %s", err)
|
||||
}
|
||||
}()
|
||||
|
||||
var y struct {
|
||||
Users []struct {
|
||||
|
||||
@@ -1,361 +0,0 @@
|
||||
// Code generated by mockery v2.51.0. DO NOT EDIT.
|
||||
|
||||
package service_mock
|
||||
|
||||
import (
|
||||
service "github.com/int128/kubelogin/integration_test/oidcserver/service"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// MockProvider is an autogenerated mock type for the Provider type
|
||||
type MockProvider struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type MockProvider_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *MockProvider) EXPECT() *MockProvider_Expecter {
|
||||
return &MockProvider_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// AuthenticateCode provides a mock function with given fields: req
|
||||
func (_m *MockProvider) AuthenticateCode(req service.AuthenticationRequest) (string, error) {
|
||||
ret := _m.Called(req)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for AuthenticateCode")
|
||||
}
|
||||
|
||||
var r0 string
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(service.AuthenticationRequest) (string, error)); ok {
|
||||
return rf(req)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(service.AuthenticationRequest) string); ok {
|
||||
r0 = rf(req)
|
||||
} else {
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(service.AuthenticationRequest) error); ok {
|
||||
r1 = rf(req)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockProvider_AuthenticateCode_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AuthenticateCode'
|
||||
type MockProvider_AuthenticateCode_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// AuthenticateCode is a helper method to define mock.On call
|
||||
// - req service.AuthenticationRequest
|
||||
func (_e *MockProvider_Expecter) AuthenticateCode(req interface{}) *MockProvider_AuthenticateCode_Call {
|
||||
return &MockProvider_AuthenticateCode_Call{Call: _e.mock.On("AuthenticateCode", req)}
|
||||
}
|
||||
|
||||
func (_c *MockProvider_AuthenticateCode_Call) Run(run func(req service.AuthenticationRequest)) *MockProvider_AuthenticateCode_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(service.AuthenticationRequest))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockProvider_AuthenticateCode_Call) Return(code string, err error) *MockProvider_AuthenticateCode_Call {
|
||||
_c.Call.Return(code, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockProvider_AuthenticateCode_Call) RunAndReturn(run func(service.AuthenticationRequest) (string, error)) *MockProvider_AuthenticateCode_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AuthenticatePassword provides a mock function with given fields: username, password, scope
|
||||
func (_m *MockProvider) AuthenticatePassword(username string, password string, scope string) (*service.TokenResponse, error) {
|
||||
ret := _m.Called(username, password, scope)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for AuthenticatePassword")
|
||||
}
|
||||
|
||||
var r0 *service.TokenResponse
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string, string, string) (*service.TokenResponse, error)); ok {
|
||||
return rf(username, password, scope)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string, string, string) *service.TokenResponse); ok {
|
||||
r0 = rf(username, password, scope)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*service.TokenResponse)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string, string, string) error); ok {
|
||||
r1 = rf(username, password, scope)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockProvider_AuthenticatePassword_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AuthenticatePassword'
|
||||
type MockProvider_AuthenticatePassword_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// AuthenticatePassword is a helper method to define mock.On call
|
||||
// - username string
|
||||
// - password string
|
||||
// - scope string
|
||||
func (_e *MockProvider_Expecter) AuthenticatePassword(username interface{}, password interface{}, scope interface{}) *MockProvider_AuthenticatePassword_Call {
|
||||
return &MockProvider_AuthenticatePassword_Call{Call: _e.mock.On("AuthenticatePassword", username, password, scope)}
|
||||
}
|
||||
|
||||
func (_c *MockProvider_AuthenticatePassword_Call) Run(run func(username string, password string, scope string)) *MockProvider_AuthenticatePassword_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string), args[1].(string), args[2].(string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockProvider_AuthenticatePassword_Call) Return(_a0 *service.TokenResponse, _a1 error) *MockProvider_AuthenticatePassword_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockProvider_AuthenticatePassword_Call) RunAndReturn(run func(string, string, string) (*service.TokenResponse, error)) *MockProvider_AuthenticatePassword_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Discovery provides a mock function with no fields
|
||||
func (_m *MockProvider) Discovery() *service.DiscoveryResponse {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Discovery")
|
||||
}
|
||||
|
||||
var r0 *service.DiscoveryResponse
|
||||
if rf, ok := ret.Get(0).(func() *service.DiscoveryResponse); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*service.DiscoveryResponse)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockProvider_Discovery_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Discovery'
|
||||
type MockProvider_Discovery_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Discovery is a helper method to define mock.On call
|
||||
func (_e *MockProvider_Expecter) Discovery() *MockProvider_Discovery_Call {
|
||||
return &MockProvider_Discovery_Call{Call: _e.mock.On("Discovery")}
|
||||
}
|
||||
|
||||
func (_c *MockProvider_Discovery_Call) Run(run func()) *MockProvider_Discovery_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run()
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockProvider_Discovery_Call) Return(_a0 *service.DiscoveryResponse) *MockProvider_Discovery_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockProvider_Discovery_Call) RunAndReturn(run func() *service.DiscoveryResponse) *MockProvider_Discovery_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Exchange provides a mock function with given fields: req
|
||||
func (_m *MockProvider) Exchange(req service.TokenRequest) (*service.TokenResponse, error) {
|
||||
ret := _m.Called(req)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Exchange")
|
||||
}
|
||||
|
||||
var r0 *service.TokenResponse
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(service.TokenRequest) (*service.TokenResponse, error)); ok {
|
||||
return rf(req)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(service.TokenRequest) *service.TokenResponse); ok {
|
||||
r0 = rf(req)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*service.TokenResponse)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(service.TokenRequest) error); ok {
|
||||
r1 = rf(req)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockProvider_Exchange_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Exchange'
|
||||
type MockProvider_Exchange_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Exchange is a helper method to define mock.On call
|
||||
// - req service.TokenRequest
|
||||
func (_e *MockProvider_Expecter) Exchange(req interface{}) *MockProvider_Exchange_Call {
|
||||
return &MockProvider_Exchange_Call{Call: _e.mock.On("Exchange", req)}
|
||||
}
|
||||
|
||||
func (_c *MockProvider_Exchange_Call) Run(run func(req service.TokenRequest)) *MockProvider_Exchange_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(service.TokenRequest))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockProvider_Exchange_Call) Return(_a0 *service.TokenResponse, _a1 error) *MockProvider_Exchange_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockProvider_Exchange_Call) RunAndReturn(run func(service.TokenRequest) (*service.TokenResponse, error)) *MockProvider_Exchange_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// GetCertificates provides a mock function with no fields
|
||||
func (_m *MockProvider) GetCertificates() *service.CertificatesResponse {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetCertificates")
|
||||
}
|
||||
|
||||
var r0 *service.CertificatesResponse
|
||||
if rf, ok := ret.Get(0).(func() *service.CertificatesResponse); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*service.CertificatesResponse)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockProvider_GetCertificates_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetCertificates'
|
||||
type MockProvider_GetCertificates_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// GetCertificates is a helper method to define mock.On call
|
||||
func (_e *MockProvider_Expecter) GetCertificates() *MockProvider_GetCertificates_Call {
|
||||
return &MockProvider_GetCertificates_Call{Call: _e.mock.On("GetCertificates")}
|
||||
}
|
||||
|
||||
func (_c *MockProvider_GetCertificates_Call) Run(run func()) *MockProvider_GetCertificates_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run()
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockProvider_GetCertificates_Call) Return(_a0 *service.CertificatesResponse) *MockProvider_GetCertificates_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockProvider_GetCertificates_Call) RunAndReturn(run func() *service.CertificatesResponse) *MockProvider_GetCertificates_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Refresh provides a mock function with given fields: refreshToken
|
||||
func (_m *MockProvider) Refresh(refreshToken string) (*service.TokenResponse, error) {
|
||||
ret := _m.Called(refreshToken)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Refresh")
|
||||
}
|
||||
|
||||
var r0 *service.TokenResponse
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string) (*service.TokenResponse, error)); ok {
|
||||
return rf(refreshToken)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string) *service.TokenResponse); ok {
|
||||
r0 = rf(refreshToken)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*service.TokenResponse)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string) error); ok {
|
||||
r1 = rf(refreshToken)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockProvider_Refresh_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Refresh'
|
||||
type MockProvider_Refresh_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Refresh is a helper method to define mock.On call
|
||||
// - refreshToken string
|
||||
func (_e *MockProvider_Expecter) Refresh(refreshToken interface{}) *MockProvider_Refresh_Call {
|
||||
return &MockProvider_Refresh_Call{Call: _e.mock.On("Refresh", refreshToken)}
|
||||
}
|
||||
|
||||
func (_c *MockProvider_Refresh_Call) Run(run func(refreshToken string)) *MockProvider_Refresh_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockProvider_Refresh_Call) Return(_a0 *service.TokenResponse, _a1 error) *MockProvider_Refresh_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockProvider_Refresh_Call) RunAndReturn(run func(string) (*service.TokenResponse, error)) *MockProvider_Refresh_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockProvider creates a new instance of MockProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockProvider(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockProvider {
|
||||
mock := &MockProvider{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -1,487 +0,0 @@
|
||||
// Code generated by mockery v2.51.0. DO NOT EDIT.
|
||||
|
||||
package service_mock
|
||||
|
||||
import (
|
||||
service "github.com/int128/kubelogin/integration_test/oidcserver/service"
|
||||
testconfig "github.com/int128/kubelogin/integration_test/oidcserver/testconfig"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// MockService is an autogenerated mock type for the Service type
|
||||
type MockService struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type MockService_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *MockService) EXPECT() *MockService_Expecter {
|
||||
return &MockService_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// AuthenticateCode provides a mock function with given fields: req
|
||||
func (_m *MockService) AuthenticateCode(req service.AuthenticationRequest) (string, error) {
|
||||
ret := _m.Called(req)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for AuthenticateCode")
|
||||
}
|
||||
|
||||
var r0 string
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(service.AuthenticationRequest) (string, error)); ok {
|
||||
return rf(req)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(service.AuthenticationRequest) string); ok {
|
||||
r0 = rf(req)
|
||||
} else {
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(service.AuthenticationRequest) error); ok {
|
||||
r1 = rf(req)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockService_AuthenticateCode_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AuthenticateCode'
|
||||
type MockService_AuthenticateCode_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// AuthenticateCode is a helper method to define mock.On call
|
||||
// - req service.AuthenticationRequest
|
||||
func (_e *MockService_Expecter) AuthenticateCode(req interface{}) *MockService_AuthenticateCode_Call {
|
||||
return &MockService_AuthenticateCode_Call{Call: _e.mock.On("AuthenticateCode", req)}
|
||||
}
|
||||
|
||||
func (_c *MockService_AuthenticateCode_Call) Run(run func(req service.AuthenticationRequest)) *MockService_AuthenticateCode_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(service.AuthenticationRequest))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_AuthenticateCode_Call) Return(code string, err error) *MockService_AuthenticateCode_Call {
|
||||
_c.Call.Return(code, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_AuthenticateCode_Call) RunAndReturn(run func(service.AuthenticationRequest) (string, error)) *MockService_AuthenticateCode_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AuthenticatePassword provides a mock function with given fields: username, password, scope
|
||||
func (_m *MockService) AuthenticatePassword(username string, password string, scope string) (*service.TokenResponse, error) {
|
||||
ret := _m.Called(username, password, scope)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for AuthenticatePassword")
|
||||
}
|
||||
|
||||
var r0 *service.TokenResponse
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string, string, string) (*service.TokenResponse, error)); ok {
|
||||
return rf(username, password, scope)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string, string, string) *service.TokenResponse); ok {
|
||||
r0 = rf(username, password, scope)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*service.TokenResponse)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string, string, string) error); ok {
|
||||
r1 = rf(username, password, scope)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockService_AuthenticatePassword_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AuthenticatePassword'
|
||||
type MockService_AuthenticatePassword_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// AuthenticatePassword is a helper method to define mock.On call
|
||||
// - username string
|
||||
// - password string
|
||||
// - scope string
|
||||
func (_e *MockService_Expecter) AuthenticatePassword(username interface{}, password interface{}, scope interface{}) *MockService_AuthenticatePassword_Call {
|
||||
return &MockService_AuthenticatePassword_Call{Call: _e.mock.On("AuthenticatePassword", username, password, scope)}
|
||||
}
|
||||
|
||||
func (_c *MockService_AuthenticatePassword_Call) Run(run func(username string, password string, scope string)) *MockService_AuthenticatePassword_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string), args[1].(string), args[2].(string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_AuthenticatePassword_Call) Return(_a0 *service.TokenResponse, _a1 error) *MockService_AuthenticatePassword_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_AuthenticatePassword_Call) RunAndReturn(run func(string, string, string) (*service.TokenResponse, error)) *MockService_AuthenticatePassword_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Discovery provides a mock function with no fields
|
||||
func (_m *MockService) Discovery() *service.DiscoveryResponse {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Discovery")
|
||||
}
|
||||
|
||||
var r0 *service.DiscoveryResponse
|
||||
if rf, ok := ret.Get(0).(func() *service.DiscoveryResponse); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*service.DiscoveryResponse)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockService_Discovery_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Discovery'
|
||||
type MockService_Discovery_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Discovery is a helper method to define mock.On call
|
||||
func (_e *MockService_Expecter) Discovery() *MockService_Discovery_Call {
|
||||
return &MockService_Discovery_Call{Call: _e.mock.On("Discovery")}
|
||||
}
|
||||
|
||||
func (_c *MockService_Discovery_Call) Run(run func()) *MockService_Discovery_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run()
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_Discovery_Call) Return(_a0 *service.DiscoveryResponse) *MockService_Discovery_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_Discovery_Call) RunAndReturn(run func() *service.DiscoveryResponse) *MockService_Discovery_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Exchange provides a mock function with given fields: req
|
||||
func (_m *MockService) Exchange(req service.TokenRequest) (*service.TokenResponse, error) {
|
||||
ret := _m.Called(req)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Exchange")
|
||||
}
|
||||
|
||||
var r0 *service.TokenResponse
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(service.TokenRequest) (*service.TokenResponse, error)); ok {
|
||||
return rf(req)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(service.TokenRequest) *service.TokenResponse); ok {
|
||||
r0 = rf(req)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*service.TokenResponse)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(service.TokenRequest) error); ok {
|
||||
r1 = rf(req)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockService_Exchange_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Exchange'
|
||||
type MockService_Exchange_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Exchange is a helper method to define mock.On call
|
||||
// - req service.TokenRequest
|
||||
func (_e *MockService_Expecter) Exchange(req interface{}) *MockService_Exchange_Call {
|
||||
return &MockService_Exchange_Call{Call: _e.mock.On("Exchange", req)}
|
||||
}
|
||||
|
||||
func (_c *MockService_Exchange_Call) Run(run func(req service.TokenRequest)) *MockService_Exchange_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(service.TokenRequest))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_Exchange_Call) Return(_a0 *service.TokenResponse, _a1 error) *MockService_Exchange_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_Exchange_Call) RunAndReturn(run func(service.TokenRequest) (*service.TokenResponse, error)) *MockService_Exchange_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// GetCertificates provides a mock function with no fields
|
||||
func (_m *MockService) GetCertificates() *service.CertificatesResponse {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetCertificates")
|
||||
}
|
||||
|
||||
var r0 *service.CertificatesResponse
|
||||
if rf, ok := ret.Get(0).(func() *service.CertificatesResponse); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*service.CertificatesResponse)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockService_GetCertificates_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetCertificates'
|
||||
type MockService_GetCertificates_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// GetCertificates is a helper method to define mock.On call
|
||||
func (_e *MockService_Expecter) GetCertificates() *MockService_GetCertificates_Call {
|
||||
return &MockService_GetCertificates_Call{Call: _e.mock.On("GetCertificates")}
|
||||
}
|
||||
|
||||
func (_c *MockService_GetCertificates_Call) Run(run func()) *MockService_GetCertificates_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run()
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_GetCertificates_Call) Return(_a0 *service.CertificatesResponse) *MockService_GetCertificates_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_GetCertificates_Call) RunAndReturn(run func() *service.CertificatesResponse) *MockService_GetCertificates_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// IssuerURL provides a mock function with no fields
|
||||
func (_m *MockService) IssuerURL() string {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for IssuerURL")
|
||||
}
|
||||
|
||||
var r0 string
|
||||
if rf, ok := ret.Get(0).(func() string); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockService_IssuerURL_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IssuerURL'
|
||||
type MockService_IssuerURL_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// IssuerURL is a helper method to define mock.On call
|
||||
func (_e *MockService_Expecter) IssuerURL() *MockService_IssuerURL_Call {
|
||||
return &MockService_IssuerURL_Call{Call: _e.mock.On("IssuerURL")}
|
||||
}
|
||||
|
||||
func (_c *MockService_IssuerURL_Call) Run(run func()) *MockService_IssuerURL_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run()
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_IssuerURL_Call) Return(_a0 string) *MockService_IssuerURL_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_IssuerURL_Call) RunAndReturn(run func() string) *MockService_IssuerURL_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// LastTokenResponse provides a mock function with no fields
|
||||
func (_m *MockService) LastTokenResponse() *service.TokenResponse {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for LastTokenResponse")
|
||||
}
|
||||
|
||||
var r0 *service.TokenResponse
|
||||
if rf, ok := ret.Get(0).(func() *service.TokenResponse); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*service.TokenResponse)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockService_LastTokenResponse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LastTokenResponse'
|
||||
type MockService_LastTokenResponse_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// LastTokenResponse is a helper method to define mock.On call
|
||||
func (_e *MockService_Expecter) LastTokenResponse() *MockService_LastTokenResponse_Call {
|
||||
return &MockService_LastTokenResponse_Call{Call: _e.mock.On("LastTokenResponse")}
|
||||
}
|
||||
|
||||
func (_c *MockService_LastTokenResponse_Call) Run(run func()) *MockService_LastTokenResponse_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run()
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_LastTokenResponse_Call) Return(_a0 *service.TokenResponse) *MockService_LastTokenResponse_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_LastTokenResponse_Call) RunAndReturn(run func() *service.TokenResponse) *MockService_LastTokenResponse_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Refresh provides a mock function with given fields: refreshToken
|
||||
func (_m *MockService) Refresh(refreshToken string) (*service.TokenResponse, error) {
|
||||
ret := _m.Called(refreshToken)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Refresh")
|
||||
}
|
||||
|
||||
var r0 *service.TokenResponse
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string) (*service.TokenResponse, error)); ok {
|
||||
return rf(refreshToken)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string) *service.TokenResponse); ok {
|
||||
r0 = rf(refreshToken)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*service.TokenResponse)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string) error); ok {
|
||||
r1 = rf(refreshToken)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockService_Refresh_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Refresh'
|
||||
type MockService_Refresh_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Refresh is a helper method to define mock.On call
|
||||
// - refreshToken string
|
||||
func (_e *MockService_Expecter) Refresh(refreshToken interface{}) *MockService_Refresh_Call {
|
||||
return &MockService_Refresh_Call{Call: _e.mock.On("Refresh", refreshToken)}
|
||||
}
|
||||
|
||||
func (_c *MockService_Refresh_Call) Run(run func(refreshToken string)) *MockService_Refresh_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_Refresh_Call) Return(_a0 *service.TokenResponse, _a1 error) *MockService_Refresh_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_Refresh_Call) RunAndReturn(run func(string) (*service.TokenResponse, error)) *MockService_Refresh_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetConfig provides a mock function with given fields: config
|
||||
func (_m *MockService) SetConfig(config testconfig.Config) {
|
||||
_m.Called(config)
|
||||
}
|
||||
|
||||
// MockService_SetConfig_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetConfig'
|
||||
type MockService_SetConfig_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// SetConfig is a helper method to define mock.On call
|
||||
// - config testconfig.Config
|
||||
func (_e *MockService_Expecter) SetConfig(config interface{}) *MockService_SetConfig_Call {
|
||||
return &MockService_SetConfig_Call{Call: _e.mock.On("SetConfig", config)}
|
||||
}
|
||||
|
||||
func (_c *MockService_SetConfig_Call) Run(run func(config testconfig.Config)) *MockService_SetConfig_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(testconfig.Config))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_SetConfig_Call) Return() *MockService_SetConfig_Call {
|
||||
_c.Call.Return()
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_SetConfig_Call) RunAndReturn(run func(testconfig.Config)) *MockService_SetConfig_Call {
|
||||
_c.Run(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockService creates a new instance of MockService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockService(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockService {
|
||||
mock := &MockService{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -0,0 +1,895 @@
|
||||
// Code generated by mockery; DO NOT EDIT.
|
||||
// github.com/vektra/mockery
|
||||
// template: testify
|
||||
|
||||
package service_mock
|
||||
|
||||
import (
|
||||
"github.com/int128/kubelogin/integration_test/oidcserver/service"
|
||||
"github.com/int128/kubelogin/integration_test/oidcserver/testconfig"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// NewMockService creates a new instance of MockService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockService(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockService {
|
||||
mock := &MockService{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockService is an autogenerated mock type for the Service type
|
||||
type MockService struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type MockService_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *MockService) EXPECT() *MockService_Expecter {
|
||||
return &MockService_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// AuthenticateCode provides a mock function for the type MockService
|
||||
func (_mock *MockService) AuthenticateCode(req service.AuthenticationRequest) (string, error) {
|
||||
ret := _mock.Called(req)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for AuthenticateCode")
|
||||
}
|
||||
|
||||
var r0 string
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(service.AuthenticationRequest) (string, error)); ok {
|
||||
return returnFunc(req)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(service.AuthenticationRequest) string); ok {
|
||||
r0 = returnFunc(req)
|
||||
} else {
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(service.AuthenticationRequest) error); ok {
|
||||
r1 = returnFunc(req)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockService_AuthenticateCode_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AuthenticateCode'
|
||||
type MockService_AuthenticateCode_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// AuthenticateCode is a helper method to define mock.On call
|
||||
// - req service.AuthenticationRequest
|
||||
func (_e *MockService_Expecter) AuthenticateCode(req interface{}) *MockService_AuthenticateCode_Call {
|
||||
return &MockService_AuthenticateCode_Call{Call: _e.mock.On("AuthenticateCode", req)}
|
||||
}
|
||||
|
||||
func (_c *MockService_AuthenticateCode_Call) Run(run func(req service.AuthenticationRequest)) *MockService_AuthenticateCode_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 service.AuthenticationRequest
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(service.AuthenticationRequest)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_AuthenticateCode_Call) Return(code string, err error) *MockService_AuthenticateCode_Call {
|
||||
_c.Call.Return(code, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_AuthenticateCode_Call) RunAndReturn(run func(req service.AuthenticationRequest) (string, error)) *MockService_AuthenticateCode_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AuthenticatePassword provides a mock function for the type MockService
|
||||
func (_mock *MockService) AuthenticatePassword(username string, password string, scope string) (*service.TokenResponse, error) {
|
||||
ret := _mock.Called(username, password, scope)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for AuthenticatePassword")
|
||||
}
|
||||
|
||||
var r0 *service.TokenResponse
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(string, string, string) (*service.TokenResponse, error)); ok {
|
||||
return returnFunc(username, password, scope)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(string, string, string) *service.TokenResponse); ok {
|
||||
r0 = returnFunc(username, password, scope)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*service.TokenResponse)
|
||||
}
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(string, string, string) error); ok {
|
||||
r1 = returnFunc(username, password, scope)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockService_AuthenticatePassword_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AuthenticatePassword'
|
||||
type MockService_AuthenticatePassword_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// AuthenticatePassword is a helper method to define mock.On call
|
||||
// - username string
|
||||
// - password string
|
||||
// - scope string
|
||||
func (_e *MockService_Expecter) AuthenticatePassword(username interface{}, password interface{}, scope interface{}) *MockService_AuthenticatePassword_Call {
|
||||
return &MockService_AuthenticatePassword_Call{Call: _e.mock.On("AuthenticatePassword", username, password, scope)}
|
||||
}
|
||||
|
||||
func (_c *MockService_AuthenticatePassword_Call) Run(run func(username string, password string, scope string)) *MockService_AuthenticatePassword_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 string
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(string)
|
||||
}
|
||||
var arg1 string
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(string)
|
||||
}
|
||||
var arg2 string
|
||||
if args[2] != nil {
|
||||
arg2 = args[2].(string)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
arg2,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_AuthenticatePassword_Call) Return(tokenResponse *service.TokenResponse, err error) *MockService_AuthenticatePassword_Call {
|
||||
_c.Call.Return(tokenResponse, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_AuthenticatePassword_Call) RunAndReturn(run func(username string, password string, scope string) (*service.TokenResponse, error)) *MockService_AuthenticatePassword_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Discovery provides a mock function for the type MockService
|
||||
func (_mock *MockService) Discovery() *service.DiscoveryResponse {
|
||||
ret := _mock.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Discovery")
|
||||
}
|
||||
|
||||
var r0 *service.DiscoveryResponse
|
||||
if returnFunc, ok := ret.Get(0).(func() *service.DiscoveryResponse); ok {
|
||||
r0 = returnFunc()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*service.DiscoveryResponse)
|
||||
}
|
||||
}
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockService_Discovery_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Discovery'
|
||||
type MockService_Discovery_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Discovery is a helper method to define mock.On call
|
||||
func (_e *MockService_Expecter) Discovery() *MockService_Discovery_Call {
|
||||
return &MockService_Discovery_Call{Call: _e.mock.On("Discovery")}
|
||||
}
|
||||
|
||||
func (_c *MockService_Discovery_Call) Run(run func()) *MockService_Discovery_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run()
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_Discovery_Call) Return(discoveryResponse *service.DiscoveryResponse) *MockService_Discovery_Call {
|
||||
_c.Call.Return(discoveryResponse)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_Discovery_Call) RunAndReturn(run func() *service.DiscoveryResponse) *MockService_Discovery_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Exchange provides a mock function for the type MockService
|
||||
func (_mock *MockService) Exchange(req service.TokenRequest) (*service.TokenResponse, error) {
|
||||
ret := _mock.Called(req)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Exchange")
|
||||
}
|
||||
|
||||
var r0 *service.TokenResponse
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(service.TokenRequest) (*service.TokenResponse, error)); ok {
|
||||
return returnFunc(req)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(service.TokenRequest) *service.TokenResponse); ok {
|
||||
r0 = returnFunc(req)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*service.TokenResponse)
|
||||
}
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(service.TokenRequest) error); ok {
|
||||
r1 = returnFunc(req)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockService_Exchange_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Exchange'
|
||||
type MockService_Exchange_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Exchange is a helper method to define mock.On call
|
||||
// - req service.TokenRequest
|
||||
func (_e *MockService_Expecter) Exchange(req interface{}) *MockService_Exchange_Call {
|
||||
return &MockService_Exchange_Call{Call: _e.mock.On("Exchange", req)}
|
||||
}
|
||||
|
||||
func (_c *MockService_Exchange_Call) Run(run func(req service.TokenRequest)) *MockService_Exchange_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 service.TokenRequest
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(service.TokenRequest)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_Exchange_Call) Return(tokenResponse *service.TokenResponse, err error) *MockService_Exchange_Call {
|
||||
_c.Call.Return(tokenResponse, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_Exchange_Call) RunAndReturn(run func(req service.TokenRequest) (*service.TokenResponse, error)) *MockService_Exchange_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// GetCertificates provides a mock function for the type MockService
|
||||
func (_mock *MockService) GetCertificates() *service.CertificatesResponse {
|
||||
ret := _mock.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetCertificates")
|
||||
}
|
||||
|
||||
var r0 *service.CertificatesResponse
|
||||
if returnFunc, ok := ret.Get(0).(func() *service.CertificatesResponse); ok {
|
||||
r0 = returnFunc()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*service.CertificatesResponse)
|
||||
}
|
||||
}
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockService_GetCertificates_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetCertificates'
|
||||
type MockService_GetCertificates_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// GetCertificates is a helper method to define mock.On call
|
||||
func (_e *MockService_Expecter) GetCertificates() *MockService_GetCertificates_Call {
|
||||
return &MockService_GetCertificates_Call{Call: _e.mock.On("GetCertificates")}
|
||||
}
|
||||
|
||||
func (_c *MockService_GetCertificates_Call) Run(run func()) *MockService_GetCertificates_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run()
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_GetCertificates_Call) Return(certificatesResponse *service.CertificatesResponse) *MockService_GetCertificates_Call {
|
||||
_c.Call.Return(certificatesResponse)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_GetCertificates_Call) RunAndReturn(run func() *service.CertificatesResponse) *MockService_GetCertificates_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// IssuerURL provides a mock function for the type MockService
|
||||
func (_mock *MockService) IssuerURL() string {
|
||||
ret := _mock.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for IssuerURL")
|
||||
}
|
||||
|
||||
var r0 string
|
||||
if returnFunc, ok := ret.Get(0).(func() string); ok {
|
||||
r0 = returnFunc()
|
||||
} else {
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockService_IssuerURL_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IssuerURL'
|
||||
type MockService_IssuerURL_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// IssuerURL is a helper method to define mock.On call
|
||||
func (_e *MockService_Expecter) IssuerURL() *MockService_IssuerURL_Call {
|
||||
return &MockService_IssuerURL_Call{Call: _e.mock.On("IssuerURL")}
|
||||
}
|
||||
|
||||
func (_c *MockService_IssuerURL_Call) Run(run func()) *MockService_IssuerURL_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run()
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_IssuerURL_Call) Return(s string) *MockService_IssuerURL_Call {
|
||||
_c.Call.Return(s)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_IssuerURL_Call) RunAndReturn(run func() string) *MockService_IssuerURL_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// LastTokenResponse provides a mock function for the type MockService
|
||||
func (_mock *MockService) LastTokenResponse() *service.TokenResponse {
|
||||
ret := _mock.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for LastTokenResponse")
|
||||
}
|
||||
|
||||
var r0 *service.TokenResponse
|
||||
if returnFunc, ok := ret.Get(0).(func() *service.TokenResponse); ok {
|
||||
r0 = returnFunc()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*service.TokenResponse)
|
||||
}
|
||||
}
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockService_LastTokenResponse_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LastTokenResponse'
|
||||
type MockService_LastTokenResponse_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// LastTokenResponse is a helper method to define mock.On call
|
||||
func (_e *MockService_Expecter) LastTokenResponse() *MockService_LastTokenResponse_Call {
|
||||
return &MockService_LastTokenResponse_Call{Call: _e.mock.On("LastTokenResponse")}
|
||||
}
|
||||
|
||||
func (_c *MockService_LastTokenResponse_Call) Run(run func()) *MockService_LastTokenResponse_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run()
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_LastTokenResponse_Call) Return(tokenResponse *service.TokenResponse) *MockService_LastTokenResponse_Call {
|
||||
_c.Call.Return(tokenResponse)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_LastTokenResponse_Call) RunAndReturn(run func() *service.TokenResponse) *MockService_LastTokenResponse_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Refresh provides a mock function for the type MockService
|
||||
func (_mock *MockService) Refresh(refreshToken string) (*service.TokenResponse, error) {
|
||||
ret := _mock.Called(refreshToken)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Refresh")
|
||||
}
|
||||
|
||||
var r0 *service.TokenResponse
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(string) (*service.TokenResponse, error)); ok {
|
||||
return returnFunc(refreshToken)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(string) *service.TokenResponse); ok {
|
||||
r0 = returnFunc(refreshToken)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*service.TokenResponse)
|
||||
}
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(string) error); ok {
|
||||
r1 = returnFunc(refreshToken)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockService_Refresh_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Refresh'
|
||||
type MockService_Refresh_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Refresh is a helper method to define mock.On call
|
||||
// - refreshToken string
|
||||
func (_e *MockService_Expecter) Refresh(refreshToken interface{}) *MockService_Refresh_Call {
|
||||
return &MockService_Refresh_Call{Call: _e.mock.On("Refresh", refreshToken)}
|
||||
}
|
||||
|
||||
func (_c *MockService_Refresh_Call) Run(run func(refreshToken string)) *MockService_Refresh_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 string
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(string)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_Refresh_Call) Return(tokenResponse *service.TokenResponse, err error) *MockService_Refresh_Call {
|
||||
_c.Call.Return(tokenResponse, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_Refresh_Call) RunAndReturn(run func(refreshToken string) (*service.TokenResponse, error)) *MockService_Refresh_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetConfig provides a mock function for the type MockService
|
||||
func (_mock *MockService) SetConfig(config testconfig.Config) {
|
||||
_mock.Called(config)
|
||||
return
|
||||
}
|
||||
|
||||
// MockService_SetConfig_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetConfig'
|
||||
type MockService_SetConfig_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// SetConfig is a helper method to define mock.On call
|
||||
// - config testconfig.Config
|
||||
func (_e *MockService_Expecter) SetConfig(config interface{}) *MockService_SetConfig_Call {
|
||||
return &MockService_SetConfig_Call{Call: _e.mock.On("SetConfig", config)}
|
||||
}
|
||||
|
||||
func (_c *MockService_SetConfig_Call) Run(run func(config testconfig.Config)) *MockService_SetConfig_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 testconfig.Config
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(testconfig.Config)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_SetConfig_Call) Return() *MockService_SetConfig_Call {
|
||||
_c.Call.Return()
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockService_SetConfig_Call) RunAndReturn(run func(config testconfig.Config)) *MockService_SetConfig_Call {
|
||||
_c.Run(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockProvider creates a new instance of MockProvider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockProvider(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockProvider {
|
||||
mock := &MockProvider{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockProvider is an autogenerated mock type for the Provider type
|
||||
type MockProvider struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type MockProvider_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *MockProvider) EXPECT() *MockProvider_Expecter {
|
||||
return &MockProvider_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// AuthenticateCode provides a mock function for the type MockProvider
|
||||
func (_mock *MockProvider) AuthenticateCode(req service.AuthenticationRequest) (string, error) {
|
||||
ret := _mock.Called(req)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for AuthenticateCode")
|
||||
}
|
||||
|
||||
var r0 string
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(service.AuthenticationRequest) (string, error)); ok {
|
||||
return returnFunc(req)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(service.AuthenticationRequest) string); ok {
|
||||
r0 = returnFunc(req)
|
||||
} else {
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(service.AuthenticationRequest) error); ok {
|
||||
r1 = returnFunc(req)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockProvider_AuthenticateCode_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AuthenticateCode'
|
||||
type MockProvider_AuthenticateCode_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// AuthenticateCode is a helper method to define mock.On call
|
||||
// - req service.AuthenticationRequest
|
||||
func (_e *MockProvider_Expecter) AuthenticateCode(req interface{}) *MockProvider_AuthenticateCode_Call {
|
||||
return &MockProvider_AuthenticateCode_Call{Call: _e.mock.On("AuthenticateCode", req)}
|
||||
}
|
||||
|
||||
func (_c *MockProvider_AuthenticateCode_Call) Run(run func(req service.AuthenticationRequest)) *MockProvider_AuthenticateCode_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 service.AuthenticationRequest
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(service.AuthenticationRequest)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockProvider_AuthenticateCode_Call) Return(code string, err error) *MockProvider_AuthenticateCode_Call {
|
||||
_c.Call.Return(code, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockProvider_AuthenticateCode_Call) RunAndReturn(run func(req service.AuthenticationRequest) (string, error)) *MockProvider_AuthenticateCode_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AuthenticatePassword provides a mock function for the type MockProvider
|
||||
func (_mock *MockProvider) AuthenticatePassword(username string, password string, scope string) (*service.TokenResponse, error) {
|
||||
ret := _mock.Called(username, password, scope)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for AuthenticatePassword")
|
||||
}
|
||||
|
||||
var r0 *service.TokenResponse
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(string, string, string) (*service.TokenResponse, error)); ok {
|
||||
return returnFunc(username, password, scope)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(string, string, string) *service.TokenResponse); ok {
|
||||
r0 = returnFunc(username, password, scope)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*service.TokenResponse)
|
||||
}
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(string, string, string) error); ok {
|
||||
r1 = returnFunc(username, password, scope)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockProvider_AuthenticatePassword_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AuthenticatePassword'
|
||||
type MockProvider_AuthenticatePassword_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// AuthenticatePassword is a helper method to define mock.On call
|
||||
// - username string
|
||||
// - password string
|
||||
// - scope string
|
||||
func (_e *MockProvider_Expecter) AuthenticatePassword(username interface{}, password interface{}, scope interface{}) *MockProvider_AuthenticatePassword_Call {
|
||||
return &MockProvider_AuthenticatePassword_Call{Call: _e.mock.On("AuthenticatePassword", username, password, scope)}
|
||||
}
|
||||
|
||||
func (_c *MockProvider_AuthenticatePassword_Call) Run(run func(username string, password string, scope string)) *MockProvider_AuthenticatePassword_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 string
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(string)
|
||||
}
|
||||
var arg1 string
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(string)
|
||||
}
|
||||
var arg2 string
|
||||
if args[2] != nil {
|
||||
arg2 = args[2].(string)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
arg2,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockProvider_AuthenticatePassword_Call) Return(tokenResponse *service.TokenResponse, err error) *MockProvider_AuthenticatePassword_Call {
|
||||
_c.Call.Return(tokenResponse, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockProvider_AuthenticatePassword_Call) RunAndReturn(run func(username string, password string, scope string) (*service.TokenResponse, error)) *MockProvider_AuthenticatePassword_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Discovery provides a mock function for the type MockProvider
|
||||
func (_mock *MockProvider) Discovery() *service.DiscoveryResponse {
|
||||
ret := _mock.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Discovery")
|
||||
}
|
||||
|
||||
var r0 *service.DiscoveryResponse
|
||||
if returnFunc, ok := ret.Get(0).(func() *service.DiscoveryResponse); ok {
|
||||
r0 = returnFunc()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*service.DiscoveryResponse)
|
||||
}
|
||||
}
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockProvider_Discovery_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Discovery'
|
||||
type MockProvider_Discovery_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Discovery is a helper method to define mock.On call
|
||||
func (_e *MockProvider_Expecter) Discovery() *MockProvider_Discovery_Call {
|
||||
return &MockProvider_Discovery_Call{Call: _e.mock.On("Discovery")}
|
||||
}
|
||||
|
||||
func (_c *MockProvider_Discovery_Call) Run(run func()) *MockProvider_Discovery_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run()
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockProvider_Discovery_Call) Return(discoveryResponse *service.DiscoveryResponse) *MockProvider_Discovery_Call {
|
||||
_c.Call.Return(discoveryResponse)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockProvider_Discovery_Call) RunAndReturn(run func() *service.DiscoveryResponse) *MockProvider_Discovery_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Exchange provides a mock function for the type MockProvider
|
||||
func (_mock *MockProvider) Exchange(req service.TokenRequest) (*service.TokenResponse, error) {
|
||||
ret := _mock.Called(req)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Exchange")
|
||||
}
|
||||
|
||||
var r0 *service.TokenResponse
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(service.TokenRequest) (*service.TokenResponse, error)); ok {
|
||||
return returnFunc(req)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(service.TokenRequest) *service.TokenResponse); ok {
|
||||
r0 = returnFunc(req)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*service.TokenResponse)
|
||||
}
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(service.TokenRequest) error); ok {
|
||||
r1 = returnFunc(req)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockProvider_Exchange_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Exchange'
|
||||
type MockProvider_Exchange_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Exchange is a helper method to define mock.On call
|
||||
// - req service.TokenRequest
|
||||
func (_e *MockProvider_Expecter) Exchange(req interface{}) *MockProvider_Exchange_Call {
|
||||
return &MockProvider_Exchange_Call{Call: _e.mock.On("Exchange", req)}
|
||||
}
|
||||
|
||||
func (_c *MockProvider_Exchange_Call) Run(run func(req service.TokenRequest)) *MockProvider_Exchange_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 service.TokenRequest
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(service.TokenRequest)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockProvider_Exchange_Call) Return(tokenResponse *service.TokenResponse, err error) *MockProvider_Exchange_Call {
|
||||
_c.Call.Return(tokenResponse, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockProvider_Exchange_Call) RunAndReturn(run func(req service.TokenRequest) (*service.TokenResponse, error)) *MockProvider_Exchange_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// GetCertificates provides a mock function for the type MockProvider
|
||||
func (_mock *MockProvider) GetCertificates() *service.CertificatesResponse {
|
||||
ret := _mock.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetCertificates")
|
||||
}
|
||||
|
||||
var r0 *service.CertificatesResponse
|
||||
if returnFunc, ok := ret.Get(0).(func() *service.CertificatesResponse); ok {
|
||||
r0 = returnFunc()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*service.CertificatesResponse)
|
||||
}
|
||||
}
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockProvider_GetCertificates_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetCertificates'
|
||||
type MockProvider_GetCertificates_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// GetCertificates is a helper method to define mock.On call
|
||||
func (_e *MockProvider_Expecter) GetCertificates() *MockProvider_GetCertificates_Call {
|
||||
return &MockProvider_GetCertificates_Call{Call: _e.mock.On("GetCertificates")}
|
||||
}
|
||||
|
||||
func (_c *MockProvider_GetCertificates_Call) Run(run func()) *MockProvider_GetCertificates_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run()
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockProvider_GetCertificates_Call) Return(certificatesResponse *service.CertificatesResponse) *MockProvider_GetCertificates_Call {
|
||||
_c.Call.Return(certificatesResponse)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockProvider_GetCertificates_Call) RunAndReturn(run func() *service.CertificatesResponse) *MockProvider_GetCertificates_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Refresh provides a mock function for the type MockProvider
|
||||
func (_mock *MockProvider) Refresh(refreshToken string) (*service.TokenResponse, error) {
|
||||
ret := _mock.Called(refreshToken)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Refresh")
|
||||
}
|
||||
|
||||
var r0 *service.TokenResponse
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(string) (*service.TokenResponse, error)); ok {
|
||||
return returnFunc(refreshToken)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(string) *service.TokenResponse); ok {
|
||||
r0 = returnFunc(refreshToken)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*service.TokenResponse)
|
||||
}
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(string) error); ok {
|
||||
r1 = returnFunc(refreshToken)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockProvider_Refresh_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Refresh'
|
||||
type MockProvider_Refresh_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Refresh is a helper method to define mock.On call
|
||||
// - refreshToken string
|
||||
func (_e *MockProvider_Expecter) Refresh(refreshToken interface{}) *MockProvider_Refresh_Call {
|
||||
return &MockProvider_Refresh_Call{Call: _e.mock.On("Refresh", refreshToken)}
|
||||
}
|
||||
|
||||
func (_c *MockProvider_Refresh_Call) Run(run func(refreshToken string)) *MockProvider_Refresh_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 string
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(string)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockProvider_Refresh_Call) Return(tokenResponse *service.TokenResponse, err error) *MockProvider_Refresh_Call {
|
||||
_c.Call.Return(tokenResponse, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockProvider_Refresh_Call) RunAndReturn(run func(refreshToken string) (*service.TokenResponse, error)) *MockProvider_Refresh_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
@@ -1,13 +1,29 @@
|
||||
// Code generated by mockery v2.51.0. DO NOT EDIT.
|
||||
// Code generated by mockery; DO NOT EDIT.
|
||||
// github.com/vektra/mockery
|
||||
// template: testify
|
||||
|
||||
package cmd_mock
|
||||
|
||||
import (
|
||||
context "context"
|
||||
"context"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockInterface is an autogenerated mock type for the Interface type
|
||||
type MockInterface struct {
|
||||
mock.Mock
|
||||
@@ -21,21 +37,20 @@ func (_m *MockInterface) EXPECT() *MockInterface_Expecter {
|
||||
return &MockInterface_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Run provides a mock function with given fields: ctx, args, version
|
||||
func (_m *MockInterface) Run(ctx context.Context, args []string, version string) int {
|
||||
ret := _m.Called(ctx, args, version)
|
||||
// Run provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) Run(ctx context.Context, args []string, version string) int {
|
||||
ret := _mock.Called(ctx, args, version)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Run")
|
||||
}
|
||||
|
||||
var r0 int
|
||||
if rf, ok := ret.Get(0).(func(context.Context, []string, string) int); ok {
|
||||
r0 = rf(ctx, args, version)
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, []string, string) int); ok {
|
||||
r0 = returnFunc(ctx, args, version)
|
||||
} else {
|
||||
r0 = ret.Get(0).(int)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
@@ -54,31 +69,33 @@ func (_e *MockInterface_Expecter) Run(ctx interface{}, args interface{}, version
|
||||
|
||||
func (_c *MockInterface_Run_Call) Run(run func(ctx context.Context, args []string, version string)) *MockInterface_Run_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context), args[1].([]string), args[2].(string))
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 []string
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].([]string)
|
||||
}
|
||||
var arg2 string
|
||||
if args[2] != nil {
|
||||
arg2 = args[2].(string)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
arg2,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Run_Call) Return(_a0 int) *MockInterface_Run_Call {
|
||||
_c.Call.Return(_a0)
|
||||
func (_c *MockInterface_Run_Call) Return(n int) *MockInterface_Run_Call {
|
||||
_c.Call.Return(n)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Run_Call) RunAndReturn(run func(context.Context, []string, string) int) *MockInterface_Run_Call {
|
||||
func (_c *MockInterface_Run_Call) RunAndReturn(run func(ctx context.Context, args []string, version string) int) *MockInterface_Run_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -1,12 +1,28 @@
|
||||
// Code generated by mockery v2.51.0. DO NOT EDIT.
|
||||
// Code generated by mockery; DO NOT EDIT.
|
||||
// github.com/vektra/mockery
|
||||
// template: testify
|
||||
|
||||
package reader_mock
|
||||
|
||||
import (
|
||||
credentialplugin "github.com/int128/kubelogin/pkg/credentialplugin"
|
||||
"github.com/int128/kubelogin/pkg/credentialplugin"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockInterface is an autogenerated mock type for the Interface type
|
||||
type MockInterface struct {
|
||||
mock.Mock
|
||||
@@ -20,9 +36,9 @@ func (_m *MockInterface) EXPECT() *MockInterface_Expecter {
|
||||
return &MockInterface_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Read provides a mock function with no fields
|
||||
func (_m *MockInterface) Read() (credentialplugin.Input, error) {
|
||||
ret := _m.Called()
|
||||
// Read provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) Read() (credentialplugin.Input, error) {
|
||||
ret := _mock.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Read")
|
||||
@@ -30,21 +46,19 @@ func (_m *MockInterface) Read() (credentialplugin.Input, error) {
|
||||
|
||||
var r0 credentialplugin.Input
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func() (credentialplugin.Input, error)); ok {
|
||||
return rf()
|
||||
if returnFunc, ok := ret.Get(0).(func() (credentialplugin.Input, error)); ok {
|
||||
return returnFunc()
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func() credentialplugin.Input); ok {
|
||||
r0 = rf()
|
||||
if returnFunc, ok := ret.Get(0).(func() credentialplugin.Input); ok {
|
||||
r0 = returnFunc()
|
||||
} else {
|
||||
r0 = ret.Get(0).(credentialplugin.Input)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func() error); ok {
|
||||
r1 = rf()
|
||||
if returnFunc, ok := ret.Get(1).(func() error); ok {
|
||||
r1 = returnFunc()
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
@@ -65,8 +79,8 @@ func (_c *MockInterface_Read_Call) Run(run func()) *MockInterface_Read_Call {
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Read_Call) Return(_a0 credentialplugin.Input, _a1 error) *MockInterface_Read_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
func (_c *MockInterface_Read_Call) Return(input credentialplugin.Input, err error) *MockInterface_Read_Call {
|
||||
_c.Call.Return(input, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
@@ -74,17 +88,3 @@ func (_c *MockInterface_Read_Call) RunAndReturn(run func() (credentialplugin.Inp
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -1,12 +1,28 @@
|
||||
// Code generated by mockery v2.51.0. DO NOT EDIT.
|
||||
// Code generated by mockery; DO NOT EDIT.
|
||||
// github.com/vektra/mockery
|
||||
// template: testify
|
||||
|
||||
package writer_mock
|
||||
|
||||
import (
|
||||
credentialplugin "github.com/int128/kubelogin/pkg/credentialplugin"
|
||||
"github.com/int128/kubelogin/pkg/credentialplugin"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockInterface is an autogenerated mock type for the Interface type
|
||||
type MockInterface struct {
|
||||
mock.Mock
|
||||
@@ -20,21 +36,20 @@ func (_m *MockInterface) EXPECT() *MockInterface_Expecter {
|
||||
return &MockInterface_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Write provides a mock function with given fields: out
|
||||
func (_m *MockInterface) Write(out credentialplugin.Output) error {
|
||||
ret := _m.Called(out)
|
||||
// Write provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) Write(out credentialplugin.Output) error {
|
||||
ret := _mock.Called(out)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Write")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(credentialplugin.Output) error); ok {
|
||||
r0 = rf(out)
|
||||
if returnFunc, ok := ret.Get(0).(func(credentialplugin.Output) error); ok {
|
||||
r0 = returnFunc(out)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
@@ -51,31 +66,23 @@ func (_e *MockInterface_Expecter) Write(out interface{}) *MockInterface_Write_Ca
|
||||
|
||||
func (_c *MockInterface_Write_Call) Run(run func(out credentialplugin.Output)) *MockInterface_Write_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(credentialplugin.Output))
|
||||
var arg0 credentialplugin.Output
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(credentialplugin.Output)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Write_Call) Return(_a0 error) *MockInterface_Write_Call {
|
||||
_c.Call.Return(_a0)
|
||||
func (_c *MockInterface_Write_Call) Return(err error) *MockInterface_Write_Call {
|
||||
_c.Call.Return(err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Write_Call) RunAndReturn(run func(credentialplugin.Output) error) *MockInterface_Write_Call {
|
||||
func (_c *MockInterface_Write_Call) RunAndReturn(run func(out credentialplugin.Output) error) *MockInterface_Write_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -1,13 +1,29 @@
|
||||
// Code generated by mockery v2.51.0. DO NOT EDIT.
|
||||
// Code generated by mockery; DO NOT EDIT.
|
||||
// github.com/vektra/mockery
|
||||
// template: testify
|
||||
|
||||
package browser_mock
|
||||
|
||||
import (
|
||||
context "context"
|
||||
"context"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockInterface is an autogenerated mock type for the Interface type
|
||||
type MockInterface struct {
|
||||
mock.Mock
|
||||
@@ -21,21 +37,20 @@ func (_m *MockInterface) EXPECT() *MockInterface_Expecter {
|
||||
return &MockInterface_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Open provides a mock function with given fields: url
|
||||
func (_m *MockInterface) Open(url string) error {
|
||||
ret := _m.Called(url)
|
||||
// Open provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) Open(url string) error {
|
||||
ret := _mock.Called(url)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Open")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(string) error); ok {
|
||||
r0 = rf(url)
|
||||
if returnFunc, ok := ret.Get(0).(func(string) error); ok {
|
||||
r0 = returnFunc(url)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
@@ -52,36 +67,41 @@ func (_e *MockInterface_Expecter) Open(url interface{}) *MockInterface_Open_Call
|
||||
|
||||
func (_c *MockInterface_Open_Call) Run(run func(url string)) *MockInterface_Open_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string))
|
||||
var arg0 string
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(string)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Open_Call) Return(_a0 error) *MockInterface_Open_Call {
|
||||
_c.Call.Return(_a0)
|
||||
func (_c *MockInterface_Open_Call) Return(err error) *MockInterface_Open_Call {
|
||||
_c.Call.Return(err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Open_Call) RunAndReturn(run func(string) error) *MockInterface_Open_Call {
|
||||
func (_c *MockInterface_Open_Call) RunAndReturn(run func(url string) error) *MockInterface_Open_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// OpenCommand provides a mock function with given fields: ctx, url, command
|
||||
func (_m *MockInterface) OpenCommand(ctx context.Context, url string, command string) error {
|
||||
ret := _m.Called(ctx, url, command)
|
||||
// OpenCommand provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) OpenCommand(ctx context.Context, url string, command string) error {
|
||||
ret := _mock.Called(ctx, url, command)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for OpenCommand")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok {
|
||||
r0 = rf(ctx, url, command)
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, string, string) error); ok {
|
||||
r0 = returnFunc(ctx, url, command)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
@@ -100,31 +120,33 @@ func (_e *MockInterface_Expecter) OpenCommand(ctx interface{}, url interface{},
|
||||
|
||||
func (_c *MockInterface_OpenCommand_Call) Run(run func(ctx context.Context, url string, command string)) *MockInterface_OpenCommand_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context), args[1].(string), args[2].(string))
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 string
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(string)
|
||||
}
|
||||
var arg2 string
|
||||
if args[2] != nil {
|
||||
arg2 = args[2].(string)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
arg2,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_OpenCommand_Call) Return(_a0 error) *MockInterface_OpenCommand_Call {
|
||||
_c.Call.Return(_a0)
|
||||
func (_c *MockInterface_OpenCommand_Call) Return(err error) *MockInterface_OpenCommand_Call {
|
||||
_c.Call.Return(err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_OpenCommand_Call) RunAndReturn(run func(context.Context, string, string) error) *MockInterface_OpenCommand_Call {
|
||||
func (_c *MockInterface_OpenCommand_Call) RunAndReturn(run func(ctx context.Context, url string, command string) error) *MockInterface_OpenCommand_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -1,13 +1,29 @@
|
||||
// Code generated by mockery v2.51.0. DO NOT EDIT.
|
||||
// Code generated by mockery; DO NOT EDIT.
|
||||
// github.com/vektra/mockery
|
||||
// template: testify
|
||||
|
||||
package clock_mock
|
||||
|
||||
import (
|
||||
time "time"
|
||||
"time"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockInterface is an autogenerated mock type for the Interface type
|
||||
type MockInterface struct {
|
||||
mock.Mock
|
||||
@@ -21,21 +37,20 @@ func (_m *MockInterface) EXPECT() *MockInterface_Expecter {
|
||||
return &MockInterface_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Now provides a mock function with no fields
|
||||
func (_m *MockInterface) Now() time.Time {
|
||||
ret := _m.Called()
|
||||
// Now provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) Now() time.Time {
|
||||
ret := _mock.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Now")
|
||||
}
|
||||
|
||||
var r0 time.Time
|
||||
if rf, ok := ret.Get(0).(func() time.Time); ok {
|
||||
r0 = rf()
|
||||
if returnFunc, ok := ret.Get(0).(func() time.Time); ok {
|
||||
r0 = returnFunc()
|
||||
} else {
|
||||
r0 = ret.Get(0).(time.Time)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
@@ -56,8 +71,8 @@ func (_c *MockInterface_Now_Call) Run(run func()) *MockInterface_Now_Call {
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Now_Call) Return(_a0 time.Time) *MockInterface_Now_Call {
|
||||
_c.Call.Return(_a0)
|
||||
func (_c *MockInterface_Now_Call) Return(time1 time.Time) *MockInterface_Now_Call {
|
||||
_c.Call.Return(time1)
|
||||
return _c
|
||||
}
|
||||
|
||||
@@ -65,17 +80,3 @@ func (_c *MockInterface_Now_Call) RunAndReturn(run func() time.Time) *MockInterf
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -1,208 +0,0 @@
|
||||
// Code generated by mockery v2.51.0. DO NOT EDIT.
|
||||
|
||||
package logger_mock
|
||||
|
||||
import (
|
||||
logger "github.com/int128/kubelogin/pkg/infrastructure/logger"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
|
||||
pflag "github.com/spf13/pflag"
|
||||
)
|
||||
|
||||
// MockInterface is an autogenerated mock type for the Interface type
|
||||
type MockInterface struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type MockInterface_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *MockInterface) EXPECT() *MockInterface_Expecter {
|
||||
return &MockInterface_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// AddFlags provides a mock function with given fields: f
|
||||
func (_m *MockInterface) AddFlags(f *pflag.FlagSet) {
|
||||
_m.Called(f)
|
||||
}
|
||||
|
||||
// MockInterface_AddFlags_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFlags'
|
||||
type MockInterface_AddFlags_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// AddFlags is a helper method to define mock.On call
|
||||
// - f *pflag.FlagSet
|
||||
func (_e *MockInterface_Expecter) AddFlags(f interface{}) *MockInterface_AddFlags_Call {
|
||||
return &MockInterface_AddFlags_Call{Call: _e.mock.On("AddFlags", f)}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_AddFlags_Call) Run(run func(f *pflag.FlagSet)) *MockInterface_AddFlags_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(*pflag.FlagSet))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_AddFlags_Call) Return() *MockInterface_AddFlags_Call {
|
||||
_c.Call.Return()
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_AddFlags_Call) RunAndReturn(run func(*pflag.FlagSet)) *MockInterface_AddFlags_Call {
|
||||
_c.Run(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// IsEnabled provides a mock function with given fields: level
|
||||
func (_m *MockInterface) IsEnabled(level int) bool {
|
||||
ret := _m.Called(level)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for IsEnabled")
|
||||
}
|
||||
|
||||
var r0 bool
|
||||
if rf, ok := ret.Get(0).(func(int) bool); ok {
|
||||
r0 = rf(level)
|
||||
} else {
|
||||
r0 = ret.Get(0).(bool)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockInterface_IsEnabled_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsEnabled'
|
||||
type MockInterface_IsEnabled_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// IsEnabled is a helper method to define mock.On call
|
||||
// - level int
|
||||
func (_e *MockInterface_Expecter) IsEnabled(level interface{}) *MockInterface_IsEnabled_Call {
|
||||
return &MockInterface_IsEnabled_Call{Call: _e.mock.On("IsEnabled", level)}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_IsEnabled_Call) Run(run func(level int)) *MockInterface_IsEnabled_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(int))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_IsEnabled_Call) Return(_a0 bool) *MockInterface_IsEnabled_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_IsEnabled_Call) RunAndReturn(run func(int) bool) *MockInterface_IsEnabled_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Printf provides a mock function with given fields: format, args
|
||||
func (_m *MockInterface) Printf(format string, args ...interface{}) {
|
||||
var _ca []interface{}
|
||||
_ca = append(_ca, format)
|
||||
_ca = append(_ca, args...)
|
||||
_m.Called(_ca...)
|
||||
}
|
||||
|
||||
// MockInterface_Printf_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Printf'
|
||||
type MockInterface_Printf_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Printf is a helper method to define mock.On call
|
||||
// - format string
|
||||
// - args ...interface{}
|
||||
func (_e *MockInterface_Expecter) Printf(format interface{}, args ...interface{}) *MockInterface_Printf_Call {
|
||||
return &MockInterface_Printf_Call{Call: _e.mock.On("Printf",
|
||||
append([]interface{}{format}, args...)...)}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Printf_Call) Run(run func(format string, args ...interface{})) *MockInterface_Printf_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
variadicArgs := make([]interface{}, len(args)-1)
|
||||
for i, a := range args[1:] {
|
||||
if a != nil {
|
||||
variadicArgs[i] = a.(interface{})
|
||||
}
|
||||
}
|
||||
run(args[0].(string), variadicArgs...)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Printf_Call) Return() *MockInterface_Printf_Call {
|
||||
_c.Call.Return()
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Printf_Call) RunAndReturn(run func(string, ...interface{})) *MockInterface_Printf_Call {
|
||||
_c.Run(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// V provides a mock function with given fields: level
|
||||
func (_m *MockInterface) V(level int) logger.Verbose {
|
||||
ret := _m.Called(level)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for V")
|
||||
}
|
||||
|
||||
var r0 logger.Verbose
|
||||
if rf, ok := ret.Get(0).(func(int) logger.Verbose); ok {
|
||||
r0 = rf(level)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(logger.Verbose)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockInterface_V_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'V'
|
||||
type MockInterface_V_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// V is a helper method to define mock.On call
|
||||
// - level int
|
||||
func (_e *MockInterface_Expecter) V(level interface{}) *MockInterface_V_Call {
|
||||
return &MockInterface_V_Call{Call: _e.mock.On("V", level)}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_V_Call) Run(run func(level int)) *MockInterface_V_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(int))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_V_Call) Return(_a0 logger.Verbose) *MockInterface_V_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_V_Call) RunAndReturn(run func(int) logger.Verbose) *MockInterface_V_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
// Code generated by mockery v2.51.0. DO NOT EDIT.
|
||||
|
||||
package logger_mock
|
||||
|
||||
import mock "github.com/stretchr/testify/mock"
|
||||
|
||||
// MockVerbose is an autogenerated mock type for the Verbose type
|
||||
type MockVerbose struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type MockVerbose_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *MockVerbose) EXPECT() *MockVerbose_Expecter {
|
||||
return &MockVerbose_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Infof provides a mock function with given fields: format, args
|
||||
func (_m *MockVerbose) Infof(format string, args ...interface{}) {
|
||||
var _ca []interface{}
|
||||
_ca = append(_ca, format)
|
||||
_ca = append(_ca, args...)
|
||||
_m.Called(_ca...)
|
||||
}
|
||||
|
||||
// MockVerbose_Infof_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Infof'
|
||||
type MockVerbose_Infof_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Infof is a helper method to define mock.On call
|
||||
// - format string
|
||||
// - args ...interface{}
|
||||
func (_e *MockVerbose_Expecter) Infof(format interface{}, args ...interface{}) *MockVerbose_Infof_Call {
|
||||
return &MockVerbose_Infof_Call{Call: _e.mock.On("Infof",
|
||||
append([]interface{}{format}, args...)...)}
|
||||
}
|
||||
|
||||
func (_c *MockVerbose_Infof_Call) Run(run func(format string, args ...interface{})) *MockVerbose_Infof_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
variadicArgs := make([]interface{}, len(args)-1)
|
||||
for i, a := range args[1:] {
|
||||
if a != nil {
|
||||
variadicArgs[i] = a.(interface{})
|
||||
}
|
||||
}
|
||||
run(args[0].(string), variadicArgs...)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockVerbose_Infof_Call) Return() *MockVerbose_Infof_Call {
|
||||
_c.Call.Return()
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockVerbose_Infof_Call) RunAndReturn(run func(string, ...interface{})) *MockVerbose_Infof_Call {
|
||||
_c.Run(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockVerbose creates a new instance of MockVerbose. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockVerbose(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockVerbose {
|
||||
mock := &MockVerbose{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
// Code generated by mockery v2.51.0. DO NOT EDIT.
|
||||
|
||||
package logger_mock
|
||||
|
||||
import mock "github.com/stretchr/testify/mock"
|
||||
|
||||
// MockgoLogger is an autogenerated mock type for the goLogger type
|
||||
type MockgoLogger struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type MockgoLogger_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *MockgoLogger) EXPECT() *MockgoLogger_Expecter {
|
||||
return &MockgoLogger_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Printf provides a mock function with given fields: format, v
|
||||
func (_m *MockgoLogger) Printf(format string, v ...interface{}) {
|
||||
var _ca []interface{}
|
||||
_ca = append(_ca, format)
|
||||
_ca = append(_ca, v...)
|
||||
_m.Called(_ca...)
|
||||
}
|
||||
|
||||
// MockgoLogger_Printf_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Printf'
|
||||
type MockgoLogger_Printf_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Printf is a helper method to define mock.On call
|
||||
// - format string
|
||||
// - v ...interface{}
|
||||
func (_e *MockgoLogger_Expecter) Printf(format interface{}, v ...interface{}) *MockgoLogger_Printf_Call {
|
||||
return &MockgoLogger_Printf_Call{Call: _e.mock.On("Printf",
|
||||
append([]interface{}{format}, v...)...)}
|
||||
}
|
||||
|
||||
func (_c *MockgoLogger_Printf_Call) Run(run func(format string, v ...interface{})) *MockgoLogger_Printf_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
variadicArgs := make([]interface{}, len(args)-1)
|
||||
for i, a := range args[1:] {
|
||||
if a != nil {
|
||||
variadicArgs[i] = a.(interface{})
|
||||
}
|
||||
}
|
||||
run(args[0].(string), variadicArgs...)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockgoLogger_Printf_Call) Return() *MockgoLogger_Printf_Call {
|
||||
_c.Call.Return()
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockgoLogger_Printf_Call) RunAndReturn(run func(string, ...interface{})) *MockgoLogger_Printf_Call {
|
||||
_c.Run(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockgoLogger creates a new instance of MockgoLogger. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockgoLogger(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockgoLogger {
|
||||
mock := &MockgoLogger{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -0,0 +1,398 @@
|
||||
// Code generated by mockery; DO NOT EDIT.
|
||||
// github.com/vektra/mockery
|
||||
// template: testify
|
||||
|
||||
package logger_mock
|
||||
|
||||
import (
|
||||
"github.com/int128/kubelogin/pkg/infrastructure/logger"
|
||||
"github.com/spf13/pflag"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockInterface is an autogenerated mock type for the Interface type
|
||||
type MockInterface struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type MockInterface_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *MockInterface) EXPECT() *MockInterface_Expecter {
|
||||
return &MockInterface_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// AddFlags provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) AddFlags(f *pflag.FlagSet) {
|
||||
_mock.Called(f)
|
||||
return
|
||||
}
|
||||
|
||||
// MockInterface_AddFlags_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFlags'
|
||||
type MockInterface_AddFlags_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// AddFlags is a helper method to define mock.On call
|
||||
// - f *pflag.FlagSet
|
||||
func (_e *MockInterface_Expecter) AddFlags(f interface{}) *MockInterface_AddFlags_Call {
|
||||
return &MockInterface_AddFlags_Call{Call: _e.mock.On("AddFlags", f)}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_AddFlags_Call) Run(run func(f *pflag.FlagSet)) *MockInterface_AddFlags_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 *pflag.FlagSet
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(*pflag.FlagSet)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_AddFlags_Call) Return() *MockInterface_AddFlags_Call {
|
||||
_c.Call.Return()
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_AddFlags_Call) RunAndReturn(run func(f *pflag.FlagSet)) *MockInterface_AddFlags_Call {
|
||||
_c.Run(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// IsEnabled provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) IsEnabled(level int) bool {
|
||||
ret := _mock.Called(level)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for IsEnabled")
|
||||
}
|
||||
|
||||
var r0 bool
|
||||
if returnFunc, ok := ret.Get(0).(func(int) bool); ok {
|
||||
r0 = returnFunc(level)
|
||||
} else {
|
||||
r0 = ret.Get(0).(bool)
|
||||
}
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockInterface_IsEnabled_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsEnabled'
|
||||
type MockInterface_IsEnabled_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// IsEnabled is a helper method to define mock.On call
|
||||
// - level int
|
||||
func (_e *MockInterface_Expecter) IsEnabled(level interface{}) *MockInterface_IsEnabled_Call {
|
||||
return &MockInterface_IsEnabled_Call{Call: _e.mock.On("IsEnabled", level)}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_IsEnabled_Call) Run(run func(level int)) *MockInterface_IsEnabled_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 int
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(int)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_IsEnabled_Call) Return(b bool) *MockInterface_IsEnabled_Call {
|
||||
_c.Call.Return(b)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_IsEnabled_Call) RunAndReturn(run func(level int) bool) *MockInterface_IsEnabled_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Printf provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) Printf(format string, args ...interface{}) {
|
||||
if len(args) > 0 {
|
||||
_mock.Called(format, args)
|
||||
} else {
|
||||
_mock.Called(format)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// MockInterface_Printf_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Printf'
|
||||
type MockInterface_Printf_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Printf is a helper method to define mock.On call
|
||||
// - format string
|
||||
// - args ...interface{}
|
||||
func (_e *MockInterface_Expecter) Printf(format interface{}, args ...interface{}) *MockInterface_Printf_Call {
|
||||
return &MockInterface_Printf_Call{Call: _e.mock.On("Printf",
|
||||
append([]interface{}{format}, args...)...)}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Printf_Call) Run(run func(format string, args ...interface{})) *MockInterface_Printf_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 string
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(string)
|
||||
}
|
||||
var arg1 []interface{}
|
||||
var variadicArgs []interface{}
|
||||
if len(args) > 1 {
|
||||
variadicArgs = args[1].([]interface{})
|
||||
}
|
||||
arg1 = variadicArgs
|
||||
run(
|
||||
arg0,
|
||||
arg1...,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Printf_Call) Return() *MockInterface_Printf_Call {
|
||||
_c.Call.Return()
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Printf_Call) RunAndReturn(run func(format string, args ...interface{})) *MockInterface_Printf_Call {
|
||||
_c.Run(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// V provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) V(level int) logger.Verbose {
|
||||
ret := _mock.Called(level)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for V")
|
||||
}
|
||||
|
||||
var r0 logger.Verbose
|
||||
if returnFunc, ok := ret.Get(0).(func(int) logger.Verbose); ok {
|
||||
r0 = returnFunc(level)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(logger.Verbose)
|
||||
}
|
||||
}
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockInterface_V_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'V'
|
||||
type MockInterface_V_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// V is a helper method to define mock.On call
|
||||
// - level int
|
||||
func (_e *MockInterface_Expecter) V(level interface{}) *MockInterface_V_Call {
|
||||
return &MockInterface_V_Call{Call: _e.mock.On("V", level)}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_V_Call) Run(run func(level int)) *MockInterface_V_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 int
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(int)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_V_Call) Return(verbose logger.Verbose) *MockInterface_V_Call {
|
||||
_c.Call.Return(verbose)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_V_Call) RunAndReturn(run func(level int) logger.Verbose) *MockInterface_V_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockVerbose creates a new instance of MockVerbose. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockVerbose(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockVerbose {
|
||||
mock := &MockVerbose{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockVerbose is an autogenerated mock type for the Verbose type
|
||||
type MockVerbose struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type MockVerbose_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *MockVerbose) EXPECT() *MockVerbose_Expecter {
|
||||
return &MockVerbose_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Infof provides a mock function for the type MockVerbose
|
||||
func (_mock *MockVerbose) Infof(format string, args ...interface{}) {
|
||||
if len(args) > 0 {
|
||||
_mock.Called(format, args)
|
||||
} else {
|
||||
_mock.Called(format)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// MockVerbose_Infof_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Infof'
|
||||
type MockVerbose_Infof_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Infof is a helper method to define mock.On call
|
||||
// - format string
|
||||
// - args ...interface{}
|
||||
func (_e *MockVerbose_Expecter) Infof(format interface{}, args ...interface{}) *MockVerbose_Infof_Call {
|
||||
return &MockVerbose_Infof_Call{Call: _e.mock.On("Infof",
|
||||
append([]interface{}{format}, args...)...)}
|
||||
}
|
||||
|
||||
func (_c *MockVerbose_Infof_Call) Run(run func(format string, args ...interface{})) *MockVerbose_Infof_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 string
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(string)
|
||||
}
|
||||
var arg1 []interface{}
|
||||
var variadicArgs []interface{}
|
||||
if len(args) > 1 {
|
||||
variadicArgs = args[1].([]interface{})
|
||||
}
|
||||
arg1 = variadicArgs
|
||||
run(
|
||||
arg0,
|
||||
arg1...,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockVerbose_Infof_Call) Return() *MockVerbose_Infof_Call {
|
||||
_c.Call.Return()
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockVerbose_Infof_Call) RunAndReturn(run func(format string, args ...interface{})) *MockVerbose_Infof_Call {
|
||||
_c.Run(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// newMockgoLogger creates a new instance of mockgoLogger. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func newMockgoLogger(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *mockgoLogger {
|
||||
mock := &mockgoLogger{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// mockgoLogger is an autogenerated mock type for the goLogger type
|
||||
type mockgoLogger struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type mockgoLogger_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *mockgoLogger) EXPECT() *mockgoLogger_Expecter {
|
||||
return &mockgoLogger_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Printf provides a mock function for the type mockgoLogger
|
||||
func (_mock *mockgoLogger) Printf(format string, v ...interface{}) {
|
||||
if len(v) > 0 {
|
||||
_mock.Called(format, v)
|
||||
} else {
|
||||
_mock.Called(format)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// mockgoLogger_Printf_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Printf'
|
||||
type mockgoLogger_Printf_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Printf is a helper method to define mock.On call
|
||||
// - format string
|
||||
// - v ...interface{}
|
||||
func (_e *mockgoLogger_Expecter) Printf(format interface{}, v ...interface{}) *mockgoLogger_Printf_Call {
|
||||
return &mockgoLogger_Printf_Call{Call: _e.mock.On("Printf",
|
||||
append([]interface{}{format}, v...)...)}
|
||||
}
|
||||
|
||||
func (_c *mockgoLogger_Printf_Call) Run(run func(format string, v ...interface{})) *mockgoLogger_Printf_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 string
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(string)
|
||||
}
|
||||
var arg1 []interface{}
|
||||
var variadicArgs []interface{}
|
||||
if len(args) > 1 {
|
||||
variadicArgs = args[1].([]interface{})
|
||||
}
|
||||
arg1 = variadicArgs
|
||||
run(
|
||||
arg0,
|
||||
arg1...,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *mockgoLogger_Printf_Call) Return() *mockgoLogger_Printf_Call {
|
||||
_c.Call.Return()
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *mockgoLogger_Printf_Call) RunAndReturn(run func(format string, v ...interface{})) *mockgoLogger_Printf_Call {
|
||||
_c.Run(run)
|
||||
return _c
|
||||
}
|
||||
@@ -1,8 +1,26 @@
|
||||
// Code generated by mockery v2.51.0. DO NOT EDIT.
|
||||
// Code generated by mockery; DO NOT EDIT.
|
||||
// github.com/vektra/mockery
|
||||
// template: testify
|
||||
|
||||
package reader_mock
|
||||
|
||||
import mock "github.com/stretchr/testify/mock"
|
||||
import (
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockInterface is an autogenerated mock type for the Interface type
|
||||
type MockInterface struct {
|
||||
@@ -17,9 +35,9 @@ func (_m *MockInterface) EXPECT() *MockInterface_Expecter {
|
||||
return &MockInterface_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// ReadPassword provides a mock function with given fields: prompt
|
||||
func (_m *MockInterface) ReadPassword(prompt string) (string, error) {
|
||||
ret := _m.Called(prompt)
|
||||
// ReadPassword provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) ReadPassword(prompt string) (string, error) {
|
||||
ret := _mock.Called(prompt)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ReadPassword")
|
||||
@@ -27,21 +45,19 @@ func (_m *MockInterface) ReadPassword(prompt string) (string, error) {
|
||||
|
||||
var r0 string
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string) (string, error)); ok {
|
||||
return rf(prompt)
|
||||
if returnFunc, ok := ret.Get(0).(func(string) (string, error)); ok {
|
||||
return returnFunc(prompt)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string) string); ok {
|
||||
r0 = rf(prompt)
|
||||
if returnFunc, ok := ret.Get(0).(func(string) string); ok {
|
||||
r0 = returnFunc(prompt)
|
||||
} else {
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string) error); ok {
|
||||
r1 = rf(prompt)
|
||||
if returnFunc, ok := ret.Get(1).(func(string) error); ok {
|
||||
r1 = returnFunc(prompt)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
@@ -58,24 +74,30 @@ func (_e *MockInterface_Expecter) ReadPassword(prompt interface{}) *MockInterfac
|
||||
|
||||
func (_c *MockInterface_ReadPassword_Call) Run(run func(prompt string)) *MockInterface_ReadPassword_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string))
|
||||
var arg0 string
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(string)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_ReadPassword_Call) Return(_a0 string, _a1 error) *MockInterface_ReadPassword_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
func (_c *MockInterface_ReadPassword_Call) Return(s string, err error) *MockInterface_ReadPassword_Call {
|
||||
_c.Call.Return(s, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_ReadPassword_Call) RunAndReturn(run func(string) (string, error)) *MockInterface_ReadPassword_Call {
|
||||
func (_c *MockInterface_ReadPassword_Call) RunAndReturn(run func(prompt string) (string, error)) *MockInterface_ReadPassword_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// ReadString provides a mock function with given fields: prompt
|
||||
func (_m *MockInterface) ReadString(prompt string) (string, error) {
|
||||
ret := _m.Called(prompt)
|
||||
// ReadString provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) ReadString(prompt string) (string, error) {
|
||||
ret := _mock.Called(prompt)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ReadString")
|
||||
@@ -83,21 +105,19 @@ func (_m *MockInterface) ReadString(prompt string) (string, error) {
|
||||
|
||||
var r0 string
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string) (string, error)); ok {
|
||||
return rf(prompt)
|
||||
if returnFunc, ok := ret.Get(0).(func(string) (string, error)); ok {
|
||||
return returnFunc(prompt)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string) string); ok {
|
||||
r0 = rf(prompt)
|
||||
if returnFunc, ok := ret.Get(0).(func(string) string); ok {
|
||||
r0 = returnFunc(prompt)
|
||||
} else {
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string) error); ok {
|
||||
r1 = rf(prompt)
|
||||
if returnFunc, ok := ret.Get(1).(func(string) error); ok {
|
||||
r1 = returnFunc(prompt)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
@@ -114,31 +134,23 @@ func (_e *MockInterface_Expecter) ReadString(prompt interface{}) *MockInterface_
|
||||
|
||||
func (_c *MockInterface_ReadString_Call) Run(run func(prompt string)) *MockInterface_ReadString_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string))
|
||||
var arg0 string
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(string)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_ReadString_Call) Return(_a0 string, _a1 error) *MockInterface_ReadString_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
func (_c *MockInterface_ReadString_Call) Return(s string, err error) *MockInterface_ReadString_Call {
|
||||
_c.Call.Return(s, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_ReadString_Call) RunAndReturn(run func(string) (string, error)) *MockInterface_ReadString_Call {
|
||||
func (_c *MockInterface_ReadString_Call) RunAndReturn(run func(prompt string) (string, error)) *MockInterface_ReadString_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
// Code generated by mockery v2.51.0. DO NOT EDIT.
|
||||
|
||||
package stdio_mock
|
||||
|
||||
import mock "github.com/stretchr/testify/mock"
|
||||
|
||||
// MockStdin is an autogenerated mock type for the Stdin type
|
||||
type MockStdin struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type MockStdin_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *MockStdin) EXPECT() *MockStdin_Expecter {
|
||||
return &MockStdin_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Read provides a mock function with given fields: p
|
||||
func (_m *MockStdin) Read(p []byte) (int, error) {
|
||||
ret := _m.Called(p)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Read")
|
||||
}
|
||||
|
||||
var r0 int
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func([]byte) (int, error)); ok {
|
||||
return rf(p)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func([]byte) int); ok {
|
||||
r0 = rf(p)
|
||||
} else {
|
||||
r0 = ret.Get(0).(int)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func([]byte) error); ok {
|
||||
r1 = rf(p)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockStdin_Read_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Read'
|
||||
type MockStdin_Read_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Read is a helper method to define mock.On call
|
||||
// - p []byte
|
||||
func (_e *MockStdin_Expecter) Read(p interface{}) *MockStdin_Read_Call {
|
||||
return &MockStdin_Read_Call{Call: _e.mock.On("Read", p)}
|
||||
}
|
||||
|
||||
func (_c *MockStdin_Read_Call) Run(run func(p []byte)) *MockStdin_Read_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].([]byte))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockStdin_Read_Call) Return(n int, err error) *MockStdin_Read_Call {
|
||||
_c.Call.Return(n, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockStdin_Read_Call) RunAndReturn(run func([]byte) (int, error)) *MockStdin_Read_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockStdin creates a new instance of MockStdin. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockStdin(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockStdin {
|
||||
mock := &MockStdin{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
// Code generated by mockery v2.51.0. DO NOT EDIT.
|
||||
|
||||
package stdio_mock
|
||||
|
||||
import mock "github.com/stretchr/testify/mock"
|
||||
|
||||
// MockStdout is an autogenerated mock type for the Stdout type
|
||||
type MockStdout struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type MockStdout_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *MockStdout) EXPECT() *MockStdout_Expecter {
|
||||
return &MockStdout_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Write provides a mock function with given fields: p
|
||||
func (_m *MockStdout) Write(p []byte) (int, error) {
|
||||
ret := _m.Called(p)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Write")
|
||||
}
|
||||
|
||||
var r0 int
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func([]byte) (int, error)); ok {
|
||||
return rf(p)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func([]byte) int); ok {
|
||||
r0 = rf(p)
|
||||
} else {
|
||||
r0 = ret.Get(0).(int)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func([]byte) error); ok {
|
||||
r1 = rf(p)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockStdout_Write_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Write'
|
||||
type MockStdout_Write_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Write is a helper method to define mock.On call
|
||||
// - p []byte
|
||||
func (_e *MockStdout_Expecter) Write(p interface{}) *MockStdout_Write_Call {
|
||||
return &MockStdout_Write_Call{Call: _e.mock.On("Write", p)}
|
||||
}
|
||||
|
||||
func (_c *MockStdout_Write_Call) Run(run func(p []byte)) *MockStdout_Write_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].([]byte))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockStdout_Write_Call) Return(n int, err error) *MockStdout_Write_Call {
|
||||
_c.Call.Return(n, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockStdout_Write_Call) RunAndReturn(run func([]byte) (int, error)) *MockStdout_Write_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockStdout creates a new instance of MockStdout. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockStdout(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockStdout {
|
||||
mock := &MockStdout{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
// Code generated by mockery; DO NOT EDIT.
|
||||
// github.com/vektra/mockery
|
||||
// template: testify
|
||||
|
||||
package stdio_mock
|
||||
|
||||
import (
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// NewMockStdout creates a new instance of MockStdout. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockStdout(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockStdout {
|
||||
mock := &MockStdout{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockStdout is an autogenerated mock type for the Stdout type
|
||||
type MockStdout struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type MockStdout_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *MockStdout) EXPECT() *MockStdout_Expecter {
|
||||
return &MockStdout_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Write provides a mock function for the type MockStdout
|
||||
func (_mock *MockStdout) Write(p []byte) (int, error) {
|
||||
ret := _mock.Called(p)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Write")
|
||||
}
|
||||
|
||||
var r0 int
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func([]byte) (int, error)); ok {
|
||||
return returnFunc(p)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func([]byte) int); ok {
|
||||
r0 = returnFunc(p)
|
||||
} else {
|
||||
r0 = ret.Get(0).(int)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func([]byte) error); ok {
|
||||
r1 = returnFunc(p)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockStdout_Write_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Write'
|
||||
type MockStdout_Write_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Write is a helper method to define mock.On call
|
||||
// - p []byte
|
||||
func (_e *MockStdout_Expecter) Write(p interface{}) *MockStdout_Write_Call {
|
||||
return &MockStdout_Write_Call{Call: _e.mock.On("Write", p)}
|
||||
}
|
||||
|
||||
func (_c *MockStdout_Write_Call) Run(run func(p []byte)) *MockStdout_Write_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 []byte
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].([]byte)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockStdout_Write_Call) Return(n int, err error) *MockStdout_Write_Call {
|
||||
_c.Call.Return(n, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockStdout_Write_Call) RunAndReturn(run func(p []byte) (int, error)) *MockStdout_Write_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockStdin creates a new instance of MockStdin. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockStdin(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockStdin {
|
||||
mock := &MockStdin{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockStdin is an autogenerated mock type for the Stdin type
|
||||
type MockStdin struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type MockStdin_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *MockStdin) EXPECT() *MockStdin_Expecter {
|
||||
return &MockStdin_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Read provides a mock function for the type MockStdin
|
||||
func (_mock *MockStdin) Read(p []byte) (int, error) {
|
||||
ret := _mock.Called(p)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Read")
|
||||
}
|
||||
|
||||
var r0 int
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func([]byte) (int, error)); ok {
|
||||
return returnFunc(p)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func([]byte) int); ok {
|
||||
r0 = returnFunc(p)
|
||||
} else {
|
||||
r0 = ret.Get(0).(int)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func([]byte) error); ok {
|
||||
r1 = returnFunc(p)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockStdin_Read_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Read'
|
||||
type MockStdin_Read_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Read is a helper method to define mock.On call
|
||||
// - p []byte
|
||||
func (_e *MockStdin_Expecter) Read(p interface{}) *MockStdin_Read_Call {
|
||||
return &MockStdin_Read_Call{Call: _e.mock.On("Read", p)}
|
||||
}
|
||||
|
||||
func (_c *MockStdin_Read_Call) Run(run func(p []byte)) *MockStdin_Read_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 []byte
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].([]byte)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockStdin_Read_Call) Return(n int, err error) *MockStdin_Read_Call {
|
||||
_c.Call.Return(n, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockStdin_Read_Call) RunAndReturn(run func(p []byte) (int, error)) *MockStdin_Read_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
@@ -1,13 +1,29 @@
|
||||
// Code generated by mockery v2.51.0. DO NOT EDIT.
|
||||
// Code generated by mockery; DO NOT EDIT.
|
||||
// github.com/vektra/mockery
|
||||
// template: testify
|
||||
|
||||
package jwt_mock
|
||||
|
||||
import (
|
||||
time "time"
|
||||
"time"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// NewMockClock creates a new instance of MockClock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockClock(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockClock {
|
||||
mock := &MockClock{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockClock is an autogenerated mock type for the Clock type
|
||||
type MockClock struct {
|
||||
mock.Mock
|
||||
@@ -21,21 +37,20 @@ func (_m *MockClock) EXPECT() *MockClock_Expecter {
|
||||
return &MockClock_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Now provides a mock function with no fields
|
||||
func (_m *MockClock) Now() time.Time {
|
||||
ret := _m.Called()
|
||||
// Now provides a mock function for the type MockClock
|
||||
func (_mock *MockClock) Now() time.Time {
|
||||
ret := _mock.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Now")
|
||||
}
|
||||
|
||||
var r0 time.Time
|
||||
if rf, ok := ret.Get(0).(func() time.Time); ok {
|
||||
r0 = rf()
|
||||
if returnFunc, ok := ret.Get(0).(func() time.Time); ok {
|
||||
r0 = returnFunc()
|
||||
} else {
|
||||
r0 = ret.Get(0).(time.Time)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
@@ -56,8 +71,8 @@ func (_c *MockClock_Now_Call) Run(run func()) *MockClock_Now_Call {
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockClock_Now_Call) Return(_a0 time.Time) *MockClock_Now_Call {
|
||||
_c.Call.Return(_a0)
|
||||
func (_c *MockClock_Now_Call) Return(time1 time.Time) *MockClock_Now_Call {
|
||||
_c.Call.Return(time1)
|
||||
return _c
|
||||
}
|
||||
|
||||
@@ -65,17 +80,3 @@ func (_c *MockClock_Now_Call) RunAndReturn(run func() time.Time) *MockClock_Now_
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockClock creates a new instance of MockClock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockClock(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockClock {
|
||||
mock := &MockClock{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -1,13 +1,28 @@
|
||||
// Code generated by mockery v2.51.0. DO NOT EDIT.
|
||||
// Code generated by mockery; DO NOT EDIT.
|
||||
// github.com/vektra/mockery
|
||||
// template: testify
|
||||
|
||||
package loader_mock
|
||||
|
||||
import (
|
||||
kubeconfig "github.com/int128/kubelogin/pkg/kubeconfig"
|
||||
|
||||
"github.com/int128/kubelogin/pkg/kubeconfig"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockInterface is an autogenerated mock type for the Interface type
|
||||
type MockInterface struct {
|
||||
mock.Mock
|
||||
@@ -21,9 +36,9 @@ func (_m *MockInterface) EXPECT() *MockInterface_Expecter {
|
||||
return &MockInterface_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// GetCurrentAuthProvider provides a mock function with given fields: explicitFilename, contextName, userName
|
||||
func (_m *MockInterface) GetCurrentAuthProvider(explicitFilename string, contextName kubeconfig.ContextName, userName kubeconfig.UserName) (*kubeconfig.AuthProvider, error) {
|
||||
ret := _m.Called(explicitFilename, contextName, userName)
|
||||
// GetCurrentAuthProvider provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) GetCurrentAuthProvider(explicitFilename string, contextName kubeconfig.ContextName, userName kubeconfig.UserName) (*kubeconfig.AuthProvider, error) {
|
||||
ret := _mock.Called(explicitFilename, contextName, userName)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetCurrentAuthProvider")
|
||||
@@ -31,23 +46,21 @@ func (_m *MockInterface) GetCurrentAuthProvider(explicitFilename string, context
|
||||
|
||||
var r0 *kubeconfig.AuthProvider
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string, kubeconfig.ContextName, kubeconfig.UserName) (*kubeconfig.AuthProvider, error)); ok {
|
||||
return rf(explicitFilename, contextName, userName)
|
||||
if returnFunc, ok := ret.Get(0).(func(string, kubeconfig.ContextName, kubeconfig.UserName) (*kubeconfig.AuthProvider, error)); ok {
|
||||
return returnFunc(explicitFilename, contextName, userName)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string, kubeconfig.ContextName, kubeconfig.UserName) *kubeconfig.AuthProvider); ok {
|
||||
r0 = rf(explicitFilename, contextName, userName)
|
||||
if returnFunc, ok := ret.Get(0).(func(string, kubeconfig.ContextName, kubeconfig.UserName) *kubeconfig.AuthProvider); ok {
|
||||
r0 = returnFunc(explicitFilename, contextName, userName)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*kubeconfig.AuthProvider)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string, kubeconfig.ContextName, kubeconfig.UserName) error); ok {
|
||||
r1 = rf(explicitFilename, contextName, userName)
|
||||
if returnFunc, ok := ret.Get(1).(func(string, kubeconfig.ContextName, kubeconfig.UserName) error); ok {
|
||||
r1 = returnFunc(explicitFilename, contextName, userName)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
@@ -66,31 +79,33 @@ func (_e *MockInterface_Expecter) GetCurrentAuthProvider(explicitFilename interf
|
||||
|
||||
func (_c *MockInterface_GetCurrentAuthProvider_Call) Run(run func(explicitFilename string, contextName kubeconfig.ContextName, userName kubeconfig.UserName)) *MockInterface_GetCurrentAuthProvider_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string), args[1].(kubeconfig.ContextName), args[2].(kubeconfig.UserName))
|
||||
var arg0 string
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(string)
|
||||
}
|
||||
var arg1 kubeconfig.ContextName
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(kubeconfig.ContextName)
|
||||
}
|
||||
var arg2 kubeconfig.UserName
|
||||
if args[2] != nil {
|
||||
arg2 = args[2].(kubeconfig.UserName)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
arg2,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetCurrentAuthProvider_Call) Return(_a0 *kubeconfig.AuthProvider, _a1 error) *MockInterface_GetCurrentAuthProvider_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
func (_c *MockInterface_GetCurrentAuthProvider_Call) Return(authProvider *kubeconfig.AuthProvider, err error) *MockInterface_GetCurrentAuthProvider_Call {
|
||||
_c.Call.Return(authProvider, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetCurrentAuthProvider_Call) RunAndReturn(run func(string, kubeconfig.ContextName, kubeconfig.UserName) (*kubeconfig.AuthProvider, error)) *MockInterface_GetCurrentAuthProvider_Call {
|
||||
func (_c *MockInterface_GetCurrentAuthProvider_Call) RunAndReturn(run func(explicitFilename string, contextName kubeconfig.ContextName, userName kubeconfig.UserName) (*kubeconfig.AuthProvider, error)) *MockInterface_GetCurrentAuthProvider_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -1,12 +1,28 @@
|
||||
// Code generated by mockery v2.51.0. DO NOT EDIT.
|
||||
// Code generated by mockery; DO NOT EDIT.
|
||||
// github.com/vektra/mockery
|
||||
// template: testify
|
||||
|
||||
package writer_mock
|
||||
|
||||
import (
|
||||
kubeconfig "github.com/int128/kubelogin/pkg/kubeconfig"
|
||||
"github.com/int128/kubelogin/pkg/kubeconfig"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockInterface is an autogenerated mock type for the Interface type
|
||||
type MockInterface struct {
|
||||
mock.Mock
|
||||
@@ -20,21 +36,20 @@ func (_m *MockInterface) EXPECT() *MockInterface_Expecter {
|
||||
return &MockInterface_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// UpdateAuthProvider provides a mock function with given fields: p
|
||||
func (_m *MockInterface) UpdateAuthProvider(p kubeconfig.AuthProvider) error {
|
||||
ret := _m.Called(p)
|
||||
// UpdateAuthProvider provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) UpdateAuthProvider(p kubeconfig.AuthProvider) error {
|
||||
ret := _mock.Called(p)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for UpdateAuthProvider")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(kubeconfig.AuthProvider) error); ok {
|
||||
r0 = rf(p)
|
||||
if returnFunc, ok := ret.Get(0).(func(kubeconfig.AuthProvider) error); ok {
|
||||
r0 = returnFunc(p)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
@@ -51,31 +66,23 @@ func (_e *MockInterface_Expecter) UpdateAuthProvider(p interface{}) *MockInterfa
|
||||
|
||||
func (_c *MockInterface_UpdateAuthProvider_Call) Run(run func(p kubeconfig.AuthProvider)) *MockInterface_UpdateAuthProvider_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(kubeconfig.AuthProvider))
|
||||
var arg0 kubeconfig.AuthProvider
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(kubeconfig.AuthProvider)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_UpdateAuthProvider_Call) Return(_a0 error) *MockInterface_UpdateAuthProvider_Call {
|
||||
_c.Call.Return(_a0)
|
||||
func (_c *MockInterface_UpdateAuthProvider_Call) Return(err error) *MockInterface_UpdateAuthProvider_Call {
|
||||
_c.Call.Return(err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_UpdateAuthProvider_Call) RunAndReturn(run func(kubeconfig.AuthProvider) error) *MockInterface_UpdateAuthProvider_Call {
|
||||
func (_c *MockInterface_UpdateAuthProvider_Call) RunAndReturn(run func(p kubeconfig.AuthProvider) error) *MockInterface_UpdateAuthProvider_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
// Code generated by mockery v2.51.0. DO NOT EDIT.
|
||||
|
||||
package client_mock
|
||||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
client "github.com/int128/kubelogin/pkg/oidc/client"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
|
||||
oidc "github.com/int128/kubelogin/pkg/oidc"
|
||||
|
||||
tlsclientconfig "github.com/int128/kubelogin/pkg/tlsclientconfig"
|
||||
)
|
||||
|
||||
// MockFactoryInterface is an autogenerated mock type for the FactoryInterface type
|
||||
type MockFactoryInterface struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type MockFactoryInterface_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *MockFactoryInterface) EXPECT() *MockFactoryInterface_Expecter {
|
||||
return &MockFactoryInterface_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// New provides a mock function with given fields: ctx, prov, tlsClientConfig
|
||||
func (_m *MockFactoryInterface) New(ctx context.Context, prov oidc.Provider, tlsClientConfig tlsclientconfig.Config) (client.Interface, error) {
|
||||
ret := _m.Called(ctx, prov, tlsClientConfig)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for New")
|
||||
}
|
||||
|
||||
var r0 client.Interface
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, oidc.Provider, tlsclientconfig.Config) (client.Interface, error)); ok {
|
||||
return rf(ctx, prov, tlsClientConfig)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, oidc.Provider, tlsclientconfig.Config) client.Interface); ok {
|
||||
r0 = rf(ctx, prov, tlsClientConfig)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(client.Interface)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, oidc.Provider, tlsclientconfig.Config) error); ok {
|
||||
r1 = rf(ctx, prov, tlsClientConfig)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockFactoryInterface_New_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'New'
|
||||
type MockFactoryInterface_New_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// New is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - prov oidc.Provider
|
||||
// - tlsClientConfig tlsclientconfig.Config
|
||||
func (_e *MockFactoryInterface_Expecter) New(ctx interface{}, prov interface{}, tlsClientConfig interface{}) *MockFactoryInterface_New_Call {
|
||||
return &MockFactoryInterface_New_Call{Call: _e.mock.On("New", ctx, prov, tlsClientConfig)}
|
||||
}
|
||||
|
||||
func (_c *MockFactoryInterface_New_Call) Run(run func(ctx context.Context, prov oidc.Provider, tlsClientConfig tlsclientconfig.Config)) *MockFactoryInterface_New_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context), args[1].(oidc.Provider), args[2].(tlsclientconfig.Config))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockFactoryInterface_New_Call) Return(_a0 client.Interface, _a1 error) *MockFactoryInterface_New_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockFactoryInterface_New_Call) RunAndReturn(run func(context.Context, oidc.Provider, tlsclientconfig.Config) (client.Interface, error)) *MockFactoryInterface_New_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockFactoryInterface creates a new instance of MockFactoryInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockFactoryInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockFactoryInterface {
|
||||
mock := &MockFactoryInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -1,490 +0,0 @@
|
||||
// Code generated by mockery v2.51.0. DO NOT EDIT.
|
||||
|
||||
package client_mock
|
||||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
client "github.com/int128/kubelogin/pkg/oidc/client"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
|
||||
oauth2dev "github.com/int128/oauth2dev"
|
||||
|
||||
oidc "github.com/int128/kubelogin/pkg/oidc"
|
||||
|
||||
pkce "github.com/int128/kubelogin/pkg/pkce"
|
||||
)
|
||||
|
||||
// MockInterface is an autogenerated mock type for the Interface type
|
||||
type MockInterface struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type MockInterface_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *MockInterface) EXPECT() *MockInterface_Expecter {
|
||||
return &MockInterface_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// ExchangeAuthCode provides a mock function with given fields: ctx, in
|
||||
func (_m *MockInterface) ExchangeAuthCode(ctx context.Context, in client.ExchangeAuthCodeInput) (*oidc.TokenSet, error) {
|
||||
ret := _m.Called(ctx, in)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ExchangeAuthCode")
|
||||
}
|
||||
|
||||
var r0 *oidc.TokenSet
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, client.ExchangeAuthCodeInput) (*oidc.TokenSet, error)); ok {
|
||||
return rf(ctx, in)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, client.ExchangeAuthCodeInput) *oidc.TokenSet); ok {
|
||||
r0 = rf(ctx, in)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*oidc.TokenSet)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, client.ExchangeAuthCodeInput) error); ok {
|
||||
r1 = rf(ctx, in)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockInterface_ExchangeAuthCode_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ExchangeAuthCode'
|
||||
type MockInterface_ExchangeAuthCode_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// ExchangeAuthCode is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - in client.ExchangeAuthCodeInput
|
||||
func (_e *MockInterface_Expecter) ExchangeAuthCode(ctx interface{}, in interface{}) *MockInterface_ExchangeAuthCode_Call {
|
||||
return &MockInterface_ExchangeAuthCode_Call{Call: _e.mock.On("ExchangeAuthCode", ctx, in)}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_ExchangeAuthCode_Call) Run(run func(ctx context.Context, in client.ExchangeAuthCodeInput)) *MockInterface_ExchangeAuthCode_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context), args[1].(client.ExchangeAuthCodeInput))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_ExchangeAuthCode_Call) Return(_a0 *oidc.TokenSet, _a1 error) *MockInterface_ExchangeAuthCode_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_ExchangeAuthCode_Call) RunAndReturn(run func(context.Context, client.ExchangeAuthCodeInput) (*oidc.TokenSet, error)) *MockInterface_ExchangeAuthCode_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// ExchangeDeviceCode provides a mock function with given fields: ctx, authResponse
|
||||
func (_m *MockInterface) ExchangeDeviceCode(ctx context.Context, authResponse *oauth2dev.AuthorizationResponse) (*oidc.TokenSet, error) {
|
||||
ret := _m.Called(ctx, authResponse)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ExchangeDeviceCode")
|
||||
}
|
||||
|
||||
var r0 *oidc.TokenSet
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *oauth2dev.AuthorizationResponse) (*oidc.TokenSet, error)); ok {
|
||||
return rf(ctx, authResponse)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *oauth2dev.AuthorizationResponse) *oidc.TokenSet); ok {
|
||||
r0 = rf(ctx, authResponse)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*oidc.TokenSet)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, *oauth2dev.AuthorizationResponse) error); ok {
|
||||
r1 = rf(ctx, authResponse)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockInterface_ExchangeDeviceCode_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ExchangeDeviceCode'
|
||||
type MockInterface_ExchangeDeviceCode_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// ExchangeDeviceCode is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - authResponse *oauth2dev.AuthorizationResponse
|
||||
func (_e *MockInterface_Expecter) ExchangeDeviceCode(ctx interface{}, authResponse interface{}) *MockInterface_ExchangeDeviceCode_Call {
|
||||
return &MockInterface_ExchangeDeviceCode_Call{Call: _e.mock.On("ExchangeDeviceCode", ctx, authResponse)}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_ExchangeDeviceCode_Call) Run(run func(ctx context.Context, authResponse *oauth2dev.AuthorizationResponse)) *MockInterface_ExchangeDeviceCode_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context), args[1].(*oauth2dev.AuthorizationResponse))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_ExchangeDeviceCode_Call) Return(_a0 *oidc.TokenSet, _a1 error) *MockInterface_ExchangeDeviceCode_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_ExchangeDeviceCode_Call) RunAndReturn(run func(context.Context, *oauth2dev.AuthorizationResponse) (*oidc.TokenSet, error)) *MockInterface_ExchangeDeviceCode_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// GetAuthCodeURL provides a mock function with given fields: in
|
||||
func (_m *MockInterface) GetAuthCodeURL(in client.AuthCodeURLInput) string {
|
||||
ret := _m.Called(in)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetAuthCodeURL")
|
||||
}
|
||||
|
||||
var r0 string
|
||||
if rf, ok := ret.Get(0).(func(client.AuthCodeURLInput) string); ok {
|
||||
r0 = rf(in)
|
||||
} else {
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockInterface_GetAuthCodeURL_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetAuthCodeURL'
|
||||
type MockInterface_GetAuthCodeURL_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// GetAuthCodeURL is a helper method to define mock.On call
|
||||
// - in client.AuthCodeURLInput
|
||||
func (_e *MockInterface_Expecter) GetAuthCodeURL(in interface{}) *MockInterface_GetAuthCodeURL_Call {
|
||||
return &MockInterface_GetAuthCodeURL_Call{Call: _e.mock.On("GetAuthCodeURL", in)}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetAuthCodeURL_Call) Run(run func(in client.AuthCodeURLInput)) *MockInterface_GetAuthCodeURL_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(client.AuthCodeURLInput))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetAuthCodeURL_Call) Return(_a0 string) *MockInterface_GetAuthCodeURL_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetAuthCodeURL_Call) RunAndReturn(run func(client.AuthCodeURLInput) string) *MockInterface_GetAuthCodeURL_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// GetDeviceAuthorization provides a mock function with given fields: ctx
|
||||
func (_m *MockInterface) GetDeviceAuthorization(ctx context.Context) (*oauth2dev.AuthorizationResponse, error) {
|
||||
ret := _m.Called(ctx)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetDeviceAuthorization")
|
||||
}
|
||||
|
||||
var r0 *oauth2dev.AuthorizationResponse
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context) (*oauth2dev.AuthorizationResponse, error)); ok {
|
||||
return rf(ctx)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context) *oauth2dev.AuthorizationResponse); ok {
|
||||
r0 = rf(ctx)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*oauth2dev.AuthorizationResponse)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context) error); ok {
|
||||
r1 = rf(ctx)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockInterface_GetDeviceAuthorization_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDeviceAuthorization'
|
||||
type MockInterface_GetDeviceAuthorization_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// GetDeviceAuthorization is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
func (_e *MockInterface_Expecter) GetDeviceAuthorization(ctx interface{}) *MockInterface_GetDeviceAuthorization_Call {
|
||||
return &MockInterface_GetDeviceAuthorization_Call{Call: _e.mock.On("GetDeviceAuthorization", ctx)}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetDeviceAuthorization_Call) Run(run func(ctx context.Context)) *MockInterface_GetDeviceAuthorization_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetDeviceAuthorization_Call) Return(_a0 *oauth2dev.AuthorizationResponse, _a1 error) *MockInterface_GetDeviceAuthorization_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetDeviceAuthorization_Call) RunAndReturn(run func(context.Context) (*oauth2dev.AuthorizationResponse, error)) *MockInterface_GetDeviceAuthorization_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// GetTokenByAuthCode provides a mock function with given fields: ctx, in, localServerReadyChan
|
||||
func (_m *MockInterface) GetTokenByAuthCode(ctx context.Context, in client.GetTokenByAuthCodeInput, localServerReadyChan chan<- string) (*oidc.TokenSet, error) {
|
||||
ret := _m.Called(ctx, in, localServerReadyChan)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetTokenByAuthCode")
|
||||
}
|
||||
|
||||
var r0 *oidc.TokenSet
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, client.GetTokenByAuthCodeInput, chan<- string) (*oidc.TokenSet, error)); ok {
|
||||
return rf(ctx, in, localServerReadyChan)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, client.GetTokenByAuthCodeInput, chan<- string) *oidc.TokenSet); ok {
|
||||
r0 = rf(ctx, in, localServerReadyChan)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*oidc.TokenSet)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, client.GetTokenByAuthCodeInput, chan<- string) error); ok {
|
||||
r1 = rf(ctx, in, localServerReadyChan)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockInterface_GetTokenByAuthCode_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTokenByAuthCode'
|
||||
type MockInterface_GetTokenByAuthCode_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// GetTokenByAuthCode is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - in client.GetTokenByAuthCodeInput
|
||||
// - localServerReadyChan chan<- string
|
||||
func (_e *MockInterface_Expecter) GetTokenByAuthCode(ctx interface{}, in interface{}, localServerReadyChan interface{}) *MockInterface_GetTokenByAuthCode_Call {
|
||||
return &MockInterface_GetTokenByAuthCode_Call{Call: _e.mock.On("GetTokenByAuthCode", ctx, in, localServerReadyChan)}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetTokenByAuthCode_Call) Run(run func(ctx context.Context, in client.GetTokenByAuthCodeInput, localServerReadyChan chan<- string)) *MockInterface_GetTokenByAuthCode_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context), args[1].(client.GetTokenByAuthCodeInput), args[2].(chan<- string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetTokenByAuthCode_Call) Return(_a0 *oidc.TokenSet, _a1 error) *MockInterface_GetTokenByAuthCode_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetTokenByAuthCode_Call) RunAndReturn(run func(context.Context, client.GetTokenByAuthCodeInput, chan<- string) (*oidc.TokenSet, error)) *MockInterface_GetTokenByAuthCode_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// GetTokenByROPC provides a mock function with given fields: ctx, username, password
|
||||
func (_m *MockInterface) GetTokenByROPC(ctx context.Context, username string, password string) (*oidc.TokenSet, error) {
|
||||
ret := _m.Called(ctx, username, password)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetTokenByROPC")
|
||||
}
|
||||
|
||||
var r0 *oidc.TokenSet
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, string) (*oidc.TokenSet, error)); ok {
|
||||
return rf(ctx, username, password)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, string) *oidc.TokenSet); ok {
|
||||
r0 = rf(ctx, username, password)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*oidc.TokenSet)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok {
|
||||
r1 = rf(ctx, username, password)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockInterface_GetTokenByROPC_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTokenByROPC'
|
||||
type MockInterface_GetTokenByROPC_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// GetTokenByROPC is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - username string
|
||||
// - password string
|
||||
func (_e *MockInterface_Expecter) GetTokenByROPC(ctx interface{}, username interface{}, password interface{}) *MockInterface_GetTokenByROPC_Call {
|
||||
return &MockInterface_GetTokenByROPC_Call{Call: _e.mock.On("GetTokenByROPC", ctx, username, password)}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetTokenByROPC_Call) Run(run func(ctx context.Context, username string, password string)) *MockInterface_GetTokenByROPC_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context), args[1].(string), args[2].(string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetTokenByROPC_Call) Return(_a0 *oidc.TokenSet, _a1 error) *MockInterface_GetTokenByROPC_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetTokenByROPC_Call) RunAndReturn(run func(context.Context, string, string) (*oidc.TokenSet, error)) *MockInterface_GetTokenByROPC_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NegotiatedPKCEMethod provides a mock function with no fields
|
||||
func (_m *MockInterface) NegotiatedPKCEMethod() pkce.Method {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for NegotiatedPKCEMethod")
|
||||
}
|
||||
|
||||
var r0 pkce.Method
|
||||
if rf, ok := ret.Get(0).(func() pkce.Method); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
r0 = ret.Get(0).(pkce.Method)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockInterface_NegotiatedPKCEMethod_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NegotiatedPKCEMethod'
|
||||
type MockInterface_NegotiatedPKCEMethod_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// NegotiatedPKCEMethod is a helper method to define mock.On call
|
||||
func (_e *MockInterface_Expecter) NegotiatedPKCEMethod() *MockInterface_NegotiatedPKCEMethod_Call {
|
||||
return &MockInterface_NegotiatedPKCEMethod_Call{Call: _e.mock.On("NegotiatedPKCEMethod")}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_NegotiatedPKCEMethod_Call) Run(run func()) *MockInterface_NegotiatedPKCEMethod_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run()
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_NegotiatedPKCEMethod_Call) Return(_a0 pkce.Method) *MockInterface_NegotiatedPKCEMethod_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_NegotiatedPKCEMethod_Call) RunAndReturn(run func() pkce.Method) *MockInterface_NegotiatedPKCEMethod_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Refresh provides a mock function with given fields: ctx, refreshToken
|
||||
func (_m *MockInterface) Refresh(ctx context.Context, refreshToken string) (*oidc.TokenSet, error) {
|
||||
ret := _m.Called(ctx, refreshToken)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Refresh")
|
||||
}
|
||||
|
||||
var r0 *oidc.TokenSet
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string) (*oidc.TokenSet, error)); ok {
|
||||
return rf(ctx, refreshToken)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string) *oidc.TokenSet); ok {
|
||||
r0 = rf(ctx, refreshToken)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*oidc.TokenSet)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
|
||||
r1 = rf(ctx, refreshToken)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockInterface_Refresh_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Refresh'
|
||||
type MockInterface_Refresh_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Refresh is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - refreshToken string
|
||||
func (_e *MockInterface_Expecter) Refresh(ctx interface{}, refreshToken interface{}) *MockInterface_Refresh_Call {
|
||||
return &MockInterface_Refresh_Call{Call: _e.mock.On("Refresh", ctx, refreshToken)}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Refresh_Call) Run(run func(ctx context.Context, refreshToken string)) *MockInterface_Refresh_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context), args[1].(string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Refresh_Call) Return(_a0 *oidc.TokenSet, _a1 error) *MockInterface_Refresh_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Refresh_Call) RunAndReturn(run func(context.Context, string) (*oidc.TokenSet, error)) *MockInterface_Refresh_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
721
mocks/github.com/int128/kubelogin/pkg/oidc/client_mock/mocks.go
Normal file
721
mocks/github.com/int128/kubelogin/pkg/oidc/client_mock/mocks.go
Normal file
@@ -0,0 +1,721 @@
|
||||
// Code generated by mockery; DO NOT EDIT.
|
||||
// github.com/vektra/mockery
|
||||
// template: testify
|
||||
|
||||
package client_mock
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/int128/kubelogin/pkg/oidc"
|
||||
"github.com/int128/kubelogin/pkg/oidc/client"
|
||||
"github.com/int128/kubelogin/pkg/pkce"
|
||||
"github.com/int128/kubelogin/pkg/tlsclientconfig"
|
||||
"github.com/int128/oauth2dev"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockInterface is an autogenerated mock type for the Interface type
|
||||
type MockInterface struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type MockInterface_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *MockInterface) EXPECT() *MockInterface_Expecter {
|
||||
return &MockInterface_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// ExchangeAuthCode provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) ExchangeAuthCode(ctx context.Context, in client.ExchangeAuthCodeInput) (*oidc.TokenSet, error) {
|
||||
ret := _mock.Called(ctx, in)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ExchangeAuthCode")
|
||||
}
|
||||
|
||||
var r0 *oidc.TokenSet
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, client.ExchangeAuthCodeInput) (*oidc.TokenSet, error)); ok {
|
||||
return returnFunc(ctx, in)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, client.ExchangeAuthCodeInput) *oidc.TokenSet); ok {
|
||||
r0 = returnFunc(ctx, in)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*oidc.TokenSet)
|
||||
}
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(context.Context, client.ExchangeAuthCodeInput) error); ok {
|
||||
r1 = returnFunc(ctx, in)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockInterface_ExchangeAuthCode_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ExchangeAuthCode'
|
||||
type MockInterface_ExchangeAuthCode_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// ExchangeAuthCode is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - in client.ExchangeAuthCodeInput
|
||||
func (_e *MockInterface_Expecter) ExchangeAuthCode(ctx interface{}, in interface{}) *MockInterface_ExchangeAuthCode_Call {
|
||||
return &MockInterface_ExchangeAuthCode_Call{Call: _e.mock.On("ExchangeAuthCode", ctx, in)}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_ExchangeAuthCode_Call) Run(run func(ctx context.Context, in client.ExchangeAuthCodeInput)) *MockInterface_ExchangeAuthCode_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 client.ExchangeAuthCodeInput
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(client.ExchangeAuthCodeInput)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_ExchangeAuthCode_Call) Return(tokenSet *oidc.TokenSet, err error) *MockInterface_ExchangeAuthCode_Call {
|
||||
_c.Call.Return(tokenSet, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_ExchangeAuthCode_Call) RunAndReturn(run func(ctx context.Context, in client.ExchangeAuthCodeInput) (*oidc.TokenSet, error)) *MockInterface_ExchangeAuthCode_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// ExchangeDeviceCode provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) ExchangeDeviceCode(ctx context.Context, authResponse *oauth2dev.AuthorizationResponse) (*oidc.TokenSet, error) {
|
||||
ret := _mock.Called(ctx, authResponse)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ExchangeDeviceCode")
|
||||
}
|
||||
|
||||
var r0 *oidc.TokenSet
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, *oauth2dev.AuthorizationResponse) (*oidc.TokenSet, error)); ok {
|
||||
return returnFunc(ctx, authResponse)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, *oauth2dev.AuthorizationResponse) *oidc.TokenSet); ok {
|
||||
r0 = returnFunc(ctx, authResponse)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*oidc.TokenSet)
|
||||
}
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(context.Context, *oauth2dev.AuthorizationResponse) error); ok {
|
||||
r1 = returnFunc(ctx, authResponse)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockInterface_ExchangeDeviceCode_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ExchangeDeviceCode'
|
||||
type MockInterface_ExchangeDeviceCode_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// ExchangeDeviceCode is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - authResponse *oauth2dev.AuthorizationResponse
|
||||
func (_e *MockInterface_Expecter) ExchangeDeviceCode(ctx interface{}, authResponse interface{}) *MockInterface_ExchangeDeviceCode_Call {
|
||||
return &MockInterface_ExchangeDeviceCode_Call{Call: _e.mock.On("ExchangeDeviceCode", ctx, authResponse)}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_ExchangeDeviceCode_Call) Run(run func(ctx context.Context, authResponse *oauth2dev.AuthorizationResponse)) *MockInterface_ExchangeDeviceCode_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 *oauth2dev.AuthorizationResponse
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(*oauth2dev.AuthorizationResponse)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_ExchangeDeviceCode_Call) Return(tokenSet *oidc.TokenSet, err error) *MockInterface_ExchangeDeviceCode_Call {
|
||||
_c.Call.Return(tokenSet, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_ExchangeDeviceCode_Call) RunAndReturn(run func(ctx context.Context, authResponse *oauth2dev.AuthorizationResponse) (*oidc.TokenSet, error)) *MockInterface_ExchangeDeviceCode_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// GetAuthCodeURL provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) GetAuthCodeURL(in client.AuthCodeURLInput) string {
|
||||
ret := _mock.Called(in)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetAuthCodeURL")
|
||||
}
|
||||
|
||||
var r0 string
|
||||
if returnFunc, ok := ret.Get(0).(func(client.AuthCodeURLInput) string); ok {
|
||||
r0 = returnFunc(in)
|
||||
} else {
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockInterface_GetAuthCodeURL_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetAuthCodeURL'
|
||||
type MockInterface_GetAuthCodeURL_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// GetAuthCodeURL is a helper method to define mock.On call
|
||||
// - in client.AuthCodeURLInput
|
||||
func (_e *MockInterface_Expecter) GetAuthCodeURL(in interface{}) *MockInterface_GetAuthCodeURL_Call {
|
||||
return &MockInterface_GetAuthCodeURL_Call{Call: _e.mock.On("GetAuthCodeURL", in)}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetAuthCodeURL_Call) Run(run func(in client.AuthCodeURLInput)) *MockInterface_GetAuthCodeURL_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 client.AuthCodeURLInput
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(client.AuthCodeURLInput)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetAuthCodeURL_Call) Return(s string) *MockInterface_GetAuthCodeURL_Call {
|
||||
_c.Call.Return(s)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetAuthCodeURL_Call) RunAndReturn(run func(in client.AuthCodeURLInput) string) *MockInterface_GetAuthCodeURL_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// GetDeviceAuthorization provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) GetDeviceAuthorization(ctx context.Context) (*oauth2dev.AuthorizationResponse, error) {
|
||||
ret := _mock.Called(ctx)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetDeviceAuthorization")
|
||||
}
|
||||
|
||||
var r0 *oauth2dev.AuthorizationResponse
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context) (*oauth2dev.AuthorizationResponse, error)); ok {
|
||||
return returnFunc(ctx)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context) *oauth2dev.AuthorizationResponse); ok {
|
||||
r0 = returnFunc(ctx)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*oauth2dev.AuthorizationResponse)
|
||||
}
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(context.Context) error); ok {
|
||||
r1 = returnFunc(ctx)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockInterface_GetDeviceAuthorization_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDeviceAuthorization'
|
||||
type MockInterface_GetDeviceAuthorization_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// GetDeviceAuthorization is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
func (_e *MockInterface_Expecter) GetDeviceAuthorization(ctx interface{}) *MockInterface_GetDeviceAuthorization_Call {
|
||||
return &MockInterface_GetDeviceAuthorization_Call{Call: _e.mock.On("GetDeviceAuthorization", ctx)}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetDeviceAuthorization_Call) Run(run func(ctx context.Context)) *MockInterface_GetDeviceAuthorization_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetDeviceAuthorization_Call) Return(authorizationResponse *oauth2dev.AuthorizationResponse, err error) *MockInterface_GetDeviceAuthorization_Call {
|
||||
_c.Call.Return(authorizationResponse, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetDeviceAuthorization_Call) RunAndReturn(run func(ctx context.Context) (*oauth2dev.AuthorizationResponse, error)) *MockInterface_GetDeviceAuthorization_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// GetTokenByAuthCode provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) GetTokenByAuthCode(ctx context.Context, in client.GetTokenByAuthCodeInput, localServerReadyChan chan<- string) (*oidc.TokenSet, error) {
|
||||
ret := _mock.Called(ctx, in, localServerReadyChan)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetTokenByAuthCode")
|
||||
}
|
||||
|
||||
var r0 *oidc.TokenSet
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, client.GetTokenByAuthCodeInput, chan<- string) (*oidc.TokenSet, error)); ok {
|
||||
return returnFunc(ctx, in, localServerReadyChan)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, client.GetTokenByAuthCodeInput, chan<- string) *oidc.TokenSet); ok {
|
||||
r0 = returnFunc(ctx, in, localServerReadyChan)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*oidc.TokenSet)
|
||||
}
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(context.Context, client.GetTokenByAuthCodeInput, chan<- string) error); ok {
|
||||
r1 = returnFunc(ctx, in, localServerReadyChan)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockInterface_GetTokenByAuthCode_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTokenByAuthCode'
|
||||
type MockInterface_GetTokenByAuthCode_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// GetTokenByAuthCode is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - in client.GetTokenByAuthCodeInput
|
||||
// - localServerReadyChan chan<- string
|
||||
func (_e *MockInterface_Expecter) GetTokenByAuthCode(ctx interface{}, in interface{}, localServerReadyChan interface{}) *MockInterface_GetTokenByAuthCode_Call {
|
||||
return &MockInterface_GetTokenByAuthCode_Call{Call: _e.mock.On("GetTokenByAuthCode", ctx, in, localServerReadyChan)}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetTokenByAuthCode_Call) Run(run func(ctx context.Context, in client.GetTokenByAuthCodeInput, localServerReadyChan chan<- string)) *MockInterface_GetTokenByAuthCode_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 client.GetTokenByAuthCodeInput
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(client.GetTokenByAuthCodeInput)
|
||||
}
|
||||
var arg2 chan<- string
|
||||
if args[2] != nil {
|
||||
arg2 = args[2].(chan<- string)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
arg2,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetTokenByAuthCode_Call) Return(tokenSet *oidc.TokenSet, err error) *MockInterface_GetTokenByAuthCode_Call {
|
||||
_c.Call.Return(tokenSet, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetTokenByAuthCode_Call) RunAndReturn(run func(ctx context.Context, in client.GetTokenByAuthCodeInput, localServerReadyChan chan<- string) (*oidc.TokenSet, error)) *MockInterface_GetTokenByAuthCode_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// GetTokenByClientCredentials provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) GetTokenByClientCredentials(ctx context.Context, in client.GetTokenByClientCredentialsInput) (*oidc.TokenSet, error) {
|
||||
ret := _mock.Called(ctx, in)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetTokenByClientCredentials")
|
||||
}
|
||||
|
||||
var r0 *oidc.TokenSet
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, client.GetTokenByClientCredentialsInput) (*oidc.TokenSet, error)); ok {
|
||||
return returnFunc(ctx, in)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, client.GetTokenByClientCredentialsInput) *oidc.TokenSet); ok {
|
||||
r0 = returnFunc(ctx, in)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*oidc.TokenSet)
|
||||
}
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(context.Context, client.GetTokenByClientCredentialsInput) error); ok {
|
||||
r1 = returnFunc(ctx, in)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockInterface_GetTokenByClientCredentials_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTokenByClientCredentials'
|
||||
type MockInterface_GetTokenByClientCredentials_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// GetTokenByClientCredentials is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - in client.GetTokenByClientCredentialsInput
|
||||
func (_e *MockInterface_Expecter) GetTokenByClientCredentials(ctx interface{}, in interface{}) *MockInterface_GetTokenByClientCredentials_Call {
|
||||
return &MockInterface_GetTokenByClientCredentials_Call{Call: _e.mock.On("GetTokenByClientCredentials", ctx, in)}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetTokenByClientCredentials_Call) Run(run func(ctx context.Context, in client.GetTokenByClientCredentialsInput)) *MockInterface_GetTokenByClientCredentials_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 client.GetTokenByClientCredentialsInput
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(client.GetTokenByClientCredentialsInput)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetTokenByClientCredentials_Call) Return(tokenSet *oidc.TokenSet, err error) *MockInterface_GetTokenByClientCredentials_Call {
|
||||
_c.Call.Return(tokenSet, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetTokenByClientCredentials_Call) RunAndReturn(run func(ctx context.Context, in client.GetTokenByClientCredentialsInput) (*oidc.TokenSet, error)) *MockInterface_GetTokenByClientCredentials_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// GetTokenByROPC provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) GetTokenByROPC(ctx context.Context, username string, password string) (*oidc.TokenSet, error) {
|
||||
ret := _mock.Called(ctx, username, password)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetTokenByROPC")
|
||||
}
|
||||
|
||||
var r0 *oidc.TokenSet
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, string, string) (*oidc.TokenSet, error)); ok {
|
||||
return returnFunc(ctx, username, password)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, string, string) *oidc.TokenSet); ok {
|
||||
r0 = returnFunc(ctx, username, password)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*oidc.TokenSet)
|
||||
}
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(context.Context, string, string) error); ok {
|
||||
r1 = returnFunc(ctx, username, password)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockInterface_GetTokenByROPC_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTokenByROPC'
|
||||
type MockInterface_GetTokenByROPC_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// GetTokenByROPC is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - username string
|
||||
// - password string
|
||||
func (_e *MockInterface_Expecter) GetTokenByROPC(ctx interface{}, username interface{}, password interface{}) *MockInterface_GetTokenByROPC_Call {
|
||||
return &MockInterface_GetTokenByROPC_Call{Call: _e.mock.On("GetTokenByROPC", ctx, username, password)}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetTokenByROPC_Call) Run(run func(ctx context.Context, username string, password string)) *MockInterface_GetTokenByROPC_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 string
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(string)
|
||||
}
|
||||
var arg2 string
|
||||
if args[2] != nil {
|
||||
arg2 = args[2].(string)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
arg2,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetTokenByROPC_Call) Return(tokenSet *oidc.TokenSet, err error) *MockInterface_GetTokenByROPC_Call {
|
||||
_c.Call.Return(tokenSet, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_GetTokenByROPC_Call) RunAndReturn(run func(ctx context.Context, username string, password string) (*oidc.TokenSet, error)) *MockInterface_GetTokenByROPC_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NegotiatedPKCEMethod provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) NegotiatedPKCEMethod() pkce.Method {
|
||||
ret := _mock.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for NegotiatedPKCEMethod")
|
||||
}
|
||||
|
||||
var r0 pkce.Method
|
||||
if returnFunc, ok := ret.Get(0).(func() pkce.Method); ok {
|
||||
r0 = returnFunc()
|
||||
} else {
|
||||
r0 = ret.Get(0).(pkce.Method)
|
||||
}
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockInterface_NegotiatedPKCEMethod_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NegotiatedPKCEMethod'
|
||||
type MockInterface_NegotiatedPKCEMethod_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// NegotiatedPKCEMethod is a helper method to define mock.On call
|
||||
func (_e *MockInterface_Expecter) NegotiatedPKCEMethod() *MockInterface_NegotiatedPKCEMethod_Call {
|
||||
return &MockInterface_NegotiatedPKCEMethod_Call{Call: _e.mock.On("NegotiatedPKCEMethod")}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_NegotiatedPKCEMethod_Call) Run(run func()) *MockInterface_NegotiatedPKCEMethod_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run()
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_NegotiatedPKCEMethod_Call) Return(method pkce.Method) *MockInterface_NegotiatedPKCEMethod_Call {
|
||||
_c.Call.Return(method)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_NegotiatedPKCEMethod_Call) RunAndReturn(run func() pkce.Method) *MockInterface_NegotiatedPKCEMethod_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Refresh provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) Refresh(ctx context.Context, refreshToken string) (*oidc.TokenSet, error) {
|
||||
ret := _mock.Called(ctx, refreshToken)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Refresh")
|
||||
}
|
||||
|
||||
var r0 *oidc.TokenSet
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, string) (*oidc.TokenSet, error)); ok {
|
||||
return returnFunc(ctx, refreshToken)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, string) *oidc.TokenSet); ok {
|
||||
r0 = returnFunc(ctx, refreshToken)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*oidc.TokenSet)
|
||||
}
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(context.Context, string) error); ok {
|
||||
r1 = returnFunc(ctx, refreshToken)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockInterface_Refresh_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Refresh'
|
||||
type MockInterface_Refresh_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Refresh is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - refreshToken string
|
||||
func (_e *MockInterface_Expecter) Refresh(ctx interface{}, refreshToken interface{}) *MockInterface_Refresh_Call {
|
||||
return &MockInterface_Refresh_Call{Call: _e.mock.On("Refresh", ctx, refreshToken)}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Refresh_Call) Run(run func(ctx context.Context, refreshToken string)) *MockInterface_Refresh_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 string
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(string)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Refresh_Call) Return(tokenSet *oidc.TokenSet, err error) *MockInterface_Refresh_Call {
|
||||
_c.Call.Return(tokenSet, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Refresh_Call) RunAndReturn(run func(ctx context.Context, refreshToken string) (*oidc.TokenSet, error)) *MockInterface_Refresh_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockFactoryInterface creates a new instance of MockFactoryInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockFactoryInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockFactoryInterface {
|
||||
mock := &MockFactoryInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockFactoryInterface is an autogenerated mock type for the FactoryInterface type
|
||||
type MockFactoryInterface struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type MockFactoryInterface_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *MockFactoryInterface) EXPECT() *MockFactoryInterface_Expecter {
|
||||
return &MockFactoryInterface_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// New provides a mock function for the type MockFactoryInterface
|
||||
func (_mock *MockFactoryInterface) New(ctx context.Context, prov oidc.Provider, tlsClientConfig tlsclientconfig.Config) (client.Interface, error) {
|
||||
ret := _mock.Called(ctx, prov, tlsClientConfig)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for New")
|
||||
}
|
||||
|
||||
var r0 client.Interface
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, oidc.Provider, tlsclientconfig.Config) (client.Interface, error)); ok {
|
||||
return returnFunc(ctx, prov, tlsClientConfig)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, oidc.Provider, tlsclientconfig.Config) client.Interface); ok {
|
||||
r0 = returnFunc(ctx, prov, tlsClientConfig)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(client.Interface)
|
||||
}
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(context.Context, oidc.Provider, tlsclientconfig.Config) error); ok {
|
||||
r1 = returnFunc(ctx, prov, tlsClientConfig)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockFactoryInterface_New_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'New'
|
||||
type MockFactoryInterface_New_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// New is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - prov oidc.Provider
|
||||
// - tlsClientConfig tlsclientconfig.Config
|
||||
func (_e *MockFactoryInterface_Expecter) New(ctx interface{}, prov interface{}, tlsClientConfig interface{}) *MockFactoryInterface_New_Call {
|
||||
return &MockFactoryInterface_New_Call{Call: _e.mock.On("New", ctx, prov, tlsClientConfig)}
|
||||
}
|
||||
|
||||
func (_c *MockFactoryInterface_New_Call) Run(run func(ctx context.Context, prov oidc.Provider, tlsClientConfig tlsclientconfig.Config)) *MockFactoryInterface_New_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 oidc.Provider
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(oidc.Provider)
|
||||
}
|
||||
var arg2 tlsclientconfig.Config
|
||||
if args[2] != nil {
|
||||
arg2 = args[2].(tlsclientconfig.Config)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
arg2,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockFactoryInterface_New_Call) Return(interfaceParam client.Interface, err error) *MockFactoryInterface_New_Call {
|
||||
_c.Call.Return(interfaceParam, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockFactoryInterface_New_Call) RunAndReturn(run func(ctx context.Context, prov oidc.Provider, tlsClientConfig tlsclientconfig.Config) (client.Interface, error)) *MockFactoryInterface_New_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
// Code generated by mockery v2.51.0. DO NOT EDIT.
|
||||
|
||||
package logger_mock
|
||||
|
||||
import mock "github.com/stretchr/testify/mock"
|
||||
|
||||
// MocktestingLogger is an autogenerated mock type for the testingLogger type
|
||||
type MocktestingLogger struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type MocktestingLogger_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *MocktestingLogger) EXPECT() *MocktestingLogger_Expecter {
|
||||
return &MocktestingLogger_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Logf provides a mock function with given fields: format, v
|
||||
func (_m *MocktestingLogger) Logf(format string, v ...interface{}) {
|
||||
var _ca []interface{}
|
||||
_ca = append(_ca, format)
|
||||
_ca = append(_ca, v...)
|
||||
_m.Called(_ca...)
|
||||
}
|
||||
|
||||
// MocktestingLogger_Logf_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Logf'
|
||||
type MocktestingLogger_Logf_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Logf is a helper method to define mock.On call
|
||||
// - format string
|
||||
// - v ...interface{}
|
||||
func (_e *MocktestingLogger_Expecter) Logf(format interface{}, v ...interface{}) *MocktestingLogger_Logf_Call {
|
||||
return &MocktestingLogger_Logf_Call{Call: _e.mock.On("Logf",
|
||||
append([]interface{}{format}, v...)...)}
|
||||
}
|
||||
|
||||
func (_c *MocktestingLogger_Logf_Call) Run(run func(format string, v ...interface{})) *MocktestingLogger_Logf_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
variadicArgs := make([]interface{}, len(args)-1)
|
||||
for i, a := range args[1:] {
|
||||
if a != nil {
|
||||
variadicArgs[i] = a.(interface{})
|
||||
}
|
||||
}
|
||||
run(args[0].(string), variadicArgs...)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MocktestingLogger_Logf_Call) Return() *MocktestingLogger_Logf_Call {
|
||||
_c.Call.Return()
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MocktestingLogger_Logf_Call) RunAndReturn(run func(string, ...interface{})) *MocktestingLogger_Logf_Call {
|
||||
_c.Run(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMocktestingLogger creates a new instance of MocktestingLogger. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMocktestingLogger(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MocktestingLogger {
|
||||
mock := &MocktestingLogger{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
// Code generated by mockery; DO NOT EDIT.
|
||||
// github.com/vektra/mockery
|
||||
// template: testify
|
||||
|
||||
package logger_mock
|
||||
|
||||
import (
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// newMocktestingLogger creates a new instance of mocktestingLogger. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func newMocktestingLogger(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *mocktestingLogger {
|
||||
mock := &mocktestingLogger{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// mocktestingLogger is an autogenerated mock type for the testingLogger type
|
||||
type mocktestingLogger struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type mocktestingLogger_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *mocktestingLogger) EXPECT() *mocktestingLogger_Expecter {
|
||||
return &mocktestingLogger_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Logf provides a mock function for the type mocktestingLogger
|
||||
func (_mock *mocktestingLogger) Logf(format string, v ...interface{}) {
|
||||
if len(v) > 0 {
|
||||
_mock.Called(format, v)
|
||||
} else {
|
||||
_mock.Called(format)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// mocktestingLogger_Logf_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Logf'
|
||||
type mocktestingLogger_Logf_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Logf is a helper method to define mock.On call
|
||||
// - format string
|
||||
// - v ...interface{}
|
||||
func (_e *mocktestingLogger_Expecter) Logf(format interface{}, v ...interface{}) *mocktestingLogger_Logf_Call {
|
||||
return &mocktestingLogger_Logf_Call{Call: _e.mock.On("Logf",
|
||||
append([]interface{}{format}, v...)...)}
|
||||
}
|
||||
|
||||
func (_c *mocktestingLogger_Logf_Call) Run(run func(format string, v ...interface{})) *mocktestingLogger_Logf_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 string
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(string)
|
||||
}
|
||||
var arg1 []interface{}
|
||||
var variadicArgs []interface{}
|
||||
if len(args) > 1 {
|
||||
variadicArgs = args[1].([]interface{})
|
||||
}
|
||||
arg1 = variadicArgs
|
||||
run(
|
||||
arg0,
|
||||
arg1...,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *mocktestingLogger_Logf_Call) Return() *mocktestingLogger_Logf_Call {
|
||||
_c.Call.Return()
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *mocktestingLogger_Logf_Call) RunAndReturn(run func(format string, v ...interface{})) *mocktestingLogger_Logf_Call {
|
||||
_c.Run(run)
|
||||
return _c
|
||||
}
|
||||
@@ -1,15 +1,30 @@
|
||||
// Code generated by mockery v2.51.0. DO NOT EDIT.
|
||||
// Code generated by mockery; DO NOT EDIT.
|
||||
// github.com/vektra/mockery
|
||||
// template: testify
|
||||
|
||||
package loader_mock
|
||||
|
||||
import (
|
||||
tls "crypto/tls"
|
||||
"crypto/tls"
|
||||
|
||||
"github.com/int128/kubelogin/pkg/tlsclientconfig"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
|
||||
tlsclientconfig "github.com/int128/kubelogin/pkg/tlsclientconfig"
|
||||
)
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockInterface is an autogenerated mock type for the Interface type
|
||||
type MockInterface struct {
|
||||
mock.Mock
|
||||
@@ -23,9 +38,9 @@ func (_m *MockInterface) EXPECT() *MockInterface_Expecter {
|
||||
return &MockInterface_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Load provides a mock function with given fields: config
|
||||
func (_m *MockInterface) Load(config tlsclientconfig.Config) (*tls.Config, error) {
|
||||
ret := _m.Called(config)
|
||||
// Load provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) Load(config tlsclientconfig.Config) (*tls.Config, error) {
|
||||
ret := _mock.Called(config)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Load")
|
||||
@@ -33,23 +48,21 @@ func (_m *MockInterface) Load(config tlsclientconfig.Config) (*tls.Config, error
|
||||
|
||||
var r0 *tls.Config
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(tlsclientconfig.Config) (*tls.Config, error)); ok {
|
||||
return rf(config)
|
||||
if returnFunc, ok := ret.Get(0).(func(tlsclientconfig.Config) (*tls.Config, error)); ok {
|
||||
return returnFunc(config)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(tlsclientconfig.Config) *tls.Config); ok {
|
||||
r0 = rf(config)
|
||||
if returnFunc, ok := ret.Get(0).(func(tlsclientconfig.Config) *tls.Config); ok {
|
||||
r0 = returnFunc(config)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*tls.Config)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(tlsclientconfig.Config) error); ok {
|
||||
r1 = rf(config)
|
||||
if returnFunc, ok := ret.Get(1).(func(tlsclientconfig.Config) error); ok {
|
||||
r1 = returnFunc(config)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
@@ -66,31 +79,23 @@ func (_e *MockInterface_Expecter) Load(config interface{}) *MockInterface_Load_C
|
||||
|
||||
func (_c *MockInterface_Load_Call) Run(run func(config tlsclientconfig.Config)) *MockInterface_Load_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(tlsclientconfig.Config))
|
||||
var arg0 tlsclientconfig.Config
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(tlsclientconfig.Config)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Load_Call) Return(_a0 *tls.Config, _a1 error) *MockInterface_Load_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
func (_c *MockInterface_Load_Call) Return(config1 *tls.Config, err error) *MockInterface_Load_Call {
|
||||
_c.Call.Return(config1, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Load_Call) RunAndReturn(run func(tlsclientconfig.Config) (*tls.Config, error)) *MockInterface_Load_Call {
|
||||
func (_c *MockInterface_Load_Call) RunAndReturn(run func(config tlsclientconfig.Config) (*tls.Config, error)) *MockInterface_Load_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -1,16 +1,31 @@
|
||||
// Code generated by mockery v2.51.0. DO NOT EDIT.
|
||||
// Code generated by mockery; DO NOT EDIT.
|
||||
// github.com/vektra/mockery
|
||||
// template: testify
|
||||
|
||||
package repository_mock
|
||||
|
||||
import (
|
||||
io "io"
|
||||
"io"
|
||||
|
||||
oidc "github.com/int128/kubelogin/pkg/oidc"
|
||||
"github.com/int128/kubelogin/pkg/oidc"
|
||||
"github.com/int128/kubelogin/pkg/tokencache"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
|
||||
tokencache "github.com/int128/kubelogin/pkg/tokencache"
|
||||
)
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockInterface is an autogenerated mock type for the Interface type
|
||||
type MockInterface struct {
|
||||
mock.Mock
|
||||
@@ -24,21 +39,20 @@ func (_m *MockInterface) EXPECT() *MockInterface_Expecter {
|
||||
return &MockInterface_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// DeleteAll provides a mock function with given fields: config
|
||||
func (_m *MockInterface) DeleteAll(config tokencache.Config) error {
|
||||
ret := _m.Called(config)
|
||||
// DeleteAll provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) DeleteAll(config tokencache.Config) error {
|
||||
ret := _mock.Called(config)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for DeleteAll")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(tokencache.Config) error); ok {
|
||||
r0 = rf(config)
|
||||
if returnFunc, ok := ret.Get(0).(func(tokencache.Config) error); ok {
|
||||
r0 = returnFunc(config)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
@@ -55,24 +69,30 @@ func (_e *MockInterface_Expecter) DeleteAll(config interface{}) *MockInterface_D
|
||||
|
||||
func (_c *MockInterface_DeleteAll_Call) Run(run func(config tokencache.Config)) *MockInterface_DeleteAll_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(tokencache.Config))
|
||||
var arg0 tokencache.Config
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(tokencache.Config)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_DeleteAll_Call) Return(_a0 error) *MockInterface_DeleteAll_Call {
|
||||
_c.Call.Return(_a0)
|
||||
func (_c *MockInterface_DeleteAll_Call) Return(err error) *MockInterface_DeleteAll_Call {
|
||||
_c.Call.Return(err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_DeleteAll_Call) RunAndReturn(run func(tokencache.Config) error) *MockInterface_DeleteAll_Call {
|
||||
func (_c *MockInterface_DeleteAll_Call) RunAndReturn(run func(config tokencache.Config) error) *MockInterface_DeleteAll_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// FindByKey provides a mock function with given fields: config, key
|
||||
func (_m *MockInterface) FindByKey(config tokencache.Config, key tokencache.Key) (*oidc.TokenSet, error) {
|
||||
ret := _m.Called(config, key)
|
||||
// FindByKey provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) FindByKey(config tokencache.Config, key tokencache.Key) (*oidc.TokenSet, error) {
|
||||
ret := _mock.Called(config, key)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for FindByKey")
|
||||
@@ -80,23 +100,21 @@ func (_m *MockInterface) FindByKey(config tokencache.Config, key tokencache.Key)
|
||||
|
||||
var r0 *oidc.TokenSet
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(tokencache.Config, tokencache.Key) (*oidc.TokenSet, error)); ok {
|
||||
return rf(config, key)
|
||||
if returnFunc, ok := ret.Get(0).(func(tokencache.Config, tokencache.Key) (*oidc.TokenSet, error)); ok {
|
||||
return returnFunc(config, key)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(tokencache.Config, tokencache.Key) *oidc.TokenSet); ok {
|
||||
r0 = rf(config, key)
|
||||
if returnFunc, ok := ret.Get(0).(func(tokencache.Config, tokencache.Key) *oidc.TokenSet); ok {
|
||||
r0 = returnFunc(config, key)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*oidc.TokenSet)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(tokencache.Config, tokencache.Key) error); ok {
|
||||
r1 = rf(config, key)
|
||||
if returnFunc, ok := ret.Get(1).(func(tokencache.Config, tokencache.Key) error); ok {
|
||||
r1 = returnFunc(config, key)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
@@ -114,24 +132,35 @@ func (_e *MockInterface_Expecter) FindByKey(config interface{}, key interface{})
|
||||
|
||||
func (_c *MockInterface_FindByKey_Call) Run(run func(config tokencache.Config, key tokencache.Key)) *MockInterface_FindByKey_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(tokencache.Config), args[1].(tokencache.Key))
|
||||
var arg0 tokencache.Config
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(tokencache.Config)
|
||||
}
|
||||
var arg1 tokencache.Key
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(tokencache.Key)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_FindByKey_Call) Return(_a0 *oidc.TokenSet, _a1 error) *MockInterface_FindByKey_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
func (_c *MockInterface_FindByKey_Call) Return(tokenSet *oidc.TokenSet, err error) *MockInterface_FindByKey_Call {
|
||||
_c.Call.Return(tokenSet, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_FindByKey_Call) RunAndReturn(run func(tokencache.Config, tokencache.Key) (*oidc.TokenSet, error)) *MockInterface_FindByKey_Call {
|
||||
func (_c *MockInterface_FindByKey_Call) RunAndReturn(run func(config tokencache.Config, key tokencache.Key) (*oidc.TokenSet, error)) *MockInterface_FindByKey_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Lock provides a mock function with given fields: config, key
|
||||
func (_m *MockInterface) Lock(config tokencache.Config, key tokencache.Key) (io.Closer, error) {
|
||||
ret := _m.Called(config, key)
|
||||
// Lock provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) Lock(config tokencache.Config, key tokencache.Key) (io.Closer, error) {
|
||||
ret := _mock.Called(config, key)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Lock")
|
||||
@@ -139,23 +168,21 @@ func (_m *MockInterface) Lock(config tokencache.Config, key tokencache.Key) (io.
|
||||
|
||||
var r0 io.Closer
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(tokencache.Config, tokencache.Key) (io.Closer, error)); ok {
|
||||
return rf(config, key)
|
||||
if returnFunc, ok := ret.Get(0).(func(tokencache.Config, tokencache.Key) (io.Closer, error)); ok {
|
||||
return returnFunc(config, key)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(tokencache.Config, tokencache.Key) io.Closer); ok {
|
||||
r0 = rf(config, key)
|
||||
if returnFunc, ok := ret.Get(0).(func(tokencache.Config, tokencache.Key) io.Closer); ok {
|
||||
r0 = returnFunc(config, key)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(io.Closer)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(tokencache.Config, tokencache.Key) error); ok {
|
||||
r1 = rf(config, key)
|
||||
if returnFunc, ok := ret.Get(1).(func(tokencache.Config, tokencache.Key) error); ok {
|
||||
r1 = returnFunc(config, key)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
@@ -173,36 +200,46 @@ func (_e *MockInterface_Expecter) Lock(config interface{}, key interface{}) *Moc
|
||||
|
||||
func (_c *MockInterface_Lock_Call) Run(run func(config tokencache.Config, key tokencache.Key)) *MockInterface_Lock_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(tokencache.Config), args[1].(tokencache.Key))
|
||||
var arg0 tokencache.Config
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(tokencache.Config)
|
||||
}
|
||||
var arg1 tokencache.Key
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(tokencache.Key)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Lock_Call) Return(_a0 io.Closer, _a1 error) *MockInterface_Lock_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
func (_c *MockInterface_Lock_Call) Return(closer io.Closer, err error) *MockInterface_Lock_Call {
|
||||
_c.Call.Return(closer, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Lock_Call) RunAndReturn(run func(tokencache.Config, tokencache.Key) (io.Closer, error)) *MockInterface_Lock_Call {
|
||||
func (_c *MockInterface_Lock_Call) RunAndReturn(run func(config tokencache.Config, key tokencache.Key) (io.Closer, error)) *MockInterface_Lock_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Save provides a mock function with given fields: config, key, tokenSet
|
||||
func (_m *MockInterface) Save(config tokencache.Config, key tokencache.Key, tokenSet oidc.TokenSet) error {
|
||||
ret := _m.Called(config, key, tokenSet)
|
||||
// Save provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) Save(config tokencache.Config, key tokencache.Key, tokenSet oidc.TokenSet) error {
|
||||
ret := _mock.Called(config, key, tokenSet)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Save")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(tokencache.Config, tokencache.Key, oidc.TokenSet) error); ok {
|
||||
r0 = rf(config, key, tokenSet)
|
||||
if returnFunc, ok := ret.Get(0).(func(tokencache.Config, tokencache.Key, oidc.TokenSet) error); ok {
|
||||
r0 = returnFunc(config, key, tokenSet)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
@@ -221,31 +258,33 @@ func (_e *MockInterface_Expecter) Save(config interface{}, key interface{}, toke
|
||||
|
||||
func (_c *MockInterface_Save_Call) Run(run func(config tokencache.Config, key tokencache.Key, tokenSet oidc.TokenSet)) *MockInterface_Save_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(tokencache.Config), args[1].(tokencache.Key), args[2].(oidc.TokenSet))
|
||||
var arg0 tokencache.Config
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(tokencache.Config)
|
||||
}
|
||||
var arg1 tokencache.Key
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(tokencache.Key)
|
||||
}
|
||||
var arg2 oidc.TokenSet
|
||||
if args[2] != nil {
|
||||
arg2 = args[2].(oidc.TokenSet)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
arg2,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Save_Call) Return(_a0 error) *MockInterface_Save_Call {
|
||||
_c.Call.Return(_a0)
|
||||
func (_c *MockInterface_Save_Call) Return(err error) *MockInterface_Save_Call {
|
||||
_c.Call.Return(err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Save_Call) RunAndReturn(run func(tokencache.Config, tokencache.Key, oidc.TokenSet) error) *MockInterface_Save_Call {
|
||||
func (_c *MockInterface_Save_Call) RunAndReturn(run func(config tokencache.Config, key tokencache.Key, tokenSet oidc.TokenSet) error) *MockInterface_Save_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -1,15 +1,30 @@
|
||||
// Code generated by mockery v2.51.0. DO NOT EDIT.
|
||||
// Code generated by mockery; DO NOT EDIT.
|
||||
// github.com/vektra/mockery
|
||||
// template: testify
|
||||
|
||||
package authentication_mock
|
||||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
authentication "github.com/int128/kubelogin/pkg/usecases/authentication"
|
||||
"context"
|
||||
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockInterface is an autogenerated mock type for the Interface type
|
||||
type MockInterface struct {
|
||||
mock.Mock
|
||||
@@ -23,9 +38,9 @@ func (_m *MockInterface) EXPECT() *MockInterface_Expecter {
|
||||
return &MockInterface_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Do provides a mock function with given fields: ctx, in
|
||||
func (_m *MockInterface) Do(ctx context.Context, in authentication.Input) (*authentication.Output, error) {
|
||||
ret := _m.Called(ctx, in)
|
||||
// Do provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) Do(ctx context.Context, in authentication.Input) (*authentication.Output, error) {
|
||||
ret := _mock.Called(ctx, in)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Do")
|
||||
@@ -33,23 +48,21 @@ func (_m *MockInterface) Do(ctx context.Context, in authentication.Input) (*auth
|
||||
|
||||
var r0 *authentication.Output
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, authentication.Input) (*authentication.Output, error)); ok {
|
||||
return rf(ctx, in)
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, authentication.Input) (*authentication.Output, error)); ok {
|
||||
return returnFunc(ctx, in)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, authentication.Input) *authentication.Output); ok {
|
||||
r0 = rf(ctx, in)
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, authentication.Input) *authentication.Output); ok {
|
||||
r0 = returnFunc(ctx, in)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*authentication.Output)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, authentication.Input) error); ok {
|
||||
r1 = rf(ctx, in)
|
||||
if returnFunc, ok := ret.Get(1).(func(context.Context, authentication.Input) error); ok {
|
||||
r1 = returnFunc(ctx, in)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
@@ -67,31 +80,28 @@ func (_e *MockInterface_Expecter) Do(ctx interface{}, in interface{}) *MockInter
|
||||
|
||||
func (_c *MockInterface_Do_Call) Run(run func(ctx context.Context, in authentication.Input)) *MockInterface_Do_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context), args[1].(authentication.Input))
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 authentication.Input
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(authentication.Input)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Do_Call) Return(_a0 *authentication.Output, _a1 error) *MockInterface_Do_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
func (_c *MockInterface_Do_Call) Return(output *authentication.Output, err error) *MockInterface_Do_Call {
|
||||
_c.Call.Return(output, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Do_Call) RunAndReturn(run func(context.Context, authentication.Input) (*authentication.Output, error)) *MockInterface_Do_Call {
|
||||
func (_c *MockInterface_Do_Call) RunAndReturn(run func(ctx context.Context, in authentication.Input) (*authentication.Output, error)) *MockInterface_Do_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -1,15 +1,30 @@
|
||||
// Code generated by mockery v2.51.0. DO NOT EDIT.
|
||||
// Code generated by mockery; DO NOT EDIT.
|
||||
// github.com/vektra/mockery
|
||||
// template: testify
|
||||
|
||||
package clean_mock
|
||||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
clean "github.com/int128/kubelogin/pkg/usecases/clean"
|
||||
"context"
|
||||
|
||||
"github.com/int128/kubelogin/pkg/usecases/clean"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockInterface is an autogenerated mock type for the Interface type
|
||||
type MockInterface struct {
|
||||
mock.Mock
|
||||
@@ -23,21 +38,20 @@ func (_m *MockInterface) EXPECT() *MockInterface_Expecter {
|
||||
return &MockInterface_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Do provides a mock function with given fields: ctx, in
|
||||
func (_m *MockInterface) Do(ctx context.Context, in clean.Input) error {
|
||||
ret := _m.Called(ctx, in)
|
||||
// Do provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) Do(ctx context.Context, in clean.Input) error {
|
||||
ret := _mock.Called(ctx, in)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Do")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, clean.Input) error); ok {
|
||||
r0 = rf(ctx, in)
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, clean.Input) error); ok {
|
||||
r0 = returnFunc(ctx, in)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
@@ -55,31 +69,28 @@ func (_e *MockInterface_Expecter) Do(ctx interface{}, in interface{}) *MockInter
|
||||
|
||||
func (_c *MockInterface_Do_Call) Run(run func(ctx context.Context, in clean.Input)) *MockInterface_Do_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context), args[1].(clean.Input))
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 clean.Input
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(clean.Input)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Do_Call) Return(_a0 error) *MockInterface_Do_Call {
|
||||
_c.Call.Return(_a0)
|
||||
func (_c *MockInterface_Do_Call) Return(err error) *MockInterface_Do_Call {
|
||||
_c.Call.Return(err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Do_Call) RunAndReturn(run func(context.Context, clean.Input) error) *MockInterface_Do_Call {
|
||||
func (_c *MockInterface_Do_Call) RunAndReturn(run func(ctx context.Context, in clean.Input) error) *MockInterface_Do_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -1,14 +1,30 @@
|
||||
// Code generated by mockery v2.51.0. DO NOT EDIT.
|
||||
// Code generated by mockery; DO NOT EDIT.
|
||||
// github.com/vektra/mockery
|
||||
// template: testify
|
||||
|
||||
package credentialplugin_mock
|
||||
|
||||
import (
|
||||
context "context"
|
||||
"context"
|
||||
|
||||
credentialplugin "github.com/int128/kubelogin/pkg/usecases/credentialplugin"
|
||||
"github.com/int128/kubelogin/pkg/usecases/credentialplugin"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockInterface is an autogenerated mock type for the Interface type
|
||||
type MockInterface struct {
|
||||
mock.Mock
|
||||
@@ -22,21 +38,20 @@ func (_m *MockInterface) EXPECT() *MockInterface_Expecter {
|
||||
return &MockInterface_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Do provides a mock function with given fields: ctx, in
|
||||
func (_m *MockInterface) Do(ctx context.Context, in credentialplugin.Input) error {
|
||||
ret := _m.Called(ctx, in)
|
||||
// Do provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) Do(ctx context.Context, in credentialplugin.Input) error {
|
||||
ret := _mock.Called(ctx, in)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Do")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, credentialplugin.Input) error); ok {
|
||||
r0 = rf(ctx, in)
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, credentialplugin.Input) error); ok {
|
||||
r0 = returnFunc(ctx, in)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
@@ -54,31 +69,28 @@ func (_e *MockInterface_Expecter) Do(ctx interface{}, in interface{}) *MockInter
|
||||
|
||||
func (_c *MockInterface_Do_Call) Run(run func(ctx context.Context, in credentialplugin.Input)) *MockInterface_Do_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context), args[1].(credentialplugin.Input))
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 credentialplugin.Input
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(credentialplugin.Input)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Do_Call) Return(_a0 error) *MockInterface_Do_Call {
|
||||
_c.Call.Return(_a0)
|
||||
func (_c *MockInterface_Do_Call) Return(err error) *MockInterface_Do_Call {
|
||||
_c.Call.Return(err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Do_Call) RunAndReturn(run func(context.Context, credentialplugin.Input) error) *MockInterface_Do_Call {
|
||||
func (_c *MockInterface_Do_Call) RunAndReturn(run func(ctx context.Context, in credentialplugin.Input) error) *MockInterface_Do_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
// Code generated by mockery v2.51.0. DO NOT EDIT.
|
||||
|
||||
package setup_mock
|
||||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
setup "github.com/int128/kubelogin/pkg/usecases/setup"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// MockInterface is an autogenerated mock type for the Interface type
|
||||
type MockInterface struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type MockInterface_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *MockInterface) EXPECT() *MockInterface_Expecter {
|
||||
return &MockInterface_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// DoStage1 provides a mock function with no fields
|
||||
func (_m *MockInterface) DoStage1() {
|
||||
_m.Called()
|
||||
}
|
||||
|
||||
// MockInterface_DoStage1_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DoStage1'
|
||||
type MockInterface_DoStage1_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// DoStage1 is a helper method to define mock.On call
|
||||
func (_e *MockInterface_Expecter) DoStage1() *MockInterface_DoStage1_Call {
|
||||
return &MockInterface_DoStage1_Call{Call: _e.mock.On("DoStage1")}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_DoStage1_Call) Run(run func()) *MockInterface_DoStage1_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run()
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_DoStage1_Call) Return() *MockInterface_DoStage1_Call {
|
||||
_c.Call.Return()
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_DoStage1_Call) RunAndReturn(run func()) *MockInterface_DoStage1_Call {
|
||||
_c.Run(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// DoStage2 provides a mock function with given fields: ctx, in
|
||||
func (_m *MockInterface) DoStage2(ctx context.Context, in setup.Stage2Input) error {
|
||||
ret := _m.Called(ctx, in)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for DoStage2")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, setup.Stage2Input) error); ok {
|
||||
r0 = rf(ctx, in)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockInterface_DoStage2_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DoStage2'
|
||||
type MockInterface_DoStage2_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// DoStage2 is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - in setup.Stage2Input
|
||||
func (_e *MockInterface_Expecter) DoStage2(ctx interface{}, in interface{}) *MockInterface_DoStage2_Call {
|
||||
return &MockInterface_DoStage2_Call{Call: _e.mock.On("DoStage2", ctx, in)}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_DoStage2_Call) Run(run func(ctx context.Context, in setup.Stage2Input)) *MockInterface_DoStage2_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context), args[1].(setup.Stage2Input))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_DoStage2_Call) Return(_a0 error) *MockInterface_DoStage2_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_DoStage2_Call) RunAndReturn(run func(context.Context, setup.Stage2Input) error) *MockInterface_DoStage2_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
// Code generated by mockery; DO NOT EDIT.
|
||||
// github.com/vektra/mockery
|
||||
// template: testify
|
||||
|
||||
package setup_mock
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/int128/kubelogin/pkg/usecases/setup"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockInterface is an autogenerated mock type for the Interface type
|
||||
type MockInterface struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type MockInterface_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *MockInterface) EXPECT() *MockInterface_Expecter {
|
||||
return &MockInterface_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Do provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) Do(ctx context.Context, in setup.Input) error {
|
||||
ret := _mock.Called(ctx, in)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Do")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, setup.Input) error); ok {
|
||||
r0 = returnFunc(ctx, in)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockInterface_Do_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Do'
|
||||
type MockInterface_Do_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Do is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - in setup.Input
|
||||
func (_e *MockInterface_Expecter) Do(ctx interface{}, in interface{}) *MockInterface_Do_Call {
|
||||
return &MockInterface_Do_Call{Call: _e.mock.On("Do", ctx, in)}
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Do_Call) Run(run func(ctx context.Context, in setup.Input)) *MockInterface_Do_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 setup.Input
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(setup.Input)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Do_Call) Return(err error) *MockInterface_Do_Call {
|
||||
_c.Call.Return(err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Do_Call) RunAndReturn(run func(ctx context.Context, in setup.Input) error) *MockInterface_Do_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
@@ -1,14 +1,30 @@
|
||||
// Code generated by mockery v2.51.0. DO NOT EDIT.
|
||||
// Code generated by mockery; DO NOT EDIT.
|
||||
// github.com/vektra/mockery
|
||||
// template: testify
|
||||
|
||||
package standalone_mock
|
||||
|
||||
import (
|
||||
context "context"
|
||||
"context"
|
||||
|
||||
standalone "github.com/int128/kubelogin/pkg/usecases/standalone"
|
||||
"github.com/int128/kubelogin/pkg/usecases/standalone"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockInterface is an autogenerated mock type for the Interface type
|
||||
type MockInterface struct {
|
||||
mock.Mock
|
||||
@@ -22,21 +38,20 @@ func (_m *MockInterface) EXPECT() *MockInterface_Expecter {
|
||||
return &MockInterface_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Do provides a mock function with given fields: ctx, in
|
||||
func (_m *MockInterface) Do(ctx context.Context, in standalone.Input) error {
|
||||
ret := _m.Called(ctx, in)
|
||||
// Do provides a mock function for the type MockInterface
|
||||
func (_mock *MockInterface) Do(ctx context.Context, in standalone.Input) error {
|
||||
ret := _mock.Called(ctx, in)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Do")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, standalone.Input) error); ok {
|
||||
r0 = rf(ctx, in)
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, standalone.Input) error); ok {
|
||||
r0 = returnFunc(ctx, in)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
@@ -54,31 +69,28 @@ func (_e *MockInterface_Expecter) Do(ctx interface{}, in interface{}) *MockInter
|
||||
|
||||
func (_c *MockInterface_Do_Call) Run(run func(ctx context.Context, in standalone.Input)) *MockInterface_Do_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context), args[1].(standalone.Input))
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 standalone.Input
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(standalone.Input)
|
||||
}
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Do_Call) Return(_a0 error) *MockInterface_Do_Call {
|
||||
_c.Call.Return(_a0)
|
||||
func (_c *MockInterface_Do_Call) Return(err error) *MockInterface_Do_Call {
|
||||
_c.Call.Return(err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockInterface_Do_Call) RunAndReturn(run func(context.Context, standalone.Input) error) *MockInterface_Do_Call {
|
||||
func (_c *MockInterface_Do_Call) RunAndReturn(run func(ctx context.Context, in standalone.Input) error) *MockInterface_Do_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockInterface creates a new instance of MockInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockInterface {
|
||||
mock := &MockInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -1,8 +1,26 @@
|
||||
// Code generated by mockery v2.51.0. DO NOT EDIT.
|
||||
// Code generated by mockery; DO NOT EDIT.
|
||||
// github.com/vektra/mockery
|
||||
// template: testify
|
||||
|
||||
package io_mock
|
||||
|
||||
import mock "github.com/stretchr/testify/mock"
|
||||
import (
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// NewMockCloser creates a new instance of MockCloser. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockCloser(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockCloser {
|
||||
mock := &MockCloser{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// MockCloser is an autogenerated mock type for the Closer type
|
||||
type MockCloser struct {
|
||||
@@ -17,21 +35,20 @@ func (_m *MockCloser) EXPECT() *MockCloser_Expecter {
|
||||
return &MockCloser_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Close provides a mock function with no fields
|
||||
func (_m *MockCloser) Close() error {
|
||||
ret := _m.Called()
|
||||
// Close provides a mock function for the type MockCloser
|
||||
func (_mock *MockCloser) Close() error {
|
||||
ret := _mock.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Close")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func() error); ok {
|
||||
r0 = rf()
|
||||
if returnFunc, ok := ret.Get(0).(func() error); ok {
|
||||
r0 = returnFunc()
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
@@ -52,8 +69,8 @@ func (_c *MockCloser_Close_Call) Run(run func()) *MockCloser_Close_Call {
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockCloser_Close_Call) Return(_a0 error) *MockCloser_Close_Call {
|
||||
_c.Call.Return(_a0)
|
||||
func (_c *MockCloser_Close_Call) Return(err error) *MockCloser_Close_Call {
|
||||
_c.Call.Return(err)
|
||||
return _c
|
||||
}
|
||||
|
||||
@@ -61,17 +78,3 @@ func (_c *MockCloser_Close_Call) RunAndReturn(run func() error) *MockCloser_Clos
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockCloser creates a new instance of MockCloser. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockCloser(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockCloser {
|
||||
mock := &MockCloser{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -5,29 +5,27 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
"github.com/int128/kubelogin/pkg/oidc/client"
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication"
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication/authcode"
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication/devicecode"
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication/ropc"
|
||||
"github.com/spf13/pflag"
|
||||
)
|
||||
|
||||
const oobRedirectURI = "urn:ietf:wg:oauth:2.0:oob"
|
||||
|
||||
type authenticationOptions struct {
|
||||
GrantType string
|
||||
ListenAddress []string
|
||||
AuthenticationTimeoutSec int
|
||||
SkipOpenBrowser bool
|
||||
BrowserCommand string
|
||||
LocalServerCertFile string
|
||||
LocalServerKeyFile string
|
||||
OpenURLAfterAuthentication string
|
||||
RedirectURLHostname string
|
||||
RedirectURLAuthCodeKeyboard string
|
||||
AuthRequestExtraParams map[string]string
|
||||
Username string
|
||||
Password string
|
||||
GrantType string
|
||||
ListenAddress []string
|
||||
AuthenticationTimeoutSec int
|
||||
SkipOpenBrowser bool
|
||||
BrowserCommand string
|
||||
LocalServerCertFile string
|
||||
LocalServerKeyFile string
|
||||
OpenURLAfterAuthentication string
|
||||
AuthRequestExtraParams map[string]string
|
||||
Username string
|
||||
Password string
|
||||
}
|
||||
|
||||
var allGrantType = strings.Join([]string{
|
||||
@@ -36,6 +34,7 @@ var allGrantType = strings.Join([]string{
|
||||
"authcode-keyboard",
|
||||
"password",
|
||||
"device-code",
|
||||
"client-credentials",
|
||||
}, "|")
|
||||
|
||||
func (o *authenticationOptions) addFlags(f *pflag.FlagSet) {
|
||||
@@ -47,9 +46,7 @@ func (o *authenticationOptions) addFlags(f *pflag.FlagSet) {
|
||||
f.StringVar(&o.LocalServerCertFile, "local-server-cert", "", "[authcode] Certificate path for the local server")
|
||||
f.StringVar(&o.LocalServerKeyFile, "local-server-key", "", "[authcode] Certificate key path for the local server")
|
||||
f.StringVar(&o.OpenURLAfterAuthentication, "open-url-after-authentication", "", "[authcode] If set, open the URL in the browser after authentication")
|
||||
f.StringVar(&o.RedirectURLHostname, "oidc-redirect-url-hostname", "localhost", "[authcode] Hostname of the redirect URL")
|
||||
f.StringVar(&o.RedirectURLAuthCodeKeyboard, "oidc-redirect-url-authcode-keyboard", oobRedirectURI, "[authcode-keyboard] Redirect URL")
|
||||
f.StringToStringVar(&o.AuthRequestExtraParams, "oidc-auth-request-extra-params", nil, "[authcode, authcode-keyboard] Extra query parameters to send with an authentication request")
|
||||
f.StringToStringVar(&o.AuthRequestExtraParams, "oidc-auth-request-extra-params", nil, "[authcode, authcode-keyboard, client-credentials] Extra query parameters to send with an authentication request")
|
||||
f.StringVar(&o.Username, "username", "", "[password] Username for resource owner password credentials grant")
|
||||
f.StringVar(&o.Password, "password", "", "[password] Password for resource owner password credentials grant")
|
||||
}
|
||||
@@ -70,13 +67,11 @@ func (o *authenticationOptions) grantOptionSet() (s authentication.GrantOptionSe
|
||||
LocalServerCertFile: o.LocalServerCertFile,
|
||||
LocalServerKeyFile: o.LocalServerKeyFile,
|
||||
OpenURLAfterAuthentication: o.OpenURLAfterAuthentication,
|
||||
RedirectURLHostname: o.RedirectURLHostname,
|
||||
AuthRequestExtraParams: o.AuthRequestExtraParams,
|
||||
}
|
||||
case o.GrantType == "authcode-keyboard":
|
||||
s.AuthCodeKeyboardOption = &authcode.KeyboardOption{
|
||||
AuthRequestExtraParams: o.AuthRequestExtraParams,
|
||||
RedirectURL: o.RedirectURLAuthCodeKeyboard,
|
||||
}
|
||||
case o.GrantType == "password" || (o.GrantType == "auto" && o.Username != ""):
|
||||
s.ROPCOption = &ropc.Option{
|
||||
@@ -88,6 +83,12 @@ func (o *authenticationOptions) grantOptionSet() (s authentication.GrantOptionSe
|
||||
SkipOpenBrowser: o.SkipOpenBrowser,
|
||||
BrowserCommand: o.BrowserCommand,
|
||||
}
|
||||
case o.GrantType == "client-credentials":
|
||||
endpointparams := make(map[string][]string, len(o.AuthRequestExtraParams))
|
||||
for k, v := range o.AuthRequestExtraParams {
|
||||
endpointparams[k] = []string{v}
|
||||
}
|
||||
s.ClientCredentialsOption = &client.GetTokenByClientCredentialsInput{EndpointParams: endpointparams}
|
||||
default:
|
||||
err = fmt.Errorf("grant-type must be one of (%s)", allGrantType)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/int128/kubelogin/pkg/oidc/client"
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication"
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication/authcode"
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication/ropc"
|
||||
@@ -21,7 +22,6 @@ func Test_authenticationOptions_grantOptionSet(t *testing.T) {
|
||||
AuthCodeBrowserOption: &authcode.BrowserOption{
|
||||
BindAddress: defaultListenAddress,
|
||||
AuthenticationTimeout: defaultAuthenticationTimeoutSec * time.Second,
|
||||
RedirectURLHostname: "localhost",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -36,7 +36,6 @@ func Test_authenticationOptions_grantOptionSet(t *testing.T) {
|
||||
"--local-server-cert", "/path/to/local-server-cert",
|
||||
"--local-server-key", "/path/to/local-server-key",
|
||||
"--open-url-after-authentication", "https://example.com/success.html",
|
||||
"--oidc-redirect-url-hostname", "example",
|
||||
"--oidc-auth-request-extra-params", "ttl=86400",
|
||||
"--oidc-auth-request-extra-params", "reauth=true",
|
||||
"--username", "USER",
|
||||
@@ -51,7 +50,6 @@ func Test_authenticationOptions_grantOptionSet(t *testing.T) {
|
||||
LocalServerCertFile: "/path/to/local-server-cert",
|
||||
LocalServerKeyFile: "/path/to/local-server-key",
|
||||
OpenURLAfterAuthentication: "https://example.com/success.html",
|
||||
RedirectURLHostname: "example",
|
||||
AuthRequestExtraParams: map[string]string{"ttl": "86400", "reauth": "true"},
|
||||
},
|
||||
},
|
||||
@@ -61,19 +59,18 @@ func Test_authenticationOptions_grantOptionSet(t *testing.T) {
|
||||
"--grant-type", "authcode-keyboard",
|
||||
},
|
||||
want: authentication.GrantOptionSet{
|
||||
AuthCodeKeyboardOption: &authcode.KeyboardOption{
|
||||
RedirectURL: oobRedirectURI,
|
||||
},
|
||||
AuthCodeKeyboardOption: &authcode.KeyboardOption{},
|
||||
},
|
||||
},
|
||||
"GrantType=authcode-keyboard with full options": {
|
||||
args: []string{
|
||||
"--grant-type", "authcode-keyboard",
|
||||
"--oidc-redirect-url-authcode-keyboard", "http://localhost",
|
||||
"--oidc-auth-request-extra-params", "ttl=86400",
|
||||
"--oidc-auth-request-extra-params", "reauth=true",
|
||||
},
|
||||
want: authentication.GrantOptionSet{
|
||||
AuthCodeKeyboardOption: &authcode.KeyboardOption{
|
||||
RedirectURL: "http://localhost",
|
||||
AuthRequestExtraParams: map[string]string{"ttl": "86400", "reauth": "true"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -92,6 +89,21 @@ func Test_authenticationOptions_grantOptionSet(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
"GrantType=client-credentials": {
|
||||
args: []string{
|
||||
"--grant-type", "client-credentials",
|
||||
"--oidc-auth-request-extra-params", "audience=https://example.com/service1",
|
||||
"--oidc-auth-request-extra-params", "jti=myUUID",
|
||||
},
|
||||
want: authentication.GrantOptionSet{
|
||||
ClientCredentialsOption: &client.GetTokenByClientCredentialsInput{
|
||||
EndpointParams: map[string][]string{
|
||||
"audience": []string{"https://example.com/service1"},
|
||||
"jti": []string{"myUUID"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"GrantType=auto": {
|
||||
args: []string{
|
||||
"--listen-address", "127.0.0.1:10080",
|
||||
|
||||
@@ -9,15 +9,11 @@ import (
|
||||
)
|
||||
|
||||
type cleanOptions struct {
|
||||
tokenCacheOptions tokenCacheOptions
|
||||
TokenCacheDir string
|
||||
}
|
||||
|
||||
func (o *cleanOptions) addFlags(f *pflag.FlagSet) {
|
||||
o.tokenCacheOptions.addFlags(f)
|
||||
}
|
||||
|
||||
func (o *cleanOptions) expandHomedir() {
|
||||
o.tokenCacheOptions.expandHomedir()
|
||||
f.StringVar(&o.TokenCacheDir, "token-cache-dir", getDefaultTokenCacheDir(), "Path to a directory of the token cache")
|
||||
}
|
||||
|
||||
type Clean struct {
|
||||
@@ -31,18 +27,13 @@ func (cmd *Clean) New() *cobra.Command {
|
||||
Short: "Delete the token cache",
|
||||
Long: `Delete the token cache.
|
||||
|
||||
This deletes both the OS keyring and the directory by default.
|
||||
If you encounter an error of keyring, try --token-cache-storage=disk.
|
||||
This deletes the token cache directory from both the file system and the keyring.
|
||||
`,
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(c *cobra.Command, _ []string) error {
|
||||
o.expandHomedir()
|
||||
tokenCacheConfig, err := o.tokenCacheOptions.tokenCacheConfig()
|
||||
if err != nil {
|
||||
return fmt.Errorf("clean: %w", err)
|
||||
}
|
||||
o.TokenCacheDir = expandHomedir(o.TokenCacheDir)
|
||||
in := clean.Input{
|
||||
TokenCacheConfig: tokenCacheConfig,
|
||||
TokenCacheDir: o.TokenCacheDir,
|
||||
}
|
||||
if err := cmd.Clean.Do(c.Context(), in); err != nil {
|
||||
return fmt.Errorf("clean: %w", err)
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/int128/kubelogin/mocks/github.com/int128/kubelogin/pkg/usecases/credentialplugin_mock"
|
||||
"github.com/int128/kubelogin/mocks/github.com/int128/kubelogin/pkg/usecases/setup_mock"
|
||||
"github.com/int128/kubelogin/mocks/github.com/int128/kubelogin/pkg/usecases/standalone_mock"
|
||||
"github.com/int128/kubelogin/pkg/oidc"
|
||||
"github.com/int128/kubelogin/pkg/testing/logger"
|
||||
@@ -16,6 +17,7 @@ import (
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication"
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication/authcode"
|
||||
"github.com/int128/kubelogin/pkg/usecases/credentialplugin"
|
||||
"github.com/int128/kubelogin/pkg/usecases/setup"
|
||||
"github.com/int128/kubelogin/pkg/usecases/standalone"
|
||||
)
|
||||
|
||||
@@ -23,6 +25,13 @@ func TestCmd_Run(t *testing.T) {
|
||||
const executable = "kubelogin"
|
||||
const version = "HEAD"
|
||||
|
||||
defaultGrantOptionSet := authentication.GrantOptionSet{
|
||||
AuthCodeBrowserOption: &authcode.BrowserOption{
|
||||
BindAddress: defaultListenAddress,
|
||||
AuthenticationTimeout: defaultAuthenticationTimeoutSec * time.Second,
|
||||
},
|
||||
}
|
||||
|
||||
t.Run("root", func(t *testing.T) {
|
||||
tests := map[string]struct {
|
||||
args []string
|
||||
@@ -31,13 +40,7 @@ func TestCmd_Run(t *testing.T) {
|
||||
"Defaults": {
|
||||
args: []string{executable},
|
||||
in: standalone.Input{
|
||||
GrantOptionSet: authentication.GrantOptionSet{
|
||||
AuthCodeBrowserOption: &authcode.BrowserOption{
|
||||
BindAddress: defaultListenAddress,
|
||||
AuthenticationTimeout: defaultAuthenticationTimeoutSec * time.Second,
|
||||
RedirectURLHostname: "localhost",
|
||||
},
|
||||
},
|
||||
GrantOptionSet: defaultGrantOptionSet,
|
||||
},
|
||||
},
|
||||
"FullOptions": {
|
||||
@@ -51,13 +54,7 @@ func TestCmd_Run(t *testing.T) {
|
||||
KubeconfigFilename: "/path/to/kubeconfig",
|
||||
KubeconfigContext: "hello.k8s.local",
|
||||
KubeconfigUser: "google",
|
||||
GrantOptionSet: authentication.GrantOptionSet{
|
||||
AuthCodeBrowserOption: &authcode.BrowserOption{
|
||||
BindAddress: defaultListenAddress,
|
||||
AuthenticationTimeout: defaultAuthenticationTimeoutSec * time.Second,
|
||||
RedirectURLHostname: "localhost",
|
||||
},
|
||||
},
|
||||
GrantOptionSet: defaultGrantOptionSet,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -120,15 +117,8 @@ func TestCmd_Run(t *testing.T) {
|
||||
},
|
||||
TokenCacheConfig: tokencache.Config{
|
||||
Directory: filepath.Join(userHomeDir, ".kube/cache/oidc-login"),
|
||||
Storage: tokencache.StorageAuto,
|
||||
},
|
||||
GrantOptionSet: authentication.GrantOptionSet{
|
||||
AuthCodeBrowserOption: &authcode.BrowserOption{
|
||||
BindAddress: defaultListenAddress,
|
||||
AuthenticationTimeout: defaultAuthenticationTimeoutSec * time.Second,
|
||||
RedirectURLHostname: "localhost",
|
||||
},
|
||||
},
|
||||
GrantOptionSet: defaultGrantOptionSet,
|
||||
},
|
||||
},
|
||||
"FullOptions": {
|
||||
@@ -139,7 +129,8 @@ func TestCmd_Run(t *testing.T) {
|
||||
"--oidc-client-secret", "YOUR_CLIENT_SECRET",
|
||||
"--oidc-extra-scope", "email",
|
||||
"--oidc-extra-scope", "profile",
|
||||
"--token-cache-storage", "disk",
|
||||
"--oidc-request-header", "Origin=localhost:8080",
|
||||
"--token-cache-storage", "keyring",
|
||||
"-v1",
|
||||
},
|
||||
in: credentialplugin.Input{
|
||||
@@ -148,18 +139,15 @@ func TestCmd_Run(t *testing.T) {
|
||||
ClientID: "YOUR_CLIENT_ID",
|
||||
ClientSecret: "YOUR_CLIENT_SECRET",
|
||||
ExtraScopes: []string{"email", "profile"},
|
||||
RequestHeaders: map[string]string{
|
||||
"Origin": "localhost:8080",
|
||||
},
|
||||
},
|
||||
TokenCacheConfig: tokencache.Config{
|
||||
Directory: filepath.Join(userHomeDir, ".kube/cache/oidc-login"),
|
||||
Storage: tokencache.StorageDisk,
|
||||
},
|
||||
GrantOptionSet: authentication.GrantOptionSet{
|
||||
AuthCodeBrowserOption: &authcode.BrowserOption{
|
||||
BindAddress: defaultListenAddress,
|
||||
AuthenticationTimeout: defaultAuthenticationTimeoutSec * time.Second,
|
||||
RedirectURLHostname: "localhost",
|
||||
},
|
||||
Storage: tokencache.StorageKeyring,
|
||||
},
|
||||
GrantOptionSet: defaultGrantOptionSet,
|
||||
},
|
||||
},
|
||||
"AccessToken": {
|
||||
@@ -177,15 +165,8 @@ func TestCmd_Run(t *testing.T) {
|
||||
},
|
||||
TokenCacheConfig: tokencache.Config{
|
||||
Directory: filepath.Join(userHomeDir, ".kube/cache/oidc-login"),
|
||||
Storage: tokencache.StorageAuto,
|
||||
},
|
||||
GrantOptionSet: authentication.GrantOptionSet{
|
||||
AuthCodeBrowserOption: &authcode.BrowserOption{
|
||||
BindAddress: defaultListenAddress,
|
||||
AuthenticationTimeout: defaultAuthenticationTimeoutSec * time.Second,
|
||||
RedirectURLHostname: "localhost",
|
||||
},
|
||||
},
|
||||
GrantOptionSet: defaultGrantOptionSet,
|
||||
},
|
||||
},
|
||||
"HomedirExpansion": {
|
||||
@@ -205,13 +186,11 @@ func TestCmd_Run(t *testing.T) {
|
||||
},
|
||||
TokenCacheConfig: tokencache.Config{
|
||||
Directory: filepath.Join(userHomeDir, ".kube/oidc-cache"),
|
||||
Storage: tokencache.StorageAuto,
|
||||
},
|
||||
GrantOptionSet: authentication.GrantOptionSet{
|
||||
AuthCodeBrowserOption: &authcode.BrowserOption{
|
||||
BindAddress: defaultListenAddress,
|
||||
AuthenticationTimeout: defaultAuthenticationTimeoutSec * time.Second,
|
||||
RedirectURLHostname: "localhost",
|
||||
LocalServerCertFile: filepath.Join(userHomeDir, ".kube/oidc-server.crt"),
|
||||
LocalServerKeyFile: filepath.Join(userHomeDir, ".kube/oidc-server.key"),
|
||||
},
|
||||
@@ -282,4 +261,54 @@ func TestCmd_Run(t *testing.T) {
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("setup", func(t *testing.T) {
|
||||
t.Run("NoOption", func(t *testing.T) {
|
||||
ctx := context.TODO()
|
||||
cmd := Cmd{
|
||||
Logger: logger.New(t),
|
||||
Root: &Root{
|
||||
Logger: logger.New(t),
|
||||
},
|
||||
}
|
||||
exitCode := cmd.Run(ctx, []string{executable, "setup"}, version)
|
||||
if exitCode != 0 {
|
||||
t.Errorf("exitCode wants 0 but %d", exitCode)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("WithOptions", func(t *testing.T) {
|
||||
ctx := context.TODO()
|
||||
setupMock := setup_mock.NewMockInterface(t)
|
||||
setupMock.EXPECT().Do(ctx, setup.Input{
|
||||
IssuerURL: "https://issuer.example.com",
|
||||
ClientID: "YOUR_CLIENT",
|
||||
ExtraScopes: []string{"email", "profile"},
|
||||
GrantOptionSet: defaultGrantOptionSet,
|
||||
ChangedFlags: []string{
|
||||
"--oidc-issuer-url=https://issuer.example.com",
|
||||
"--oidc-client-id=YOUR_CLIENT",
|
||||
"--oidc-extra-scope=email",
|
||||
"--oidc-extra-scope=profile",
|
||||
},
|
||||
}).Return(nil)
|
||||
cmd := Cmd{
|
||||
Logger: logger.New(t),
|
||||
Root: &Root{
|
||||
Logger: logger.New(t),
|
||||
},
|
||||
Setup: &Setup{
|
||||
Setup: setupMock,
|
||||
},
|
||||
}
|
||||
exitCode := cmd.Run(ctx, []string{executable, "setup",
|
||||
"--oidc-issuer-url", "https://issuer.example.com",
|
||||
"--oidc-client-id", "YOUR_CLIENT",
|
||||
"--oidc-extra-scope", "email,profile",
|
||||
}, version)
|
||||
if exitCode != 0 {
|
||||
t.Errorf("exitCode wants 0 but %d", exitCode)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -16,8 +16,10 @@ type getTokenOptions struct {
|
||||
IssuerURL string
|
||||
ClientID string
|
||||
ClientSecret string
|
||||
RedirectURL string
|
||||
ExtraScopes []string
|
||||
UseAccessToken bool
|
||||
RequestHeaders map[string]string
|
||||
tokenCacheOptions tokenCacheOptions
|
||||
tlsOptions tlsOptions
|
||||
pkceOptions pkceOptions
|
||||
@@ -29,8 +31,10 @@ func (o *getTokenOptions) addFlags(f *pflag.FlagSet) {
|
||||
f.StringVar(&o.IssuerURL, "oidc-issuer-url", "", "Issuer URL of the provider (mandatory)")
|
||||
f.StringVar(&o.ClientID, "oidc-client-id", "", "Client ID of the provider (mandatory)")
|
||||
f.StringVar(&o.ClientSecret, "oidc-client-secret", "", "Client secret of the provider")
|
||||
f.StringVar(&o.RedirectURL, "oidc-redirect-url", "", "[authcode, authcode-keyboard] Redirect URL")
|
||||
f.StringSliceVar(&o.ExtraScopes, "oidc-extra-scope", nil, "Scopes to request to the provider")
|
||||
f.BoolVar(&o.UseAccessToken, "oidc-use-access-token", false, "Instead of using the id_token, use the access_token to authenticate to Kubernetes")
|
||||
f.StringToStringVar(&o.RequestHeaders, "oidc-request-header", nil, "HTTP headers to send with an authentication request")
|
||||
f.BoolVar(&o.ForceRefresh, "force-refresh", false, "If set, refresh the ID token regardless of its expiration time")
|
||||
o.tokenCacheOptions.addFlags(f)
|
||||
o.tlsOptions.addFlags(f)
|
||||
@@ -85,9 +89,11 @@ func (cmd *GetToken) New() *cobra.Command {
|
||||
IssuerURL: o.IssuerURL,
|
||||
ClientID: o.ClientID,
|
||||
ClientSecret: o.ClientSecret,
|
||||
RedirectURL: o.RedirectURL,
|
||||
PKCEMethod: pkceMethod,
|
||||
UseAccessToken: o.UseAccessToken,
|
||||
ExtraScopes: o.ExtraScopes,
|
||||
RequestHeaders: o.RequestHeaders,
|
||||
},
|
||||
ForceRefresh: o.ForceRefresh,
|
||||
TokenCacheConfig: tokenCacheConfig,
|
||||
|
||||
@@ -3,6 +3,8 @@ package cmd
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
_ "embed"
|
||||
|
||||
"github.com/int128/kubelogin/pkg/usecases/setup"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
@@ -13,8 +15,10 @@ type setupOptions struct {
|
||||
IssuerURL string
|
||||
ClientID string
|
||||
ClientSecret string
|
||||
RedirectURL string
|
||||
ExtraScopes []string
|
||||
UseAccessToken bool
|
||||
RequestHeaders map[string]string
|
||||
tlsOptions tlsOptions
|
||||
pkceOptions pkceOptions
|
||||
authenticationOptions authenticationOptions
|
||||
@@ -24,8 +28,10 @@ func (o *setupOptions) addFlags(f *pflag.FlagSet) {
|
||||
f.StringVar(&o.IssuerURL, "oidc-issuer-url", "", "Issuer URL of the provider")
|
||||
f.StringVar(&o.ClientID, "oidc-client-id", "", "Client ID of the provider")
|
||||
f.StringVar(&o.ClientSecret, "oidc-client-secret", "", "Client secret of the provider")
|
||||
f.StringVar(&o.RedirectURL, "oidc-redirect-url", "", "[authcode, authcode-keyboard] Redirect URL")
|
||||
f.StringSliceVar(&o.ExtraScopes, "oidc-extra-scope", nil, "Scopes to request to the provider")
|
||||
f.BoolVar(&o.UseAccessToken, "oidc-use-access-token", false, "Instead of using the id_token, use the access_token to authenticate to Kubernetes")
|
||||
f.StringToStringVar(&o.RequestHeaders, "oidc-request-header", nil, "HTTP headers to send with an authentication request")
|
||||
o.tlsOptions.addFlags(f)
|
||||
o.pkceOptions.addFlags(f)
|
||||
o.authenticationOptions.addFlags(f)
|
||||
@@ -35,13 +41,31 @@ type Setup struct {
|
||||
Setup setup.Interface
|
||||
}
|
||||
|
||||
//go:embed setup.md
|
||||
var setupLongDescription string
|
||||
|
||||
func (cmd *Setup) New() *cobra.Command {
|
||||
var o setupOptions
|
||||
c := &cobra.Command{
|
||||
Use: "setup",
|
||||
Short: "Show the setup instruction",
|
||||
Long: setupLongDescription,
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(c *cobra.Command, _ []string) error {
|
||||
var changedFlags []string
|
||||
c.Flags().VisitAll(func(f *pflag.Flag) {
|
||||
if !f.Changed {
|
||||
return
|
||||
}
|
||||
if sliceValue, ok := f.Value.(pflag.SliceValue); ok {
|
||||
for _, v := range sliceValue.GetSlice() {
|
||||
changedFlags = append(changedFlags, fmt.Sprintf("--%s=%s", f.Name, v))
|
||||
}
|
||||
return
|
||||
}
|
||||
changedFlags = append(changedFlags, fmt.Sprintf("--%s=%s", f.Name, f.Value))
|
||||
})
|
||||
|
||||
grantOptionSet, err := o.authenticationOptions.grantOptionSet()
|
||||
if err != nil {
|
||||
return fmt.Errorf("setup: %w", err)
|
||||
@@ -50,27 +74,23 @@ func (cmd *Setup) New() *cobra.Command {
|
||||
if err != nil {
|
||||
return fmt.Errorf("setup: %w", err)
|
||||
}
|
||||
in := setup.Stage2Input{
|
||||
in := setup.Input{
|
||||
IssuerURL: o.IssuerURL,
|
||||
ClientID: o.ClientID,
|
||||
ClientSecret: o.ClientSecret,
|
||||
RedirectURL: o.RedirectURL,
|
||||
ExtraScopes: o.ExtraScopes,
|
||||
UseAccessToken: o.UseAccessToken,
|
||||
RequestHeaders: o.RequestHeaders,
|
||||
PKCEMethod: pkceMethod,
|
||||
GrantOptionSet: grantOptionSet,
|
||||
TLSClientConfig: o.tlsOptions.tlsClientConfig(),
|
||||
}
|
||||
if c.Flags().Lookup("listen-address").Changed {
|
||||
in.ListenAddressArgs = o.authenticationOptions.ListenAddress
|
||||
}
|
||||
if c.Flags().Lookup("oidc-pkce-method").Changed {
|
||||
in.PKCEMethodArg = o.pkceOptions.PKCEMethod
|
||||
ChangedFlags: changedFlags,
|
||||
}
|
||||
if in.IssuerURL == "" || in.ClientID == "" {
|
||||
cmd.Setup.DoStage1()
|
||||
return nil
|
||||
return c.Help()
|
||||
}
|
||||
if err := cmd.Setup.DoStage2(c.Context(), in); err != nil {
|
||||
if err := cmd.Setup.Do(c.Context(), in); err != nil {
|
||||
return fmt.Errorf("setup: %w", err)
|
||||
}
|
||||
return nil
|
||||
|
||||
12
pkg/cmd/setup.md
Normal file
12
pkg/cmd/setup.md
Normal file
@@ -0,0 +1,12 @@
|
||||
This setup shows the instruction of Kubernetes OpenID Connect authentication.
|
||||
|
||||
You need to set up the OpenID Connect Provider.
|
||||
Run the following command to authenticate with the OpenID Connect Provider:
|
||||
|
||||
```
|
||||
kubectl oidc-login setup \
|
||||
--oidc-issuer-url=ISSUER_URL \
|
||||
--oidc-client-id=YOUR_CLIENT_ID
|
||||
```
|
||||
|
||||
See https://github.com/int128/kubelogin for the details.
|
||||
@@ -18,7 +18,7 @@ func getDefaultTokenCacheDir() string {
|
||||
return filepath.Join("~", ".kube", "cache", "oidc-login")
|
||||
}
|
||||
|
||||
var allTokenCacheStorage = strings.Join([]string{"auto", "keyring", "disk"}, "|")
|
||||
var allTokenCacheStorage = strings.Join([]string{"disk", "keyring", "none"}, "|")
|
||||
|
||||
type tokenCacheOptions struct {
|
||||
TokenCacheDir string
|
||||
@@ -27,7 +27,7 @@ type tokenCacheOptions struct {
|
||||
|
||||
func (o *tokenCacheOptions) addFlags(f *pflag.FlagSet) {
|
||||
f.StringVar(&o.TokenCacheDir, "token-cache-dir", getDefaultTokenCacheDir(), "Path to a directory of the token cache")
|
||||
f.StringVar(&o.TokenCacheStorage, "token-cache-storage", "auto", fmt.Sprintf("Storage for the token cache. One of (%s)", allTokenCacheStorage))
|
||||
f.StringVar(&o.TokenCacheStorage, "token-cache-storage", "disk", fmt.Sprintf("Storage for the token cache. One of (%s)", allTokenCacheStorage))
|
||||
}
|
||||
|
||||
func (o *tokenCacheOptions) expandHomedir() {
|
||||
@@ -39,12 +39,12 @@ func (o *tokenCacheOptions) tokenCacheConfig() (tokencache.Config, error) {
|
||||
Directory: o.TokenCacheDir,
|
||||
}
|
||||
switch o.TokenCacheStorage {
|
||||
case "auto":
|
||||
config.Storage = tokencache.StorageAuto
|
||||
case "keyring":
|
||||
config.Storage = tokencache.StorageKeyring
|
||||
case "disk":
|
||||
config.Storage = tokencache.StorageDisk
|
||||
case "keyring":
|
||||
config.Storage = tokencache.StorageKeyring
|
||||
case "none":
|
||||
config.Storage = tokencache.StorageNone
|
||||
default:
|
||||
return tokencache.Config{}, fmt.Errorf("token-cache-storage must be one of (%s)", allTokenCacheStorage)
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
"github.com/int128/kubelogin/pkg/tokencache/repository"
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication"
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication/authcode"
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication/clientcredentials"
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication/devicecode"
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication/ropc"
|
||||
"github.com/int128/kubelogin/pkg/usecases/clean"
|
||||
@@ -76,13 +77,17 @@ func NewCmdForHeadless(clockInterface clock.Interface, stdin stdio.Stdin, stdout
|
||||
Browser: browserInterface,
|
||||
Logger: loggerInterface,
|
||||
}
|
||||
clientCredentials := &clientcredentials.ClientCredentials{
|
||||
Logger: loggerInterface,
|
||||
}
|
||||
authenticationAuthentication := &authentication.Authentication{
|
||||
ClientFactory: factory,
|
||||
Logger: loggerInterface,
|
||||
AuthCodeBrowser: authcodeBrowser,
|
||||
AuthCodeKeyboard: keyboard,
|
||||
ROPC: ropcROPC,
|
||||
DeviceCode: deviceCode,
|
||||
ClientFactory: factory,
|
||||
Logger: loggerInterface,
|
||||
AuthCodeBrowser: authcodeBrowser,
|
||||
AuthCodeKeyboard: keyboard,
|
||||
ROPC: ropcROPC,
|
||||
DeviceCode: deviceCode,
|
||||
ClientCredentials: clientCredentials,
|
||||
}
|
||||
loader3 := &loader2.Loader{}
|
||||
writerWriter := &writer.Writer{}
|
||||
@@ -97,9 +102,7 @@ func NewCmdForHeadless(clockInterface clock.Interface, stdin stdio.Stdin, stdout
|
||||
Standalone: standaloneStandalone,
|
||||
Logger: loggerInterface,
|
||||
}
|
||||
repositoryRepository := &repository.Repository{
|
||||
Logger: loggerInterface,
|
||||
}
|
||||
repositoryRepository := &repository.Repository{}
|
||||
reader3 := &reader2.Reader{}
|
||||
writer3 := &writer2.Writer{
|
||||
Stdout: stdout,
|
||||
|
||||
100
pkg/oidc/client/authcode.go
Normal file
100
pkg/oidc/client/authcode.go
Normal file
@@ -0,0 +1,100 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
gooidc "github.com/coreos/go-oidc/v3/oidc"
|
||||
"github.com/int128/kubelogin/pkg/oidc"
|
||||
"github.com/int128/kubelogin/pkg/pkce"
|
||||
"github.com/int128/oauth2cli"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
type AuthCodeURLInput struct {
|
||||
State string
|
||||
Nonce string
|
||||
PKCEParams pkce.Params
|
||||
AuthRequestExtraParams map[string]string
|
||||
}
|
||||
|
||||
type ExchangeAuthCodeInput struct {
|
||||
Code string
|
||||
PKCEParams pkce.Params
|
||||
Nonce string
|
||||
}
|
||||
|
||||
type GetTokenByAuthCodeInput struct {
|
||||
BindAddress []string
|
||||
State string
|
||||
Nonce string
|
||||
PKCEParams pkce.Params
|
||||
AuthRequestExtraParams map[string]string
|
||||
LocalServerSuccessHTML string
|
||||
LocalServerCertFile string
|
||||
LocalServerKeyFile string
|
||||
}
|
||||
|
||||
func (c *client) NegotiatedPKCEMethod() pkce.Method {
|
||||
return c.negotiatedPKCEMethod
|
||||
}
|
||||
|
||||
// GetTokenByAuthCode performs the authorization code flow.
|
||||
func (c *client) GetTokenByAuthCode(ctx context.Context, in GetTokenByAuthCodeInput, localServerReadyChan chan<- string) (*oidc.TokenSet, error) {
|
||||
ctx = c.wrapContext(ctx)
|
||||
config := oauth2cli.Config{
|
||||
OAuth2Config: c.oauth2Config,
|
||||
State: in.State,
|
||||
AuthCodeOptions: authorizationRequestOptions(in.Nonce, in.PKCEParams, in.AuthRequestExtraParams),
|
||||
TokenRequestOptions: tokenRequestOptions(in.PKCEParams),
|
||||
LocalServerBindAddress: in.BindAddress,
|
||||
LocalServerReadyChan: localServerReadyChan,
|
||||
LocalServerSuccessHTML: in.LocalServerSuccessHTML,
|
||||
LocalServerCertFile: in.LocalServerCertFile,
|
||||
LocalServerKeyFile: in.LocalServerKeyFile,
|
||||
Logf: c.logger.V(1).Infof,
|
||||
}
|
||||
token, err := oauth2cli.GetToken(ctx, config)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("oauth2 error: %w", err)
|
||||
}
|
||||
return c.verifyToken(ctx, token, in.Nonce)
|
||||
}
|
||||
|
||||
// GetAuthCodeURL returns the URL of authentication request for the authorization code flow.
|
||||
func (c *client) GetAuthCodeURL(in AuthCodeURLInput) string {
|
||||
opts := authorizationRequestOptions(in.Nonce, in.PKCEParams, in.AuthRequestExtraParams)
|
||||
return c.oauth2Config.AuthCodeURL(in.State, opts...)
|
||||
}
|
||||
|
||||
// ExchangeAuthCode exchanges the authorization code and token.
|
||||
func (c *client) ExchangeAuthCode(ctx context.Context, in ExchangeAuthCodeInput) (*oidc.TokenSet, error) {
|
||||
ctx = c.wrapContext(ctx)
|
||||
opts := tokenRequestOptions(in.PKCEParams)
|
||||
token, err := c.oauth2Config.Exchange(ctx, in.Code, opts...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("exchange error: %w", err)
|
||||
}
|
||||
return c.verifyToken(ctx, token, in.Nonce)
|
||||
}
|
||||
|
||||
func authorizationRequestOptions(nonce string, pkceParams pkce.Params, extraParams map[string]string) []oauth2.AuthCodeOption {
|
||||
opts := []oauth2.AuthCodeOption{
|
||||
oauth2.AccessTypeOffline,
|
||||
gooidc.Nonce(nonce),
|
||||
}
|
||||
if pkceOpt := pkceParams.AuthCodeOption(); pkceOpt != nil {
|
||||
opts = append(opts, pkceOpt)
|
||||
}
|
||||
for key, value := range extraParams {
|
||||
opts = append(opts, oauth2.SetAuthURLParam(key, value))
|
||||
}
|
||||
return opts
|
||||
}
|
||||
|
||||
func tokenRequestOptions(pkceParams pkce.Params) []oauth2.AuthCodeOption {
|
||||
if pkceOpt := pkceParams.TokenRequestOption(); pkceOpt != nil {
|
||||
return []oauth2.AuthCodeOption{pkceOpt}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"github.com/int128/kubelogin/pkg/infrastructure/logger"
|
||||
"github.com/int128/kubelogin/pkg/oidc"
|
||||
"github.com/int128/kubelogin/pkg/pkce"
|
||||
"github.com/int128/oauth2cli"
|
||||
"github.com/int128/oauth2dev"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
@@ -22,47 +21,20 @@ type Interface interface {
|
||||
GetTokenByAuthCode(ctx context.Context, in GetTokenByAuthCodeInput, localServerReadyChan chan<- string) (*oidc.TokenSet, error)
|
||||
NegotiatedPKCEMethod() pkce.Method
|
||||
GetTokenByROPC(ctx context.Context, username, password string) (*oidc.TokenSet, error)
|
||||
GetTokenByClientCredentials(ctx context.Context, in GetTokenByClientCredentialsInput) (*oidc.TokenSet, error)
|
||||
GetDeviceAuthorization(ctx context.Context) (*oauth2dev.AuthorizationResponse, error)
|
||||
ExchangeDeviceCode(ctx context.Context, authResponse *oauth2dev.AuthorizationResponse) (*oidc.TokenSet, error)
|
||||
Refresh(ctx context.Context, refreshToken string) (*oidc.TokenSet, error)
|
||||
}
|
||||
|
||||
type AuthCodeURLInput struct {
|
||||
State string
|
||||
Nonce string
|
||||
PKCEParams pkce.Params
|
||||
RedirectURI string
|
||||
AuthRequestExtraParams map[string]string
|
||||
}
|
||||
|
||||
type ExchangeAuthCodeInput struct {
|
||||
Code string
|
||||
PKCEParams pkce.Params
|
||||
Nonce string
|
||||
RedirectURI string
|
||||
}
|
||||
|
||||
type GetTokenByAuthCodeInput struct {
|
||||
BindAddress []string
|
||||
State string
|
||||
Nonce string
|
||||
PKCEParams pkce.Params
|
||||
RedirectURLHostname string
|
||||
AuthRequestExtraParams map[string]string
|
||||
LocalServerSuccessHTML string
|
||||
LocalServerCertFile string
|
||||
LocalServerKeyFile string
|
||||
}
|
||||
|
||||
type client struct {
|
||||
httpClient *http.Client
|
||||
provider *gooidc.Provider
|
||||
oauth2Config oauth2.Config
|
||||
clock clock.Interface
|
||||
logger logger.Interface
|
||||
negotiatedPKCEMethod pkce.Method
|
||||
deviceAuthorizationEndpoint string
|
||||
useAccessToken bool
|
||||
httpClient *http.Client
|
||||
provider *gooidc.Provider
|
||||
oauth2Config oauth2.Config
|
||||
clock clock.Interface
|
||||
logger logger.Interface
|
||||
negotiatedPKCEMethod pkce.Method
|
||||
useAccessToken bool
|
||||
}
|
||||
|
||||
func (c *client) wrapContext(ctx context.Context) context.Context {
|
||||
@@ -72,109 +44,6 @@ func (c *client) wrapContext(ctx context.Context) context.Context {
|
||||
return ctx
|
||||
}
|
||||
|
||||
// GetTokenByAuthCode performs the authorization code flow.
|
||||
func (c *client) GetTokenByAuthCode(ctx context.Context, in GetTokenByAuthCodeInput, localServerReadyChan chan<- string) (*oidc.TokenSet, error) {
|
||||
ctx = c.wrapContext(ctx)
|
||||
config := oauth2cli.Config{
|
||||
OAuth2Config: c.oauth2Config,
|
||||
State: in.State,
|
||||
AuthCodeOptions: authorizationRequestOptions(in.Nonce, in.PKCEParams, in.AuthRequestExtraParams),
|
||||
TokenRequestOptions: tokenRequestOptions(in.PKCEParams),
|
||||
LocalServerBindAddress: in.BindAddress,
|
||||
LocalServerReadyChan: localServerReadyChan,
|
||||
RedirectURLHostname: in.RedirectURLHostname,
|
||||
LocalServerSuccessHTML: in.LocalServerSuccessHTML,
|
||||
LocalServerCertFile: in.LocalServerCertFile,
|
||||
LocalServerKeyFile: in.LocalServerKeyFile,
|
||||
Logf: c.logger.V(1).Infof,
|
||||
}
|
||||
token, err := oauth2cli.GetToken(ctx, config)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("oauth2 error: %w", err)
|
||||
}
|
||||
return c.verifyToken(ctx, token, in.Nonce)
|
||||
}
|
||||
|
||||
// GetAuthCodeURL returns the URL of authentication request for the authorization code flow.
|
||||
func (c *client) GetAuthCodeURL(in AuthCodeURLInput) string {
|
||||
cfg := c.oauth2Config
|
||||
cfg.RedirectURL = in.RedirectURI
|
||||
opts := authorizationRequestOptions(in.Nonce, in.PKCEParams, in.AuthRequestExtraParams)
|
||||
return cfg.AuthCodeURL(in.State, opts...)
|
||||
}
|
||||
|
||||
// ExchangeAuthCode exchanges the authorization code and token.
|
||||
func (c *client) ExchangeAuthCode(ctx context.Context, in ExchangeAuthCodeInput) (*oidc.TokenSet, error) {
|
||||
ctx = c.wrapContext(ctx)
|
||||
cfg := c.oauth2Config
|
||||
cfg.RedirectURL = in.RedirectURI
|
||||
opts := tokenRequestOptions(in.PKCEParams)
|
||||
token, err := cfg.Exchange(ctx, in.Code, opts...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("exchange error: %w", err)
|
||||
}
|
||||
return c.verifyToken(ctx, token, in.Nonce)
|
||||
}
|
||||
|
||||
func authorizationRequestOptions(nonce string, pkceParams pkce.Params, extraParams map[string]string) []oauth2.AuthCodeOption {
|
||||
opts := []oauth2.AuthCodeOption{
|
||||
oauth2.AccessTypeOffline,
|
||||
gooidc.Nonce(nonce),
|
||||
}
|
||||
if pkceParams.CodeChallenge != "" {
|
||||
opts = append(opts, oauth2.SetAuthURLParam("code_challenge", pkceParams.CodeChallenge))
|
||||
}
|
||||
if pkceParams.CodeChallengeMethod != "" {
|
||||
opts = append(opts, oauth2.SetAuthURLParam("code_challenge_method", pkceParams.CodeChallengeMethod))
|
||||
}
|
||||
for key, value := range extraParams {
|
||||
opts = append(opts, oauth2.SetAuthURLParam(key, value))
|
||||
}
|
||||
return opts
|
||||
}
|
||||
|
||||
func tokenRequestOptions(pkceParams pkce.Params) []oauth2.AuthCodeOption {
|
||||
var opts []oauth2.AuthCodeOption
|
||||
if pkceParams.CodeVerifier != "" {
|
||||
opts = append(opts, oauth2.SetAuthURLParam("code_verifier", pkceParams.CodeVerifier))
|
||||
}
|
||||
return opts
|
||||
}
|
||||
|
||||
func (c *client) NegotiatedPKCEMethod() pkce.Method {
|
||||
return c.negotiatedPKCEMethod
|
||||
}
|
||||
|
||||
// GetTokenByROPC performs the resource owner password credentials flow.
|
||||
func (c *client) GetTokenByROPC(ctx context.Context, username, password string) (*oidc.TokenSet, error) {
|
||||
ctx = c.wrapContext(ctx)
|
||||
token, err := c.oauth2Config.PasswordCredentialsToken(ctx, username, password)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("resource owner password credentials flow error: %w", err)
|
||||
}
|
||||
return c.verifyToken(ctx, token, "")
|
||||
}
|
||||
|
||||
// GetDeviceAuthorization initializes the device authorization code challenge
|
||||
func (c *client) GetDeviceAuthorization(ctx context.Context) (*oauth2dev.AuthorizationResponse, error) {
|
||||
ctx = c.wrapContext(ctx)
|
||||
config := c.oauth2Config
|
||||
config.Endpoint = oauth2.Endpoint{
|
||||
AuthURL: c.deviceAuthorizationEndpoint,
|
||||
}
|
||||
return oauth2dev.RetrieveCode(ctx, config)
|
||||
}
|
||||
|
||||
// ExchangeDeviceCode exchanges the device to an oidc.TokenSet
|
||||
func (c *client) ExchangeDeviceCode(ctx context.Context, authResponse *oauth2dev.AuthorizationResponse) (*oidc.TokenSet, error) {
|
||||
ctx = c.wrapContext(ctx)
|
||||
tokenResponse, err := oauth2dev.PollToken(ctx, c.oauth2Config, *authResponse)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("device-code: exchange failed: %w", err)
|
||||
}
|
||||
return c.verifyToken(ctx, tokenResponse, "")
|
||||
}
|
||||
|
||||
// Refresh sends a refresh token request and returns a token set.
|
||||
func (c *client) Refresh(ctx context.Context, refreshToken string) (*oidc.TokenSet, error) {
|
||||
ctx = c.wrapContext(ctx)
|
||||
|
||||
41
pkg/oidc/client/clientcredentials.go
Normal file
41
pkg/oidc/client/clientcredentials.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/int128/kubelogin/pkg/oidc"
|
||||
"golang.org/x/oauth2"
|
||||
"golang.org/x/oauth2/clientcredentials"
|
||||
)
|
||||
|
||||
type GetTokenByClientCredentialsInput struct {
|
||||
EndpointParams map[string][]string
|
||||
}
|
||||
|
||||
// GetTokenByClientCredentials performs the client credentials flow.
|
||||
func (c *client) GetTokenByClientCredentials(ctx context.Context, in GetTokenByClientCredentialsInput) (*oidc.TokenSet, error) {
|
||||
ctx = c.wrapContext(ctx)
|
||||
c.logger.V(1).Infof("%s, %s, %v", c.oauth2Config.ClientID, c.oauth2Config.Endpoint.AuthURL, c.oauth2Config.Scopes)
|
||||
|
||||
config := clientcredentials.Config{
|
||||
ClientID: c.oauth2Config.ClientID,
|
||||
ClientSecret: c.oauth2Config.ClientSecret,
|
||||
TokenURL: c.oauth2Config.Endpoint.TokenURL,
|
||||
Scopes: c.oauth2Config.Scopes,
|
||||
EndpointParams: in.EndpointParams,
|
||||
AuthStyle: oauth2.AuthStyleInHeader,
|
||||
}
|
||||
source := config.TokenSource(ctx)
|
||||
token, err := source.Token()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not acquire token: %w", err)
|
||||
}
|
||||
if c.useAccessToken {
|
||||
return &oidc.TokenSet{
|
||||
IDToken: token.AccessToken,
|
||||
RefreshToken: token.RefreshToken,
|
||||
}, nil
|
||||
}
|
||||
return c.verifyToken(ctx, token, "")
|
||||
}
|
||||
30
pkg/oidc/client/devicecode.go
Normal file
30
pkg/oidc/client/devicecode.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/int128/kubelogin/pkg/oidc"
|
||||
"github.com/int128/oauth2dev"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
// GetDeviceAuthorization initializes the device authorization code challenge
|
||||
func (c *client) GetDeviceAuthorization(ctx context.Context) (*oauth2dev.AuthorizationResponse, error) {
|
||||
ctx = c.wrapContext(ctx)
|
||||
config := c.oauth2Config
|
||||
config.Endpoint = oauth2.Endpoint{
|
||||
AuthURL: c.provider.Endpoint().DeviceAuthURL,
|
||||
}
|
||||
return oauth2dev.RetrieveCode(ctx, config)
|
||||
}
|
||||
|
||||
// ExchangeDeviceCode exchanges the device authorization code for an oidc.TokenSet
|
||||
func (c *client) ExchangeDeviceCode(ctx context.Context, authResponse *oauth2dev.AuthorizationResponse) (*oidc.TokenSet, error) {
|
||||
ctx = c.wrapContext(ctx)
|
||||
tokenResponse, err := oauth2dev.PollToken(ctx, c.oauth2Config, *authResponse)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("device-code: exchange failed: %w", err)
|
||||
}
|
||||
return c.verifyToken(ctx, tokenResponse, "")
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/int128/kubelogin/pkg/infrastructure/clock"
|
||||
"github.com/int128/kubelogin/pkg/infrastructure/logger"
|
||||
"github.com/int128/kubelogin/pkg/oidc"
|
||||
"github.com/int128/kubelogin/pkg/oidc/client/logging"
|
||||
"github.com/int128/kubelogin/pkg/oidc/client/transport"
|
||||
"github.com/int128/kubelogin/pkg/pkce"
|
||||
"github.com/int128/kubelogin/pkg/tlsclientconfig"
|
||||
"github.com/int128/kubelogin/pkg/tlsclientconfig/loader"
|
||||
@@ -40,16 +40,17 @@ func (f *Factory) New(ctx context.Context, prov oidc.Provider, tlsClientConfig t
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not load the TLS client config: %w", err)
|
||||
}
|
||||
baseTransport := &http.Transport{
|
||||
TLSClientConfig: rawTLSClientConfig,
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
}
|
||||
loggingTransport := &logging.Transport{
|
||||
Base: baseTransport,
|
||||
Logger: f.Logger,
|
||||
}
|
||||
httpClient := &http.Client{
|
||||
Transport: loggingTransport,
|
||||
Transport: &transport.WithHeader{
|
||||
Base: &transport.WithLogging{
|
||||
Base: &http.Transport{
|
||||
TLSClientConfig: rawTLSClientConfig,
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
},
|
||||
Logger: f.Logger,
|
||||
},
|
||||
RequestHeaders: prov.RequestHeaders,
|
||||
},
|
||||
}
|
||||
|
||||
ctx = context.WithValue(ctx, oauth2.HTTPClient, httpClient)
|
||||
@@ -61,24 +62,26 @@ func (f *Factory) New(ctx context.Context, prov oidc.Provider, tlsClientConfig t
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not determine supported PKCE methods: %w", err)
|
||||
}
|
||||
deviceAuthorizationEndpoint, err := extractDeviceAuthorizationEndpoint(provider)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not determine device authorization endpoint: %w", err)
|
||||
|
||||
endpoint := provider.Endpoint()
|
||||
if prov.ClientSecret == "" {
|
||||
endpoint.AuthStyle = oauth2.AuthStyleInParams
|
||||
}
|
||||
|
||||
return &client{
|
||||
httpClient: httpClient,
|
||||
provider: provider,
|
||||
oauth2Config: oauth2.Config{
|
||||
Endpoint: provider.Endpoint(),
|
||||
Endpoint: endpoint,
|
||||
ClientID: prov.ClientID,
|
||||
ClientSecret: prov.ClientSecret,
|
||||
RedirectURL: prov.RedirectURL,
|
||||
Scopes: append(prov.ExtraScopes, gooidc.ScopeOpenID),
|
||||
},
|
||||
clock: f.Clock,
|
||||
logger: f.Logger,
|
||||
negotiatedPKCEMethod: determinePKCEMethod(supportedPKCEMethods, prov.PKCEMethod),
|
||||
deviceAuthorizationEndpoint: deviceAuthorizationEndpoint,
|
||||
useAccessToken: prov.UseAccessToken,
|
||||
clock: f.Clock,
|
||||
logger: f.Logger,
|
||||
negotiatedPKCEMethod: determinePKCEMethod(supportedPKCEMethods, prov.PKCEMethod),
|
||||
useAccessToken: prov.UseAccessToken,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -105,13 +108,3 @@ func extractSupportedPKCEMethods(provider *gooidc.Provider) ([]string, error) {
|
||||
}
|
||||
return claims.CodeChallengeMethodsSupported, nil
|
||||
}
|
||||
|
||||
func extractDeviceAuthorizationEndpoint(provider *gooidc.Provider) (string, error) {
|
||||
var claims struct {
|
||||
DeviceAuthorizationEndpoint string `json:"device_authorization_endpoint"`
|
||||
}
|
||||
if err := provider.Claims(&claims); err != nil {
|
||||
return "", fmt.Errorf("invalid discovery document: %w", err)
|
||||
}
|
||||
return claims.DeviceAuthorizationEndpoint, nil
|
||||
}
|
||||
|
||||
18
pkg/oidc/client/ropc.go
Normal file
18
pkg/oidc/client/ropc.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/int128/kubelogin/pkg/oidc"
|
||||
)
|
||||
|
||||
// GetTokenByROPC performs the resource owner password credentials flow.
|
||||
func (c *client) GetTokenByROPC(ctx context.Context, username, password string) (*oidc.TokenSet, error) {
|
||||
ctx = c.wrapContext(ctx)
|
||||
token, err := c.oauth2Config.PasswordCredentialsToken(ctx, username, password)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("resource owner password credentials flow error: %w", err)
|
||||
}
|
||||
return c.verifyToken(ctx, token, "")
|
||||
}
|
||||
21
pkg/oidc/client/transport/header.go
Normal file
21
pkg/oidc/client/transport/header.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package transport
|
||||
|
||||
import "net/http"
|
||||
|
||||
// WithHeader is a RoundTripper that adds custom headers to each request.
|
||||
//
|
||||
// Token retrievel fails when an auth code has been retrieved using Azure AD
|
||||
// Single Page Application due to the missing "Origin" header for CORS
|
||||
// validation.
|
||||
// https://github.com/int128/kubelogin/issues/1048
|
||||
type WithHeader struct {
|
||||
Base http.RoundTripper
|
||||
RequestHeaders map[string]string
|
||||
}
|
||||
|
||||
func (t *WithHeader) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
for key, value := range t.RequestHeaders {
|
||||
req.Header.Set(key, value)
|
||||
}
|
||||
return t.Base.RoundTrip(req)
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package logging
|
||||
package transport
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
@@ -12,12 +12,12 @@ const (
|
||||
levelDumpBody = 3
|
||||
)
|
||||
|
||||
type Transport struct {
|
||||
type WithLogging struct {
|
||||
Base http.RoundTripper
|
||||
Logger logger.Interface
|
||||
}
|
||||
|
||||
func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
func (t *WithLogging) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
if !t.Logger.IsEnabled(levelDumpHeaders) {
|
||||
return t.Base.RoundTrip(req)
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package logging
|
||||
package transport
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
@@ -20,7 +20,7 @@ func (t *mockTransport) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
return t.resp, nil
|
||||
}
|
||||
|
||||
func TestLoggingTransport_RoundTrip(t *testing.T) {
|
||||
func TestWithLogging_RoundTrip(t *testing.T) {
|
||||
req := httptest.NewRequest("GET", "http://example.com/hello", nil)
|
||||
resp, err := http.ReadResponse(bufio.NewReader(strings.NewReader(`HTTP/1.1 200 OK
|
||||
Host: example.com
|
||||
@@ -29,9 +29,13 @@ dummy`)), req)
|
||||
if err != nil {
|
||||
t.Errorf("could not create a response: %s", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer func() {
|
||||
if err := resp.Body.Close(); err != nil {
|
||||
t.Errorf("could not close response body: %s", err)
|
||||
}
|
||||
}()
|
||||
|
||||
transport := &Transport{
|
||||
transport := &WithLogging{
|
||||
Base: &mockTransport{resp: resp},
|
||||
Logger: logger.New(t),
|
||||
}
|
||||
@@ -15,8 +15,10 @@ type Provider struct {
|
||||
ClientID string
|
||||
ClientSecret string // optional
|
||||
ExtraScopes []string // optional
|
||||
RedirectURL string // optional
|
||||
PKCEMethod PKCEMethod
|
||||
UseAccessToken bool
|
||||
RequestHeaders map[string]string
|
||||
}
|
||||
|
||||
// PKCEMethod represents a preferred method of PKCE.
|
||||
|
||||
@@ -2,13 +2,7 @@
|
||||
// See also https://tools.ietf.org/html/rfc7636.
|
||||
package pkce
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
)
|
||||
import "golang.org/x/oauth2"
|
||||
|
||||
type Method int
|
||||
|
||||
@@ -20,9 +14,22 @@ const (
|
||||
|
||||
// Params represents a set of the PKCE parameters.
|
||||
type Params struct {
|
||||
CodeChallenge string
|
||||
CodeChallengeMethod string
|
||||
CodeVerifier string
|
||||
Method Method
|
||||
Verifier string
|
||||
}
|
||||
|
||||
func (params Params) AuthCodeOption() oauth2.AuthCodeOption {
|
||||
if params.Method == MethodS256 {
|
||||
return oauth2.S256ChallengeOption(params.Verifier)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (params Params) TokenRequestOption() oauth2.AuthCodeOption {
|
||||
if params.Method == MethodS256 {
|
||||
return oauth2.VerifierOption(params.Verifier)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// New returns a parameters supported by the provider.
|
||||
@@ -30,39 +37,10 @@ type Params struct {
|
||||
// It returns a zero value if no method is available.
|
||||
func New(method Method) (Params, error) {
|
||||
if method == MethodS256 {
|
||||
return NewS256()
|
||||
return Params{
|
||||
Method: MethodS256,
|
||||
Verifier: oauth2.GenerateVerifier(),
|
||||
}, nil
|
||||
}
|
||||
return Params{}, nil
|
||||
}
|
||||
|
||||
// NewS256 generates a parameters for S256.
|
||||
func NewS256() (Params, error) {
|
||||
b, err := random32()
|
||||
if err != nil {
|
||||
return Params{}, fmt.Errorf("could not generate a random: %w", err)
|
||||
}
|
||||
return computeS256(b), nil
|
||||
}
|
||||
|
||||
func random32() ([]byte, error) {
|
||||
b := make([]byte, 32)
|
||||
if err := binary.Read(rand.Reader, binary.LittleEndian, b); err != nil {
|
||||
return nil, fmt.Errorf("read error: %w", err)
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func computeS256(b []byte) Params {
|
||||
v := base64URLEncode(b)
|
||||
s := sha256.New()
|
||||
_, _ = s.Write([]byte(v))
|
||||
return Params{
|
||||
CodeChallenge: base64URLEncode(s.Sum(nil)),
|
||||
CodeChallengeMethod: "S256",
|
||||
CodeVerifier: v,
|
||||
}
|
||||
}
|
||||
|
||||
func base64URLEncode(b []byte) string {
|
||||
return base64.URLEncoding.WithPadding(base64.NoPadding).EncodeToString(b)
|
||||
}
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
package pkce
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
)
|
||||
|
||||
func TestNew(t *testing.T) {
|
||||
t.Run("S256", func(t *testing.T) {
|
||||
params, err := New(MethodS256)
|
||||
if err != nil {
|
||||
t.Fatalf("New error: %s", err)
|
||||
}
|
||||
if params.CodeChallengeMethod != "S256" {
|
||||
t.Errorf("CodeChallengeMethod wants S256 but was %s", params.CodeChallengeMethod)
|
||||
}
|
||||
if params.CodeChallenge == "" {
|
||||
t.Errorf("CodeChallenge wants non-empty but was empty")
|
||||
}
|
||||
if params.CodeVerifier == "" {
|
||||
t.Errorf("CodeVerifier wants non-empty but was empty")
|
||||
}
|
||||
})
|
||||
t.Run("NoMethod", func(t *testing.T) {
|
||||
params, err := New(NoMethod)
|
||||
if err != nil {
|
||||
t.Fatalf("New error: %s", err)
|
||||
}
|
||||
if diff := cmp.Diff(Params{}, params); diff != "" {
|
||||
t.Errorf("mismatch (-want +got):\n%s", diff)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func Test_computeS256(t *testing.T) {
|
||||
// Testdata described at:
|
||||
// https://tools.ietf.org/html/rfc7636#appendix-B
|
||||
b := []byte{
|
||||
116, 24, 223, 180, 151, 153, 224, 37, 79, 250, 96, 125, 216, 173,
|
||||
187, 186, 22, 212, 37, 77, 105, 214, 191, 240, 91, 88, 5, 88, 83,
|
||||
132, 141, 121,
|
||||
}
|
||||
p := computeS256(b)
|
||||
if want := "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"; want != p.CodeVerifier {
|
||||
t.Errorf("CodeVerifier wants %s but was %s", want, p.CodeVerifier)
|
||||
}
|
||||
if want := "E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM"; want != p.CodeChallenge {
|
||||
t.Errorf("CodeChallenge wants %s but was %s", want, p.CodeChallenge)
|
||||
}
|
||||
if p.CodeChallengeMethod != "S256" {
|
||||
t.Errorf("CodeChallengeMethod wants S256 but was %s", p.CodeChallengeMethod)
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"encoding/gob"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
@@ -13,7 +12,6 @@ import (
|
||||
|
||||
"github.com/gofrs/flock"
|
||||
"github.com/google/wire"
|
||||
"github.com/int128/kubelogin/pkg/infrastructure/logger"
|
||||
"github.com/int128/kubelogin/pkg/oidc"
|
||||
"github.com/int128/kubelogin/pkg/tokencache"
|
||||
"github.com/zalando/go-keyring"
|
||||
@@ -39,9 +37,7 @@ type entity struct {
|
||||
|
||||
// Repository provides access to the token cache on the local filesystem.
|
||||
// Filename of a token cache is sha256 digest of the issuer, zero-character and client ID.
|
||||
type Repository struct {
|
||||
Logger logger.Interface
|
||||
}
|
||||
type Repository struct{}
|
||||
|
||||
// keyringService is used to namespace the keyring access.
|
||||
// Some implementations may also display this string when prompting the user
|
||||
@@ -57,20 +53,12 @@ func (r *Repository) FindByKey(config tokencache.Config, key tokencache.Key) (*o
|
||||
return nil, fmt.Errorf("could not compute the key: %w", err)
|
||||
}
|
||||
switch config.Storage {
|
||||
case tokencache.StorageAuto:
|
||||
t, err := readFromKeyring(checksum)
|
||||
if errors.Is(err, keyring.ErrUnsupportedPlatform) ||
|
||||
errors.Is(err, keyring.ErrNotFound) {
|
||||
return readFromFile(config, checksum)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return t, nil
|
||||
case tokencache.StorageDisk:
|
||||
return readFromFile(config, checksum)
|
||||
case tokencache.StorageKeyring:
|
||||
return readFromKeyring(checksum)
|
||||
case tokencache.StorageNone:
|
||||
return nil, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown storage mode: %v", config.Storage)
|
||||
}
|
||||
@@ -120,18 +108,12 @@ func (r *Repository) Save(config tokencache.Config, key tokencache.Key, tokenSet
|
||||
return fmt.Errorf("could not compute the key: %w", err)
|
||||
}
|
||||
switch config.Storage {
|
||||
case tokencache.StorageAuto:
|
||||
if err := writeToKeyring(checksum, tokenSet); err != nil {
|
||||
if errors.Is(err, keyring.ErrUnsupportedPlatform) {
|
||||
return writeToFile(config, checksum, tokenSet)
|
||||
}
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
case tokencache.StorageDisk:
|
||||
return writeToFile(config, checksum, tokenSet)
|
||||
case tokencache.StorageKeyring:
|
||||
return writeToKeyring(checksum, tokenSet)
|
||||
case tokencache.StorageNone:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("unknown storage mode: %v", config.Storage)
|
||||
}
|
||||
@@ -164,7 +146,15 @@ func writeToKeyring(checksum string, tokenSet oidc.TokenSet) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Implement io.Closer for noneStorage type
|
||||
type noneStorageCloser struct{}
|
||||
|
||||
func (c noneStorageCloser) Close() error { return nil }
|
||||
|
||||
func (r *Repository) Lock(config tokencache.Config, key tokencache.Key) (io.Closer, error) {
|
||||
if config.Storage == tokencache.StorageNone {
|
||||
return noneStorageCloser{}, nil
|
||||
}
|
||||
checksum, err := computeChecksum(key)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not compute the key: %w", err)
|
||||
@@ -185,36 +175,22 @@ func (r *Repository) Lock(config tokencache.Config, key tokencache.Key) (io.Clos
|
||||
}
|
||||
|
||||
func (r *Repository) DeleteAll(config tokencache.Config) error {
|
||||
return errors.Join(
|
||||
func() error {
|
||||
if err := os.RemoveAll(config.Directory); err != nil {
|
||||
return fmt.Errorf("remove the directory %s: %w", config.Directory, err)
|
||||
}
|
||||
r.Logger.Printf("Deleted the token cache at %s", config.Directory)
|
||||
return nil
|
||||
}(),
|
||||
func() error {
|
||||
switch config.Storage {
|
||||
case tokencache.StorageAuto:
|
||||
if err := keyring.DeleteAll(keyringService); err != nil {
|
||||
if errors.Is(err, keyring.ErrUnsupportedPlatform) {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("keyring delete: %w", err)
|
||||
}
|
||||
r.Logger.Printf("Deleted the token cache in the keyring")
|
||||
return nil
|
||||
case tokencache.StorageKeyring:
|
||||
if err := keyring.DeleteAll(keyringService); err != nil {
|
||||
return fmt.Errorf("keyring delete: %w", err)
|
||||
}
|
||||
r.Logger.Printf("Deleted the token cache in the keyring")
|
||||
return nil
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}(),
|
||||
)
|
||||
switch config.Storage {
|
||||
case tokencache.StorageDisk:
|
||||
if err := os.RemoveAll(config.Directory); err != nil {
|
||||
return fmt.Errorf("remove the directory %s: %w", config.Directory, err)
|
||||
}
|
||||
return nil
|
||||
case tokencache.StorageKeyring:
|
||||
if err := keyring.DeleteAll(keyringService); err != nil {
|
||||
return fmt.Errorf("keyring delete: %w", err)
|
||||
}
|
||||
return nil
|
||||
case tokencache.StorageNone:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("unknown storage mode: %v", config.Storage)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeKey(tokenSet oidc.TokenSet) ([]byte, error) {
|
||||
|
||||
@@ -25,10 +25,10 @@ type Config struct {
|
||||
type Storage byte
|
||||
|
||||
const (
|
||||
// StorageAuto will prefer keyring when available, and fallback to disk when not.
|
||||
StorageAuto Storage = iota
|
||||
// StorageDisk will only store cached keys on disk.
|
||||
StorageDisk
|
||||
StorageDisk Storage = iota
|
||||
// StorageDisk will only store cached keys in the OS keyring.
|
||||
StorageKeyring
|
||||
// StorageNone will not store cached keys.
|
||||
StorageNone
|
||||
)
|
||||
|
||||
@@ -19,7 +19,6 @@ type BrowserOption struct {
|
||||
BindAddress []string
|
||||
AuthenticationTimeout time.Duration
|
||||
OpenURLAfterAuthentication string
|
||||
RedirectURLHostname string
|
||||
AuthRequestExtraParams map[string]string
|
||||
LocalServerCertFile string
|
||||
LocalServerKeyFile string
|
||||
@@ -54,7 +53,6 @@ func (u *Browser) Do(ctx context.Context, o *BrowserOption, oidcClient client.In
|
||||
State: state,
|
||||
Nonce: nonce,
|
||||
PKCEParams: pkceParams,
|
||||
RedirectURLHostname: o.RedirectURLHostname,
|
||||
AuthRequestExtraParams: o.AuthRequestExtraParams,
|
||||
LocalServerSuccessHTML: successHTML,
|
||||
LocalServerCertFile: o.LocalServerCertFile,
|
||||
|
||||
@@ -28,7 +28,6 @@ func TestBrowser_Do(t *testing.T) {
|
||||
LocalServerCertFile: "/path/to/local-server-cert",
|
||||
LocalServerKeyFile: "/path/to/local-server-key",
|
||||
OpenURLAfterAuthentication: "https://example.com/success.html",
|
||||
RedirectURLHostname: "localhost",
|
||||
AuthRequestExtraParams: map[string]string{"ttl": "86400", "reauth": "true"},
|
||||
}
|
||||
mockClient := client_mock.NewMockInterface(t)
|
||||
@@ -42,9 +41,6 @@ func TestBrowser_Do(t *testing.T) {
|
||||
if diff := cmp.Diff(BrowserRedirectHTML("https://example.com/success.html"), in.LocalServerSuccessHTML); diff != "" {
|
||||
t.Errorf("LocalServerSuccessHTML mismatch (-want +got):\n%s", diff)
|
||||
}
|
||||
if diff := cmp.Diff(o.RedirectURLHostname, in.RedirectURLHostname); diff != "" {
|
||||
t.Errorf("RedirectURLHostname mismatch (-want +got):\n%s", diff)
|
||||
}
|
||||
if diff := cmp.Diff(o.AuthRequestExtraParams, in.AuthRequestExtraParams); diff != "" {
|
||||
t.Errorf("AuthRequestExtraParams mismatch (-want +got):\n%s", diff)
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ const keyboardPrompt = "Enter code: "
|
||||
|
||||
type KeyboardOption struct {
|
||||
AuthRequestExtraParams map[string]string
|
||||
RedirectURL string
|
||||
}
|
||||
|
||||
// Keyboard provides the authorization code flow with keyboard interactive.
|
||||
@@ -42,7 +41,6 @@ func (u *Keyboard) Do(ctx context.Context, o *KeyboardOption, oidcClient client.
|
||||
State: state,
|
||||
Nonce: nonce,
|
||||
PKCEParams: pkceParams,
|
||||
RedirectURI: o.RedirectURL,
|
||||
AuthRequestExtraParams: o.AuthRequestExtraParams,
|
||||
})
|
||||
u.Logger.Printf("Please visit the following URL in your browser: %s", authCodeURL)
|
||||
@@ -53,10 +51,9 @@ func (u *Keyboard) Do(ctx context.Context, o *KeyboardOption, oidcClient client.
|
||||
|
||||
u.Logger.V(1).Infof("exchanging the code and token")
|
||||
tokenSet, err := oidcClient.ExchangeAuthCode(ctx, client.ExchangeAuthCodeInput{
|
||||
Code: code,
|
||||
PKCEParams: pkceParams,
|
||||
Nonce: nonce,
|
||||
RedirectURI: o.RedirectURL,
|
||||
Code: code,
|
||||
PKCEParams: pkceParams,
|
||||
Nonce: nonce,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not exchange the authorization code: %w", err)
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/int128/kubelogin/pkg/oidc/client"
|
||||
"github.com/int128/kubelogin/pkg/tlsclientconfig"
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication/authcode"
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication/clientcredentials"
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication/devicecode"
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication/ropc"
|
||||
)
|
||||
@@ -22,6 +23,7 @@ var Set = wire.NewSet(
|
||||
wire.Struct(new(authcode.Keyboard), "*"),
|
||||
wire.Struct(new(ropc.ROPC), "*"),
|
||||
wire.Struct(new(devicecode.DeviceCode), "*"),
|
||||
wire.Struct(new(clientcredentials.ClientCredentials), "*"),
|
||||
)
|
||||
|
||||
type Interface interface {
|
||||
@@ -37,10 +39,11 @@ type Input struct {
|
||||
}
|
||||
|
||||
type GrantOptionSet struct {
|
||||
AuthCodeBrowserOption *authcode.BrowserOption
|
||||
AuthCodeKeyboardOption *authcode.KeyboardOption
|
||||
ROPCOption *ropc.Option
|
||||
DeviceCodeOption *devicecode.Option
|
||||
AuthCodeBrowserOption *authcode.BrowserOption
|
||||
AuthCodeKeyboardOption *authcode.KeyboardOption
|
||||
ROPCOption *ropc.Option
|
||||
DeviceCodeOption *devicecode.Option
|
||||
ClientCredentialsOption *client.GetTokenByClientCredentialsInput
|
||||
}
|
||||
|
||||
// Output represents an output DTO of the Authentication use-case.
|
||||
@@ -52,7 +55,7 @@ type Output struct {
|
||||
//
|
||||
// If the IDToken is not set, it performs the authentication flow.
|
||||
// If the IDToken is valid, it does nothing.
|
||||
// If the IDtoken has expired and the RefreshToken is set, it refreshes the token.
|
||||
// If the IDToken has expired and the RefreshToken is set, it refreshes the token.
|
||||
// If the RefreshToken has expired, it performs the authentication flow.
|
||||
//
|
||||
// The authentication flow is determined as:
|
||||
@@ -61,12 +64,13 @@ type Output struct {
|
||||
// Otherwise, it performs the resource owner password credentials flow.
|
||||
// If the Password is not set, it asks a password by the prompt.
|
||||
type Authentication struct {
|
||||
ClientFactory client.FactoryInterface
|
||||
Logger logger.Interface
|
||||
AuthCodeBrowser *authcode.Browser
|
||||
AuthCodeKeyboard *authcode.Keyboard
|
||||
ROPC *ropc.ROPC
|
||||
DeviceCode *devicecode.DeviceCode
|
||||
ClientFactory client.FactoryInterface
|
||||
Logger logger.Interface
|
||||
AuthCodeBrowser *authcode.Browser
|
||||
AuthCodeKeyboard *authcode.Keyboard
|
||||
ROPC *ropc.ROPC
|
||||
DeviceCode *devicecode.DeviceCode
|
||||
ClientCredentials *clientcredentials.ClientCredentials
|
||||
}
|
||||
|
||||
func (u *Authentication) Do(ctx context.Context, in Input) (*Output, error) {
|
||||
@@ -113,5 +117,12 @@ func (u *Authentication) Do(ctx context.Context, in Input) (*Output, error) {
|
||||
}
|
||||
return &Output{TokenSet: *tokenSet}, nil
|
||||
}
|
||||
if in.GrantOptionSet.ClientCredentialsOption != nil {
|
||||
tokenSet, err := u.ClientCredentials.Do(ctx, in.GrantOptionSet.ClientCredentialsOption, oidcClient)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("client-credentials error: %w", err)
|
||||
}
|
||||
return &Output{TokenSet: *tokenSet}, nil
|
||||
}
|
||||
return nil, fmt.Errorf("any authorization grant must be set")
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
testingLogger "github.com/int128/kubelogin/pkg/testing/logger"
|
||||
"github.com/int128/kubelogin/pkg/tlsclientconfig"
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication/authcode"
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication/clientcredentials"
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication/ropc"
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
@@ -181,4 +182,45 @@ func TestAuthentication_Do(t *testing.T) {
|
||||
t.Errorf("mismatch (-want +got):\n%s", diff)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("NoToken/ClientCredentials", func(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), timeout)
|
||||
defer cancel()
|
||||
ccIn := client.GetTokenByClientCredentialsInput{
|
||||
EndpointParams: map[string][]string{
|
||||
"audience": []string{"gopher://myaud"},
|
||||
},
|
||||
}
|
||||
in := Input{Provider: dummyProvider,
|
||||
TLSClientConfig: dummyTLSClientConfig,
|
||||
GrantOptionSet: GrantOptionSet{ClientCredentialsOption: &ccIn}}
|
||||
testToken := &oidc.TokenSet{IDToken: "TEST_ID_TOKEN"}
|
||||
mockClient := client_mock.NewMockInterface(t)
|
||||
mockClient.EXPECT().
|
||||
GetTokenByClientCredentials(ctx, ccIn).Return(testToken, nil).Once()
|
||||
|
||||
mockClientFactory := client_mock.NewMockFactoryInterface(t)
|
||||
mockClientFactory.EXPECT().
|
||||
New(ctx, dummyProvider, dummyTLSClientConfig).
|
||||
Return(mockClient, nil)
|
||||
u := Authentication{
|
||||
ClientFactory: mockClientFactory,
|
||||
Logger: testingLogger.New(t),
|
||||
ClientCredentials: &clientcredentials.ClientCredentials{
|
||||
Logger: testingLogger.New(t),
|
||||
},
|
||||
}
|
||||
got, err := u.Do(ctx, in)
|
||||
if err != nil {
|
||||
t.Errorf("Do returned error: %+v", err)
|
||||
}
|
||||
want := &Output{
|
||||
TokenSet: oidc.TokenSet{
|
||||
IDToken: "TEST_ID_TOKEN",
|
||||
},
|
||||
}
|
||||
if diff := cmp.Diff(want, got); diff != "" {
|
||||
t.Errorf("mismatch (-want +got):\n%s", diff)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package clientcredentials
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/int128/kubelogin/pkg/infrastructure/logger"
|
||||
"github.com/int128/kubelogin/pkg/oidc"
|
||||
"github.com/int128/kubelogin/pkg/oidc/client"
|
||||
)
|
||||
|
||||
// DeviceCode provides the oauth2 device code flow.
|
||||
type ClientCredentials struct {
|
||||
Logger logger.Interface
|
||||
}
|
||||
|
||||
func (u *ClientCredentials) Do(ctx context.Context, in *client.GetTokenByClientCredentialsInput, oidcClient client.Interface) (*oidc.TokenSet, error) {
|
||||
u.Logger.V(1).Infof("starting the oauth2 client credentials code flow")
|
||||
if in == nil {
|
||||
return nil, fmt.Errorf("nil input")
|
||||
}
|
||||
tokenSet, err := oidcClient.GetTokenByClientCredentials(ctx, *in)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("authorization error: %w", err)
|
||||
}
|
||||
u.Logger.V(1).Infof("finished the oauth2 client credentials code flow")
|
||||
return tokenSet, nil
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package clientcredentials
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/int128/kubelogin/mocks/github.com/int128/kubelogin/pkg/oidc/client_mock"
|
||||
"github.com/int128/kubelogin/pkg/oidc"
|
||||
"github.com/int128/kubelogin/pkg/oidc/client"
|
||||
"github.com/int128/kubelogin/pkg/testing/logger"
|
||||
)
|
||||
|
||||
func TestClientCredentials(t *testing.T) {
|
||||
ctx := context.TODO()
|
||||
|
||||
t.Run("Authorization error", func(t *testing.T) {
|
||||
mockClient := client_mock.NewMockInterface(t)
|
||||
cc := &ClientCredentials{
|
||||
Logger: logger.New(t),
|
||||
}
|
||||
errTest := errors.New("make sure Do() passes err")
|
||||
in := client.GetTokenByClientCredentialsInput{}
|
||||
mockClient.EXPECT().GetTokenByClientCredentials(ctx, in).Return(nil, errTest).Once()
|
||||
opts := client.GetTokenByClientCredentialsInput{}
|
||||
_, err := cc.Do(ctx, &opts, mockClient)
|
||||
if !errors.Is(err, errTest) {
|
||||
t.Errorf("returned error is not the test error: %v", err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Server returns access_token", func(t *testing.T) {
|
||||
mockClient := client_mock.NewMockInterface(t)
|
||||
cc := &ClientCredentials{
|
||||
Logger: logger.New(t),
|
||||
}
|
||||
in := client.GetTokenByClientCredentialsInput{}
|
||||
testToken := &oidc.TokenSet{}
|
||||
mockClient.EXPECT().GetTokenByClientCredentials(ctx, in).Return(testToken, nil).Once()
|
||||
opts := client.GetTokenByClientCredentialsInput{}
|
||||
ts, err := cc.Do(ctx, &opts, mockClient)
|
||||
if err != nil {
|
||||
t.Errorf("returned unexpected error: %v", err)
|
||||
}
|
||||
if ts != testToken {
|
||||
t.Errorf("returned unexpected token set: %v", ts)
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
@@ -21,7 +21,7 @@ type Interface interface {
|
||||
|
||||
// Input represents an input of the Clean use-case.
|
||||
type Input struct {
|
||||
TokenCacheConfig tokencache.Config
|
||||
TokenCacheDir string
|
||||
}
|
||||
|
||||
type Clean struct {
|
||||
@@ -31,8 +31,17 @@ type Clean struct {
|
||||
|
||||
func (u *Clean) Do(ctx context.Context, in Input) error {
|
||||
u.Logger.V(1).Infof("Deleting the token cache")
|
||||
if err := u.TokenCacheRepository.DeleteAll(in.TokenCacheConfig); err != nil {
|
||||
return fmt.Errorf("delete the token cache: %w", err)
|
||||
|
||||
if err := u.TokenCacheRepository.DeleteAll(tokencache.Config{Directory: in.TokenCacheDir, Storage: tokencache.StorageDisk}); err != nil {
|
||||
return fmt.Errorf("delete the token cache from %s: %w", in.TokenCacheDir, err)
|
||||
}
|
||||
u.Logger.Printf("Deleted the token cache from %s", in.TokenCacheDir)
|
||||
|
||||
if err := u.TokenCacheRepository.DeleteAll(tokencache.Config{Directory: in.TokenCacheDir, Storage: tokencache.StorageKeyring}); err != nil {
|
||||
// Do not return an error because the keyring may not be available.
|
||||
u.Logger.Printf("Could not delete the token cache from the keyring: %s", err)
|
||||
} else {
|
||||
u.Logger.Printf("Deleted the token cache from the keyring")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -112,6 +112,63 @@ func TestGetToken_Do(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("TokenCacheNoneReturnsNone", func(t *testing.T) {
|
||||
tokenCacheKey := tokencache.Key{
|
||||
Provider: oidc.Provider{
|
||||
IssuerURL: "https://accounts.google.com",
|
||||
ClientID: "YOUR_CLIENT_ID",
|
||||
ClientSecret: "YOUR_CLIENT_SECRET",
|
||||
},
|
||||
}
|
||||
ctx := context.TODO()
|
||||
in := Input{
|
||||
Provider: dummyProvider,
|
||||
TokenCacheConfig: tokencache.Config{
|
||||
Storage: tokencache.StorageNone,
|
||||
},
|
||||
GrantOptionSet: grantOptionSet,
|
||||
}
|
||||
mockAuthentication := authentication_mock.NewMockInterface(t)
|
||||
mockAuthentication.EXPECT().
|
||||
Do(ctx, authentication.Input{
|
||||
Provider: dummyProvider,
|
||||
GrantOptionSet: grantOptionSet,
|
||||
}).
|
||||
Return(&authentication.Output{TokenSet: issuedTokenSet}, nil)
|
||||
mockCloser := io_mock.NewMockCloser(t)
|
||||
mockCloser.EXPECT().
|
||||
Close().
|
||||
Return(nil)
|
||||
mockRepository := repository_mock.NewMockInterface(t)
|
||||
mockRepository.EXPECT().
|
||||
Lock(in.TokenCacheConfig, tokenCacheKey).
|
||||
Return(mockCloser, nil)
|
||||
mockRepository.EXPECT().
|
||||
FindByKey(in.TokenCacheConfig, tokenCacheKey).
|
||||
Return(nil, nil)
|
||||
mockRepository.EXPECT().
|
||||
Save(in.TokenCacheConfig, tokenCacheKey, issuedTokenSet).
|
||||
Return(nil)
|
||||
mockReader := reader_mock.NewMockInterface(t)
|
||||
mockReader.EXPECT().
|
||||
Read().
|
||||
Return(credentialpluginInput, nil)
|
||||
mockWriter := writer_mock.NewMockInterface(t)
|
||||
mockWriter.EXPECT().
|
||||
Write(issuedOutput).
|
||||
Return(nil)
|
||||
u := GetToken{
|
||||
Authentication: mockAuthentication,
|
||||
TokenCacheRepository: mockRepository,
|
||||
CredentialPluginReader: mockReader,
|
||||
CredentialPluginWriter: mockWriter,
|
||||
Logger: logger.New(t),
|
||||
Clock: clock.Fake(expiryTime.Add(-time.Hour)),
|
||||
}
|
||||
if err := u.Do(ctx, in); err != nil {
|
||||
t.Errorf("Do returned error: %+v", err)
|
||||
}
|
||||
})
|
||||
t.Run("ROPC", func(t *testing.T) {
|
||||
grantOptionSet := authentication.GrantOptionSet{
|
||||
ROPCOption: &ropc.Option{Username: "YOUR_USERNAME"},
|
||||
|
||||
@@ -3,9 +3,17 @@ package setup
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
_ "embed"
|
||||
|
||||
"github.com/google/wire"
|
||||
"github.com/int128/kubelogin/pkg/infrastructure/logger"
|
||||
"github.com/int128/kubelogin/pkg/oidc"
|
||||
"github.com/int128/kubelogin/pkg/tlsclientconfig"
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication"
|
||||
)
|
||||
|
||||
@@ -15,11 +23,66 @@ var Set = wire.NewSet(
|
||||
)
|
||||
|
||||
type Interface interface {
|
||||
DoStage1()
|
||||
DoStage2(ctx context.Context, in Stage2Input) error
|
||||
Do(ctx context.Context, in Input) error
|
||||
}
|
||||
|
||||
type Setup struct {
|
||||
Authentication authentication.Interface
|
||||
Logger logger.Interface
|
||||
}
|
||||
|
||||
//go:embed setup.md
|
||||
var setupMarkdown string
|
||||
|
||||
var setupTemplate = template.Must(template.New("setup.md").Funcs(template.FuncMap{
|
||||
"quote": strconv.Quote,
|
||||
}).Parse(setupMarkdown))
|
||||
|
||||
type Input struct {
|
||||
IssuerURL string
|
||||
ClientID string
|
||||
ClientSecret string
|
||||
RedirectURL string
|
||||
ExtraScopes []string
|
||||
UseAccessToken bool
|
||||
RequestHeaders map[string]string
|
||||
PKCEMethod oidc.PKCEMethod
|
||||
GrantOptionSet authentication.GrantOptionSet
|
||||
TLSClientConfig tlsclientconfig.Config
|
||||
ChangedFlags []string
|
||||
}
|
||||
|
||||
func (u Setup) Do(ctx context.Context, in Input) error {
|
||||
u.Logger.Printf("Authentication in progress...")
|
||||
out, err := u.Authentication.Do(ctx, authentication.Input{
|
||||
Provider: oidc.Provider{
|
||||
IssuerURL: in.IssuerURL,
|
||||
ClientID: in.ClientID,
|
||||
ClientSecret: in.ClientSecret,
|
||||
RedirectURL: in.RedirectURL,
|
||||
ExtraScopes: in.ExtraScopes,
|
||||
PKCEMethod: in.PKCEMethod,
|
||||
UseAccessToken: in.UseAccessToken,
|
||||
RequestHeaders: in.RequestHeaders,
|
||||
},
|
||||
GrantOptionSet: in.GrantOptionSet,
|
||||
TLSClientConfig: in.TLSClientConfig,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("authentication error: %w", err)
|
||||
}
|
||||
idTokenClaims, err := out.TokenSet.DecodeWithoutVerify()
|
||||
if err != nil {
|
||||
return fmt.Errorf("you got an invalid token: %w", err)
|
||||
}
|
||||
|
||||
var b strings.Builder
|
||||
if err := setupTemplate.Execute(&b, map[string]any{
|
||||
"IDTokenPrettyJSON": idTokenClaims.Pretty,
|
||||
"Flags": in.ChangedFlags,
|
||||
}); err != nil {
|
||||
return fmt.Errorf("render the template: %w", err)
|
||||
}
|
||||
u.Logger.Printf(b.String())
|
||||
return nil
|
||||
}
|
||||
|
||||
24
pkg/usecases/setup/setup.md
Normal file
24
pkg/usecases/setup/setup.md
Normal file
@@ -0,0 +1,24 @@
|
||||
## Authenticated with the OpenID Connect Provider
|
||||
|
||||
You got the token with the following claims:
|
||||
|
||||
```
|
||||
{{ .IDTokenPrettyJSON }}
|
||||
```
|
||||
|
||||
## Set up the kubeconfig
|
||||
|
||||
You can run the following command to set up the kubeconfig:
|
||||
|
||||
```
|
||||
kubectl config set-credentials oidc \
|
||||
--exec-api-version=client.authentication.k8s.io/v1 \
|
||||
--exec-interactive-mode=Never \
|
||||
--exec-command=kubectl \
|
||||
--exec-arg=oidc-login \
|
||||
--exec-arg=get-token \
|
||||
{{- range $index, $flag := .Flags }}
|
||||
{{- if $index}} \{{end}}
|
||||
--exec-arg={{ $flag | quote }}
|
||||
{{- end }}
|
||||
```
|
||||
66
pkg/usecases/setup/setup_test.go
Normal file
66
pkg/usecases/setup/setup_test.go
Normal file
@@ -0,0 +1,66 @@
|
||||
package setup
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
"github.com/int128/kubelogin/mocks/github.com/int128/kubelogin/pkg/usecases/authentication_mock"
|
||||
"github.com/int128/kubelogin/pkg/oidc"
|
||||
testingJWT "github.com/int128/kubelogin/pkg/testing/jwt"
|
||||
"github.com/int128/kubelogin/pkg/testing/logger"
|
||||
"github.com/int128/kubelogin/pkg/tlsclientconfig"
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication"
|
||||
)
|
||||
|
||||
func TestSetup_Do(t *testing.T) {
|
||||
issuedIDToken := testingJWT.EncodeF(t, func(claims *testingJWT.Claims) {
|
||||
claims.Issuer = "https://issuer.example.com"
|
||||
claims.Subject = "YOUR_SUBJECT"
|
||||
claims.ExpiresAt = jwt.NewNumericDate(time.Now().Add(1 * time.Hour))
|
||||
})
|
||||
dummyTLSClientConfig := tlsclientconfig.Config{
|
||||
CACertFilename: []string{"/path/to/cert"},
|
||||
}
|
||||
var grantOptionSet authentication.GrantOptionSet
|
||||
|
||||
ctx := context.Background()
|
||||
in := Input{
|
||||
IssuerURL: "https://accounts.google.com",
|
||||
ClientID: "YOUR_CLIENT_ID",
|
||||
ClientSecret: "YOUR_CLIENT_SECRET",
|
||||
ExtraScopes: []string{"email"},
|
||||
GrantOptionSet: grantOptionSet,
|
||||
TLSClientConfig: dummyTLSClientConfig,
|
||||
ChangedFlags: []string{
|
||||
"--oidc-issuer-url=https://accounts.google.com",
|
||||
"--oidc-client-id=YOUR_CLIENT_ID",
|
||||
},
|
||||
}
|
||||
mockAuthentication := authentication_mock.NewMockInterface(t)
|
||||
mockAuthentication.EXPECT().
|
||||
Do(ctx, authentication.Input{
|
||||
Provider: oidc.Provider{
|
||||
IssuerURL: "https://accounts.google.com",
|
||||
ClientID: "YOUR_CLIENT_ID",
|
||||
ClientSecret: "YOUR_CLIENT_SECRET",
|
||||
ExtraScopes: []string{"email"},
|
||||
},
|
||||
GrantOptionSet: grantOptionSet,
|
||||
TLSClientConfig: dummyTLSClientConfig,
|
||||
}).
|
||||
Return(&authentication.Output{
|
||||
TokenSet: oidc.TokenSet{
|
||||
IDToken: issuedIDToken,
|
||||
RefreshToken: "YOUR_REFRESH_TOKEN",
|
||||
},
|
||||
}, nil)
|
||||
u := Setup{
|
||||
Authentication: mockAuthentication,
|
||||
Logger: logger.New(t),
|
||||
}
|
||||
if err := u.Do(ctx, in); err != nil {
|
||||
t.Errorf("Do returned error: %+v", err)
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package setup
|
||||
|
||||
const stage1 = `This setup shows the instruction of Kubernetes OpenID Connect authentication.
|
||||
See also https://github.com/int128/kubelogin.
|
||||
|
||||
## 1. Set up the OpenID Connect Provider
|
||||
|
||||
Open the OpenID Connect Provider and create a client.
|
||||
|
||||
For example, Google Identity Platform:
|
||||
Open https://console.developers.google.com/apis/credentials and create an OAuth client of "Other" type.
|
||||
ISSUER is https://accounts.google.com
|
||||
|
||||
## 2. Verify authentication
|
||||
|
||||
Run the following command to proceed.
|
||||
|
||||
kubectl oidc-login setup \
|
||||
--oidc-issuer-url=ISSUER \
|
||||
--oidc-client-id=YOUR_CLIENT_ID \
|
||||
--oidc-client-secret=YOUR_CLIENT_SECRET
|
||||
|
||||
You can set your CA certificate. See also the options by --help.
|
||||
`
|
||||
|
||||
func (u *Setup) DoStage1() {
|
||||
u.Logger.Printf(stage1)
|
||||
}
|
||||
@@ -1,178 +0,0 @@
|
||||
package setup
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
"github.com/int128/kubelogin/pkg/oidc"
|
||||
"github.com/int128/kubelogin/pkg/tlsclientconfig"
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication"
|
||||
)
|
||||
|
||||
var stage2Tpl = template.Must(template.New("").Parse(`
|
||||
## 2. Verify authentication
|
||||
|
||||
You got a token with the following claims:
|
||||
|
||||
{{ .IDTokenPrettyJSON }}
|
||||
|
||||
## 3. Bind a cluster role
|
||||
|
||||
Run the following command:
|
||||
|
||||
kubectl create clusterrolebinding oidc-cluster-admin --clusterrole=cluster-admin --user='{{ .IssuerURL }}#{{ .Subject }}'
|
||||
|
||||
## 4. Set up the Kubernetes API server
|
||||
|
||||
Add the following options to the kube-apiserver:
|
||||
|
||||
--oidc-issuer-url={{ .IssuerURL }}
|
||||
--oidc-client-id={{ .ClientID }}
|
||||
|
||||
## 5. Set up the kubeconfig
|
||||
|
||||
Run the following command:
|
||||
|
||||
kubectl config set-credentials oidc \
|
||||
--exec-api-version=client.authentication.k8s.io/v1 \
|
||||
--exec-command=kubectl \
|
||||
--exec-arg=oidc-login \
|
||||
--exec-arg=get-token \
|
||||
{{- range $index, $arg := .Args }}
|
||||
{{- if $index}} \{{end}}
|
||||
--exec-arg={{ $arg }}
|
||||
{{- end }}
|
||||
|
||||
## 6. Verify cluster access
|
||||
|
||||
Make sure you can access the Kubernetes cluster.
|
||||
|
||||
kubectl --user=oidc get nodes
|
||||
|
||||
You can switch the default context to oidc.
|
||||
|
||||
kubectl config set-context --current --user=oidc
|
||||
|
||||
You can share the kubeconfig to your team members for on-boarding.
|
||||
`))
|
||||
|
||||
type stage2Vars struct {
|
||||
IDTokenPrettyJSON string
|
||||
IssuerURL string
|
||||
ClientID string
|
||||
Args []string
|
||||
Subject string
|
||||
}
|
||||
|
||||
// Stage2Input represents an input DTO of the stage2.
|
||||
type Stage2Input struct {
|
||||
IssuerURL string
|
||||
ClientID string
|
||||
ClientSecret string
|
||||
ExtraScopes []string // optional
|
||||
UseAccessToken bool // optional
|
||||
ListenAddressArgs []string // non-nil if set by the command arg
|
||||
PKCEMethod oidc.PKCEMethod
|
||||
PKCEMethodArg string
|
||||
GrantOptionSet authentication.GrantOptionSet
|
||||
TLSClientConfig tlsclientconfig.Config
|
||||
}
|
||||
|
||||
func (u *Setup) DoStage2(ctx context.Context, in Stage2Input) error {
|
||||
u.Logger.Printf("authentication in progress...")
|
||||
out, err := u.Authentication.Do(ctx, authentication.Input{
|
||||
Provider: oidc.Provider{
|
||||
IssuerURL: in.IssuerURL,
|
||||
ClientID: in.ClientID,
|
||||
ClientSecret: in.ClientSecret,
|
||||
ExtraScopes: in.ExtraScopes,
|
||||
PKCEMethod: in.PKCEMethod,
|
||||
UseAccessToken: in.UseAccessToken,
|
||||
},
|
||||
GrantOptionSet: in.GrantOptionSet,
|
||||
TLSClientConfig: in.TLSClientConfig,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("authentication error: %w", err)
|
||||
}
|
||||
idTokenClaims, err := out.TokenSet.DecodeWithoutVerify()
|
||||
if err != nil {
|
||||
return fmt.Errorf("you got an invalid token: %w", err)
|
||||
}
|
||||
|
||||
v := stage2Vars{
|
||||
IDTokenPrettyJSON: idTokenClaims.Pretty,
|
||||
IssuerURL: in.IssuerURL,
|
||||
ClientID: in.ClientID,
|
||||
Args: makeCredentialPluginArgs(in),
|
||||
Subject: idTokenClaims.Subject,
|
||||
}
|
||||
var b strings.Builder
|
||||
if err := stage2Tpl.Execute(&b, &v); err != nil {
|
||||
return fmt.Errorf("could not render the template: %w", err)
|
||||
}
|
||||
u.Logger.Printf(b.String())
|
||||
return nil
|
||||
}
|
||||
|
||||
func makeCredentialPluginArgs(in Stage2Input) []string {
|
||||
var args []string
|
||||
args = append(args, "--oidc-issuer-url="+in.IssuerURL)
|
||||
args = append(args, "--oidc-client-id="+in.ClientID)
|
||||
if in.ClientSecret != "" {
|
||||
args = append(args, "--oidc-client-secret="+in.ClientSecret)
|
||||
}
|
||||
for _, extraScope := range in.ExtraScopes {
|
||||
args = append(args, "--oidc-extra-scope="+extraScope)
|
||||
}
|
||||
if in.PKCEMethodArg != "" {
|
||||
args = append(args, "--oidc-pkce-method="+in.PKCEMethodArg)
|
||||
}
|
||||
if in.UseAccessToken {
|
||||
args = append(args, "--oidc-use-access-token")
|
||||
}
|
||||
for _, f := range in.TLSClientConfig.CACertFilename {
|
||||
args = append(args, "--certificate-authority="+f)
|
||||
}
|
||||
for _, d := range in.TLSClientConfig.CACertData {
|
||||
args = append(args, "--certificate-authority-data="+d)
|
||||
}
|
||||
if in.TLSClientConfig.SkipTLSVerify {
|
||||
args = append(args, "--insecure-skip-tls-verify")
|
||||
}
|
||||
|
||||
if in.GrantOptionSet.AuthCodeBrowserOption != nil {
|
||||
if in.GrantOptionSet.AuthCodeBrowserOption.SkipOpenBrowser {
|
||||
args = append(args, "--skip-open-browser")
|
||||
}
|
||||
if in.GrantOptionSet.AuthCodeBrowserOption.BrowserCommand != "" {
|
||||
args = append(args, "--browser-command="+in.GrantOptionSet.AuthCodeBrowserOption.BrowserCommand)
|
||||
}
|
||||
if in.GrantOptionSet.AuthCodeBrowserOption.LocalServerCertFile != "" {
|
||||
// Resolve the absolute path for the cert files so the user doesn't have to know
|
||||
// to use one when running setup.
|
||||
certpath, err := filepath.Abs(in.GrantOptionSet.AuthCodeBrowserOption.LocalServerCertFile)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
keypath, err := filepath.Abs(in.GrantOptionSet.AuthCodeBrowserOption.LocalServerKeyFile)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
args = append(args, "--local-server-cert="+certpath)
|
||||
args = append(args, "--local-server-key="+keypath)
|
||||
}
|
||||
}
|
||||
for _, l := range in.ListenAddressArgs {
|
||||
args = append(args, "--listen-address="+l)
|
||||
}
|
||||
if in.GrantOptionSet.ROPCOption != nil {
|
||||
if in.GrantOptionSet.ROPCOption.Username != "" {
|
||||
args = append(args, "--username="+in.GrantOptionSet.ROPCOption.Username)
|
||||
}
|
||||
}
|
||||
return args
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
package setup
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
"github.com/int128/kubelogin/mocks/github.com/int128/kubelogin/pkg/usecases/authentication_mock"
|
||||
"github.com/int128/kubelogin/pkg/oidc"
|
||||
testingJWT "github.com/int128/kubelogin/pkg/testing/jwt"
|
||||
"github.com/int128/kubelogin/pkg/testing/logger"
|
||||
"github.com/int128/kubelogin/pkg/tlsclientconfig"
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication"
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication/authcode"
|
||||
"github.com/int128/kubelogin/pkg/usecases/authentication/ropc"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestSetup_DoStage2(t *testing.T) {
|
||||
issuedIDToken := testingJWT.EncodeF(t, func(claims *testingJWT.Claims) {
|
||||
claims.Issuer = "https://issuer.example.com"
|
||||
claims.Subject = "YOUR_SUBJECT"
|
||||
claims.ExpiresAt = jwt.NewNumericDate(time.Now().Add(1 * time.Hour))
|
||||
})
|
||||
dummyTLSClientConfig := tlsclientconfig.Config{
|
||||
CACertFilename: []string{"/path/to/cert"},
|
||||
}
|
||||
var grantOptionSet authentication.GrantOptionSet
|
||||
|
||||
ctx := context.Background()
|
||||
in := Stage2Input{
|
||||
IssuerURL: "https://accounts.google.com",
|
||||
ClientID: "YOUR_CLIENT_ID",
|
||||
ClientSecret: "YOUR_CLIENT_SECRET",
|
||||
ExtraScopes: []string{"email"},
|
||||
GrantOptionSet: grantOptionSet,
|
||||
TLSClientConfig: dummyTLSClientConfig,
|
||||
}
|
||||
mockAuthentication := authentication_mock.NewMockInterface(t)
|
||||
mockAuthentication.EXPECT().
|
||||
Do(ctx, authentication.Input{
|
||||
Provider: oidc.Provider{
|
||||
IssuerURL: "https://accounts.google.com",
|
||||
ClientID: "YOUR_CLIENT_ID",
|
||||
ClientSecret: "YOUR_CLIENT_SECRET",
|
||||
ExtraScopes: []string{"email"},
|
||||
},
|
||||
GrantOptionSet: grantOptionSet,
|
||||
TLSClientConfig: dummyTLSClientConfig,
|
||||
}).
|
||||
Return(&authentication.Output{
|
||||
TokenSet: oidc.TokenSet{
|
||||
IDToken: issuedIDToken,
|
||||
RefreshToken: "YOUR_REFRESH_TOKEN",
|
||||
},
|
||||
}, nil)
|
||||
u := Setup{
|
||||
Authentication: mockAuthentication,
|
||||
Logger: logger.New(t),
|
||||
}
|
||||
if err := u.DoStage2(ctx, in); err != nil {
|
||||
t.Errorf("DoStage2 returned error: %+v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func Test_makeCredentialPluginArgs(t *testing.T) {
|
||||
in := Stage2Input{
|
||||
IssuerURL: "https://oidc.example.com",
|
||||
ClientID: "test_kid",
|
||||
ClientSecret: "test_ksecret",
|
||||
ExtraScopes: []string{"groups"},
|
||||
PKCEMethodArg: "S256",
|
||||
ListenAddressArgs: []string{"127.0.0.1:8080", "127.0.0.1:8888"},
|
||||
GrantOptionSet: authentication.GrantOptionSet{
|
||||
AuthCodeBrowserOption: &authcode.BrowserOption{
|
||||
SkipOpenBrowser: true,
|
||||
BrowserCommand: "firefox",
|
||||
LocalServerCertFile: "/path/to/cert.crt",
|
||||
LocalServerKeyFile: "/path/to/cert.key",
|
||||
},
|
||||
ROPCOption: &ropc.Option{
|
||||
Username: "user1",
|
||||
},
|
||||
},
|
||||
TLSClientConfig: tlsclientconfig.Config{
|
||||
CACertFilename: []string{"/path/to/ca.crt"},
|
||||
CACertData: []string{"base64encoded1"},
|
||||
SkipTLSVerify: true,
|
||||
},
|
||||
}
|
||||
expet := []string{
|
||||
"--oidc-issuer-url=https://oidc.example.com",
|
||||
"--oidc-client-id=test_kid",
|
||||
"--oidc-client-secret=test_ksecret",
|
||||
"--oidc-extra-scope=groups",
|
||||
"--oidc-pkce-method=S256",
|
||||
"--certificate-authority=/path/to/ca.crt",
|
||||
"--certificate-authority-data=base64encoded1",
|
||||
"--insecure-skip-tls-verify",
|
||||
"--skip-open-browser",
|
||||
"--browser-command=firefox",
|
||||
"--local-server-cert=/path/to/cert.crt",
|
||||
"--local-server-key=/path/to/cert.key",
|
||||
"--listen-address=127.0.0.1:8080",
|
||||
"--listen-address=127.0.0.1:8888",
|
||||
"--username=user1",
|
||||
}
|
||||
got := makeCredentialPluginArgs(in)
|
||||
assert.Equal(t, expet, got)
|
||||
}
|
||||
@@ -2,12 +2,11 @@
|
||||
|
||||
This is an automated test for verifying behavior of the plugin with a real Kubernetes cluster and OIDC provider.
|
||||
|
||||
|
||||
## Purpose
|
||||
|
||||
This test checks the following points:
|
||||
|
||||
1. User can set up Kubernetes OIDC authentication using [setup guide](../docs/setup.md).
|
||||
1. User can set up Kubernetes OIDC authentication using the [setup guide](../docs/setup.md).
|
||||
1. User can log in to an OIDC provider on a browser.
|
||||
1. User can access the cluster using a token returned from the plugin.
|
||||
|
||||
@@ -18,7 +17,6 @@ It depends on the following components:
|
||||
- Browser (Chrome)
|
||||
- kubectl command
|
||||
|
||||
|
||||
## How it works
|
||||
|
||||
Let's take a look at the diagram.
|
||||
@@ -45,7 +43,6 @@ It performs the test by the following steps:
|
||||
1. kube-apiserver verifies the token by Dex.
|
||||
1. Check if kubectl exited with code 0.
|
||||
|
||||
|
||||
## Run locally
|
||||
|
||||
You need to set up the following components:
|
||||
@@ -80,7 +77,6 @@ make terminate
|
||||
make clean
|
||||
```
|
||||
|
||||
|
||||
## Technical consideration
|
||||
|
||||
### Network and DNS
|
||||
|
||||
@@ -8,13 +8,16 @@ export KUBECONFIG
|
||||
cluster:
|
||||
cp $(CERT_DIR)/ca.crt /tmp/kubelogin-system-test-dex-ca.crt
|
||||
kind create cluster --name $(CLUSTER_NAME) --config cluster.yaml
|
||||
# add the Dex container IP to /etc/hosts
|
||||
|
||||
# Add the Dex container IP to /etc/hosts.
|
||||
docker inspect -f '{{.NetworkSettings.Networks.kind.IPAddress}}' dex-server | sed -e 's,$$, dex-server,' | \
|
||||
docker exec -i $(CLUSTER_NAME)-control-plane tee -a /etc/hosts
|
||||
# wait for kube-apiserver oidc initialization
|
||||
# (oidc authenticator will retry oidc discovery every 10s)
|
||||
|
||||
# Wait for kube-apiserver oidc initialization.
|
||||
# oidc authenticator will retry oidc discovery every 10s.
|
||||
sleep 10
|
||||
# add the cluster role
|
||||
|
||||
# Add the cluster role.
|
||||
kubectl create clusterrole cluster-readonly --verb=get,watch,list --resource='*.*'
|
||||
kubectl create clusterrolebinding cluster-readonly --clusterrole=cluster-readonly --user=admin@example.com
|
||||
|
||||
|
||||
@@ -2,15 +2,18 @@ CERT_DIR := ../cert
|
||||
|
||||
.PHONY: dex
|
||||
dex: dex.yaml
|
||||
# wait for kind network
|
||||
while true; do if docker network inspect kind; then break; fi; sleep 1; done
|
||||
# create a container
|
||||
# Wait for kind network.
|
||||
until docker network inspect kind; do sleep 1; done
|
||||
|
||||
# Create a container.
|
||||
docker create -q --name dex-server -p 10443:10443 --network kind ghcr.io/dexidp/dex:v2.39.0 dex serve /dex.yaml
|
||||
# deploy the config
|
||||
|
||||
# Deploy the config.
|
||||
docker cp $(CERT_DIR)/server.crt dex-server:/
|
||||
docker cp $(CERT_DIR)/server.key dex-server:/
|
||||
docker cp dex.yaml dex-server:/
|
||||
# start the container
|
||||
|
||||
# Start the container.
|
||||
docker start dex-server
|
||||
docker logs dex-server
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ test: build
|
||||
--exec-arg=--oidc-client-id=YOUR_CLIENT_ID \
|
||||
--exec-arg=--oidc-client-secret=YOUR_CLIENT_SECRET \
|
||||
--exec-arg=--oidc-extra-scope=email \
|
||||
--exec-arg=--token-cache-storage=keyring \
|
||||
--exec-arg=--certificate-authority=$(CERT_DIR)/ca.crt \
|
||||
--exec-arg=--browser-command=$(BIN_DIR)/chromelogin
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
GOBIN := $(CURDIR)/bin
|
||||
export GOBIN
|
||||
|
||||
all: bin/mockery bin/wire bin/golangci-lint
|
||||
|
||||
bin/mockery:
|
||||
go install github.com/vektra/mockery/v2
|
||||
|
||||
bin/wire:
|
||||
go install github.com/google/wire/cmd/wire
|
||||
|
||||
bin/golangci-lint:
|
||||
go install github.com/golangci/golangci-lint/cmd/golangci-lint
|
||||
205
tools/go.mod
205
tools/go.mod
@@ -1,205 +0,0 @@
|
||||
module github.com/int128/kubelogin/tools
|
||||
|
||||
go 1.23.5
|
||||
|
||||
require (
|
||||
github.com/golangci/golangci-lint v1.63.4
|
||||
github.com/google/wire v0.6.0
|
||||
github.com/vektra/mockery/v2 v2.51.0
|
||||
)
|
||||
|
||||
require (
|
||||
4d63.com/gocheckcompilerdirectives v1.2.1 // indirect
|
||||
4d63.com/gochecknoglobals v0.2.1 // indirect
|
||||
github.com/4meepo/tagalign v1.4.1 // indirect
|
||||
github.com/Abirdcfly/dupword v0.1.3 // indirect
|
||||
github.com/Antonboom/errname v1.0.0 // indirect
|
||||
github.com/Antonboom/nilnil v1.0.1 // indirect
|
||||
github.com/Antonboom/testifylint v1.5.2 // indirect
|
||||
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c // indirect
|
||||
github.com/Crocmagnon/fatcontext v0.5.3 // indirect
|
||||
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect
|
||||
github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.0 // indirect
|
||||
github.com/Masterminds/semver/v3 v3.3.0 // indirect
|
||||
github.com/OpenPeeDeeP/depguard/v2 v2.2.0 // indirect
|
||||
github.com/alecthomas/go-check-sumtype v0.3.1 // indirect
|
||||
github.com/alexkohler/nakedret/v2 v2.0.5 // indirect
|
||||
github.com/alexkohler/prealloc v1.0.0 // indirect
|
||||
github.com/alingse/asasalint v0.0.11 // indirect
|
||||
github.com/alingse/nilnesserr v0.1.1 // indirect
|
||||
github.com/ashanbrown/forbidigo v1.6.0 // indirect
|
||||
github.com/ashanbrown/makezero v1.2.0 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bkielbasa/cyclop v1.2.3 // indirect
|
||||
github.com/blizzy78/varnamelen v0.8.0 // indirect
|
||||
github.com/bombsimon/wsl/v4 v4.5.0 // indirect
|
||||
github.com/breml/bidichk v0.3.2 // indirect
|
||||
github.com/breml/errchkjson v0.4.0 // indirect
|
||||
github.com/butuzov/ireturn v0.3.1 // indirect
|
||||
github.com/butuzov/mirror v1.3.0 // indirect
|
||||
github.com/catenacyber/perfsprint v0.7.1 // indirect
|
||||
github.com/ccojocar/zxcvbn-go v1.0.2 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||
github.com/charithe/durationcheck v0.0.10 // indirect
|
||||
github.com/chavacava/garif v0.1.0 // indirect
|
||||
github.com/chigopher/pathlib v0.19.1 // indirect
|
||||
github.com/ckaznocha/intrange v0.3.0 // indirect
|
||||
github.com/curioswitch/go-reassign v0.3.0 // indirect
|
||||
github.com/daixiang0/gci v0.13.5 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/denis-tingaikin/go-header v0.5.0 // indirect
|
||||
github.com/ettle/strcase v0.2.0 // indirect
|
||||
github.com/fatih/color v1.18.0 // indirect
|
||||
github.com/fatih/structtag v1.2.0 // indirect
|
||||
github.com/firefart/nonamedreturns v1.0.5 // indirect
|
||||
github.com/fsnotify/fsnotify v1.6.0 // indirect
|
||||
github.com/fzipp/gocyclo v0.6.0 // indirect
|
||||
github.com/ghostiam/protogetter v0.3.8 // indirect
|
||||
github.com/go-critic/go-critic v0.11.5 // indirect
|
||||
github.com/go-toolsmith/astcast v1.1.0 // indirect
|
||||
github.com/go-toolsmith/astcopy v1.1.0 // indirect
|
||||
github.com/go-toolsmith/astequal v1.2.0 // indirect
|
||||
github.com/go-toolsmith/astfmt v1.1.0 // indirect
|
||||
github.com/go-toolsmith/astp v1.1.0 // indirect
|
||||
github.com/go-toolsmith/strparse v1.1.0 // indirect
|
||||
github.com/go-toolsmith/typep v1.1.0 // indirect
|
||||
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
|
||||
github.com/go-xmlfmt/xmlfmt v1.1.3 // indirect
|
||||
github.com/gobwas/glob v0.2.3 // indirect
|
||||
github.com/gofrs/flock v0.12.1 // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect
|
||||
github.com/golangci/go-printf-func-name v0.1.0 // indirect
|
||||
github.com/golangci/gofmt v0.0.0-20241223200906-057b0627d9b9 // indirect
|
||||
github.com/golangci/misspell v0.6.0 // indirect
|
||||
github.com/golangci/plugin-module-register v0.1.1 // indirect
|
||||
github.com/golangci/revgrep v0.5.3 // indirect
|
||||
github.com/golangci/unconvert v0.0.0-20240309020433-c5143eacb3ed // indirect
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
github.com/google/subcommands v1.2.0 // indirect
|
||||
github.com/gordonklaus/ineffassign v0.1.0 // indirect
|
||||
github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
|
||||
github.com/gostaticanalysis/comment v1.4.2 // indirect
|
||||
github.com/gostaticanalysis/forcetypeassert v0.1.0 // indirect
|
||||
github.com/gostaticanalysis/nilerr v0.1.1 // indirect
|
||||
github.com/hashicorp/go-immutable-radix/v2 v2.1.0 // indirect
|
||||
github.com/hashicorp/go-version v1.7.0 // indirect
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/hexops/gotextdiff v1.0.3 // indirect
|
||||
github.com/huandu/xstrings v1.4.0 // indirect
|
||||
github.com/iancoleman/strcase v0.2.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/jgautheron/goconst v1.7.1 // indirect
|
||||
github.com/jingyugao/rowserrcheck v1.1.1 // indirect
|
||||
github.com/jinzhu/copier v0.3.5 // indirect
|
||||
github.com/jjti/go-spancheck v0.6.4 // indirect
|
||||
github.com/julz/importas v0.2.0 // indirect
|
||||
github.com/karamaru-alpha/copyloopvar v1.1.0 // indirect
|
||||
github.com/kisielk/errcheck v1.8.0 // indirect
|
||||
github.com/kkHAIKE/contextcheck v1.1.5 // indirect
|
||||
github.com/kulti/thelper v0.6.3 // indirect
|
||||
github.com/kunwardeep/paralleltest v1.0.10 // indirect
|
||||
github.com/kyoh86/exportloopref v0.1.11 // indirect
|
||||
github.com/lasiar/canonicalheader v1.1.2 // indirect
|
||||
github.com/ldez/exptostd v0.3.1 // indirect
|
||||
github.com/ldez/gomoddirectives v0.6.0 // indirect
|
||||
github.com/ldez/grignotin v0.7.0 // indirect
|
||||
github.com/ldez/tagliatelle v0.7.1 // indirect
|
||||
github.com/ldez/usetesting v0.4.2 // indirect
|
||||
github.com/leonklingele/grouper v1.1.2 // indirect
|
||||
github.com/macabu/inamedparam v0.1.3 // indirect
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
github.com/maratori/testableexamples v1.0.0 // indirect
|
||||
github.com/maratori/testpackage v1.1.1 // indirect
|
||||
github.com/matoous/godox v0.0.0-20230222163458-006bad1f9d26 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.16 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
||||
github.com/mgechev/revive v1.5.1 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/moricho/tparallel v0.3.2 // indirect
|
||||
github.com/nakabonne/nestif v0.3.1 // indirect
|
||||
github.com/nishanths/exhaustive v0.12.0 // indirect
|
||||
github.com/nishanths/predeclared v0.2.2 // indirect
|
||||
github.com/nunnatsa/ginkgolinter v0.18.4 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/polyfloyd/go-errorlint v1.7.0 // indirect
|
||||
github.com/prometheus/client_golang v1.12.1 // indirect
|
||||
github.com/prometheus/client_model v0.2.0 // indirect
|
||||
github.com/prometheus/common v0.32.1 // indirect
|
||||
github.com/prometheus/procfs v0.7.3 // indirect
|
||||
github.com/quasilyte/go-ruleguard v0.4.3-0.20240823090925-0fe6f58b47b1 // indirect
|
||||
github.com/quasilyte/go-ruleguard/dsl v0.3.22 // indirect
|
||||
github.com/quasilyte/gogrep v0.5.0 // indirect
|
||||
github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect
|
||||
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect
|
||||
github.com/raeperd/recvcheck v0.2.0 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
github.com/rogpeppe/go-internal v1.13.1 // indirect
|
||||
github.com/rs/zerolog v1.29.0 // indirect
|
||||
github.com/ryancurrah/gomodguard v1.3.5 // indirect
|
||||
github.com/ryanrolds/sqlclosecheck v0.5.1 // indirect
|
||||
github.com/sanposhiho/wastedassign/v2 v2.1.0 // indirect
|
||||
github.com/santhosh-tekuri/jsonschema/v6 v6.0.1 // indirect
|
||||
github.com/sashamelentyev/interfacebloat v1.1.0 // indirect
|
||||
github.com/sashamelentyev/usestdlibvars v1.28.0 // indirect
|
||||
github.com/securego/gosec/v2 v2.21.4 // indirect
|
||||
github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c // indirect
|
||||
github.com/sirupsen/logrus v1.9.3 // indirect
|
||||
github.com/sivchari/containedctx v1.0.3 // indirect
|
||||
github.com/sivchari/tenv v1.12.1 // indirect
|
||||
github.com/sonatard/noctx v0.1.0 // indirect
|
||||
github.com/sourcegraph/go-diff v0.7.0 // indirect
|
||||
github.com/spf13/afero v1.11.0 // indirect
|
||||
github.com/spf13/cast v1.5.0 // indirect
|
||||
github.com/spf13/cobra v1.8.1 // indirect
|
||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/spf13/viper v1.15.0 // indirect
|
||||
github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect
|
||||
github.com/stbenjam/no-sprintf-host-port v0.2.0 // indirect
|
||||
github.com/stretchr/objx v0.5.2 // indirect
|
||||
github.com/stretchr/testify v1.10.0 // indirect
|
||||
github.com/subosito/gotenv v1.4.2 // indirect
|
||||
github.com/tdakkota/asciicheck v0.3.0 // indirect
|
||||
github.com/tetafro/godot v1.4.20 // indirect
|
||||
github.com/timakin/bodyclose v0.0.0-20241017074812-ed6a65f985e3 // indirect
|
||||
github.com/timonwong/loggercheck v0.10.1 // indirect
|
||||
github.com/tomarrell/wrapcheck/v2 v2.10.0 // indirect
|
||||
github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect
|
||||
github.com/ultraware/funlen v0.2.0 // indirect
|
||||
github.com/ultraware/whitespace v0.2.0 // indirect
|
||||
github.com/uudashr/gocognit v1.2.0 // indirect
|
||||
github.com/uudashr/iface v1.3.0 // indirect
|
||||
github.com/xen0n/gosmopolitan v1.2.2 // indirect
|
||||
github.com/yagipy/maintidx v1.0.0 // indirect
|
||||
github.com/yeya24/promlinter v0.3.0 // indirect
|
||||
github.com/ykadowak/zerologlint v0.1.5 // indirect
|
||||
gitlab.com/bosi/decorder v0.4.2 // indirect
|
||||
go-simpler.org/musttag v0.13.0 // indirect
|
||||
go-simpler.org/sloglint v0.7.2 // indirect
|
||||
go.uber.org/atomic v1.9.0 // indirect
|
||||
go.uber.org/automaxprocs v1.6.0 // indirect
|
||||
go.uber.org/multierr v1.8.0 // indirect
|
||||
go.uber.org/zap v1.24.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
|
||||
golang.org/x/exp/typeparams v0.0.0-20241108190413-2d47ceb2692f // indirect
|
||||
golang.org/x/mod v0.22.0 // indirect
|
||||
golang.org/x/sync v0.10.0 // indirect
|
||||
golang.org/x/sys v0.28.0 // indirect
|
||||
golang.org/x/term v0.16.0 // indirect
|
||||
golang.org/x/text v0.20.0 // indirect
|
||||
golang.org/x/tools v0.28.0 // indirect
|
||||
google.golang.org/protobuf v1.34.2 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
honnef.co/go/tools v0.5.1 // indirect
|
||||
mvdan.cc/gofumpt v0.7.0 // indirect
|
||||
mvdan.cc/unparam v0.0.0-20240528143540-8a5130ca722f // indirect
|
||||
)
|
||||
1017
tools/go.sum
1017
tools/go.sum
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user