Skip to content

chore: allow running fake idp with coderd dev #11555

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

Merged
merged 6 commits into from
Jan 11, 2024
Merged

Conversation

Emyrk
Copy link
Member

@Emyrk Emyrk commented Jan 10, 2024

This could be made more ergonomic, but this is a good start.

Essentially as I debug this oauth stuff, the oidctest stuff has been excellent for testing, and I think it would be valuable to also be able to manually test the UI with it. For example this: #11554 hangs indefinitely on the UI. I got this accidentally from github, but it would be nice to manually invoke this.

Maybe the e2e tests could use this too? idk.

Screenshot from 2024-01-10 10-49-57

Example

Run this file

$ go run main.go                                                                                                                                   
2024-01-10 16:48:01.415 [info]  stdlib: 2024/01/10 10:48:01 IDP Issuer URL http://127.0.0.1:44517
2024-01-10 16:48:01.415 [info]  stdlib: 2024/01/10 10:48:01 Oauth Flags
2024-01-10 16:48:01.415 [info]  stdlib: 2024/01/10 10:48:01 --external-auth-providers='[{"type":"fake","client_id":"f2df566b-a1c9-407a-8b75-480db45c6476","client_secret":"55aca4e3-7b94-44b6-9f45-ecb5e81c560d","auth_url":"http://127.0.0.1:44517/oauth2/authorize","token_url":"http://127.0.0.1:44517/oauth2/token","validate_url":"http://127.0.0.1:44517/oauth2/userinfo","scopes":["openid","email","profile"]}]'
2024-01-10 16:48:01.415 [info]  stdlib: 2024/01/10 10:48:01 Press Ctrl+C to exit

Then copy that flag to develop.sh

develop.sh -- --external-auth-providers='[{"type":"fake","client_id":"f2df566b-a1c9-407a-8b75-480db45c6476","client_secret":"55aca4e3-7b94-44b6-9f45-ecb5e81c560d","auth_url":"http://127.0.0.1:44517/oauth2/authorize","token_url":"http://127.0.0.1:44517/oauth2/token","validate_url":"http://127.0.0.1:44517/oauth2/userinfo","scopes":["openid","email","profile"]}]'

Flag parsing

I fixed that awhile ago here: #11268

Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

@@ -0,0 +1,58 @@
package main
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be moved to cmd/testidp. I think it would be confusing to have packages that can be built sprinkled within the source tree.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call 👍

Name: "Run Fake IDP",
F: RunIDP(),
},
}, nil, nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels weird, but I understand you did it to use the oidctest package 😄, it's also possible to build a test package, typically I'd suggest to implement this that way, but it wouldn't be as easily discoverable as this is (esp. if put in cmd/).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I felt werid saying run go test -run="TestRealIDP" or something.

Another idea I had was to just implement the testing.TB struct myself and just throw log messages on the Fails(). It's not as trivial as I'd hope though, they have this: https://github.com/golang/go/blob/master/src/testing/testing.go#L899-L902

So I'd have to embed an actual testing.T struct? It just also has it's "jankiness", so just went with this for now.

@Emyrk Emyrk enabled auto-merge (squash) January 11, 2024 18:00
@Emyrk Emyrk merged commit e3ad958 into main Jan 11, 2024
@Emyrk Emyrk deleted the stevenmasley/fake_idp_service branch January 11, 2024 18:10
@github-actions github-actions bot locked and limited conversation to collaborators Jan 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants