-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLI-140: integration tests on ci #263
Changes from 23 commits
eda57a2
c057136
0b33221
a8b99b8
5b04287
5267a1d
5452a69
6ce685e
46c0731
8d9d409
16384bd
54b319c
7736d2d
e6b3aa2
946d02a
ca0c543
c2e8fbb
4ca5642
977317d
1e4a362
2dcb9f2
1621e67
70a768b
5e0632e
46b13a0
74697e1
268c5a9
0c5e51b
b76d343
a650818
cac083a
f2f54ba
c2400f1
c55da52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,11 +38,7 @@ lint: | |
|
||
# Build for the native platform | ||
build: | ||
go build -ldflags "$(CTIMEVAR)" -o auth0 cmd/auth0/main.go | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch. bad resolved merge conflict I guess 🤦🏼 |
||
.PHONY: build | ||
|
||
# Build for the native platform | ||
build: | ||
go build -ldflags "$(CTIMEVAR)" -o $(GOBIN)/auth0 cmd/auth0/main.go | ||
.PHONY: build | ||
|
||
# Build a beta version of auth0-cli for all supported platforms | ||
|
@@ -69,6 +65,6 @@ $(GOBIN)/commander: | |
$(GOBIN)/auth0-cli-config-generator: | ||
go install ./pkg/auth0-cli-config-generator | ||
|
||
integration: $(GOBIN)/auth0-cli-config-generator $(GOBIN)/commander | ||
auth0-cli-config-generator && commander test commander.yaml | ||
integration: build $(GOBIN)/auth0-cli-config-generator $(GOBIN)/commander | ||
auth0-cli-config-generator && commander test commander.yaml --verbose | ||
.PHONY: integration |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,17 @@ type params struct { | |
clientSecret string | ||
} | ||
|
||
var requiredScopes = []string{ | ||
"openid", | ||
"offline_access", // <-- to get a refresh token. | ||
"create:clients", "delete:clients", "read:clients", "update:clients", | ||
"create:resource_servers", "delete:resource_servers", "read:resource_servers", "update:resource_servers", | ||
"create:rules", "delete:rules", "read:rules", "update:rules", | ||
"read:users", "update:users", | ||
"read:branding", "update:branding", | ||
"read:client_keys", "read:logs", "read:tenant_settings", | ||
} | ||
|
||
func (p params) validate() error { | ||
if p.clientName == "" { | ||
return fmt.Errorf("Missing client name") | ||
|
@@ -65,6 +76,7 @@ type tenant struct { | |
Domain string `json:"domain"` | ||
AccessToken string `json:"access_token,omitempty"` | ||
ExpiresAt time.Time `json:"expires_at"` | ||
Scopes []string `json:"scopes,omitempty"` | ||
} | ||
|
||
func isLoggedIn(filePath string) bool { | ||
|
@@ -168,7 +180,13 @@ func main() { | |
return err | ||
} | ||
|
||
t := tenant{p.clientName, p.clientDomain, token.AccessToken, token.Expiry} | ||
t := tenant{ | ||
Name: p.clientName, | ||
Domain: p.clientDomain, | ||
AccessToken: token.AccessToken, | ||
ExpiresAt: token.Expiry, | ||
Scopes: requiredScopes, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the CLI is triggering a login flow if the scopes on the tenant are not equal to the defined on the auth package, this is a way we have to "revalidate" tokens if we change the scopes used. Evidently, it would be hard to maintain (keep in sync) the config generator regarding I would like to explore that alternative of skipping all file-related config if an access token is defined. That way the generator would be repurposed on a command to login and write the access token to a var, no need to know the tenant entity at all. |
||
} | ||
|
||
cfg := config{p.clientName, map[string]tenant{p.clientName: t}} | ||
if err := persistConfig(p.filePath, cfg, overwrite); err != nil { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we need
AUTH0_CLI_REUSE_CONFIG
on the secrets. It should be always false on CI if understood the code correctly; there's no config file to reuse here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if we tweak the CLI codebase to look for all those ENV vars and skip the config file completely if the vars are present?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm, we don't want to support client id/secret auth mechanism on the code base. In any case, it could look for an ENV var with the access token and skip config file, but that has nothing to do with this PR.