Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding issue #24

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/get_client_credentials_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func GetClientCredentialsTokenCmd(cfg config.Config, clientId, clientSecret stri
uaaTokenFormat = uaa.OpaqueToken
}

oauth2.RegisterBrokenAuthHeaderProvider(cfg.GetActiveTarget().BaseUrl)
api, err := uaa.NewWithClientCredentials(cfg.GetActiveTarget().BaseUrl, cfg.ZoneSubdomain, clientId, clientSecret, uaaTokenFormat, cfg.GetActiveTarget().SkipSSLValidation)
if err != nil {
return errors.Wrap(err, "An error occurred while building API with client credentials.")
Expand Down
15 changes: 10 additions & 5 deletions cmd/get_client_credentials_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ var _ = Describe("GetClientCredentialsToken", func() {
config.WriteConfig(c)
server.RouteToHandler("POST", "/oauth/token", CombineHandlers(
RespondWith(http.StatusOK, opaqueTokenResponseJson, contentTypeJson),
VerifyHeaderKV("Authorization", "Basic YWRtaW46YWRtaW5zZWNyZXQ="),
VerifyFormKV("client_id", "admin"),
VerifyFormKV("client_secret", "adminsecret"),
VerifyFormKV("grant_type", "client_credentials"),
),
)
Expand All @@ -63,7 +64,8 @@ var _ = Describe("GetClientCredentialsToken", func() {
It("can request jwt token", func() {
server.RouteToHandler("POST", "/oauth/token", CombineHandlers(
RespondWith(http.StatusOK, jwtResponseJson, contentTypeJson),
VerifyHeaderKV("Authorization", "Basic YWRtaW46YWRtaW5zZWNyZXQ="),
VerifyFormKV("client_id", "admin"),
VerifyFormKV("client_secret", "adminsecret"),
VerifyFormKV("grant_type", "client_credentials"),
VerifyFormKV("token_format", "jwt"),
))
Expand All @@ -74,7 +76,8 @@ var _ = Describe("GetClientCredentialsToken", func() {
It("can request opaque token", func() {
server.RouteToHandler("POST", "/oauth/token", CombineHandlers(
RespondWith(http.StatusOK, opaqueTokenResponseJson, contentTypeJson),
VerifyHeaderKV("Authorization", "Basic YWRtaW46YWRtaW5zZWNyZXQ="),
VerifyFormKV("client_id", "admin"),
VerifyFormKV("client_secret", "adminsecret"),
VerifyFormKV("grant_type", "client_credentials"),
VerifyFormKV("token_format", "opaque"),
))
Expand All @@ -85,7 +88,8 @@ var _ = Describe("GetClientCredentialsToken", func() {
It("uses jwt format by default", func() {
server.RouteToHandler("POST", "/oauth/token", CombineHandlers(
RespondWith(http.StatusOK, jwtResponseJson, contentTypeJson),
VerifyHeaderKV("Authorization", "Basic YWRtaW46YWRtaW5zZWNyZXQ="),
VerifyFormKV("client_id", "admin"),
VerifyFormKV("client_secret", "adminsecret"),
VerifyFormKV("grant_type", "client_credentials"),
VerifyFormKV("token_format", "jwt"),
))
Expand All @@ -108,7 +112,8 @@ var _ = Describe("GetClientCredentialsToken", func() {
config.WriteConfig(c)
server.RouteToHandler("POST", "/oauth/token", CombineHandlers(
RespondWith(http.StatusUnauthorized, `{"error":"unauthorized","error_description":"Bad credentials"}`),
VerifyHeaderKV("Authorization", "Basic YWRtaW46YWRtaW5zZWNyZXQ="),
VerifyFormKV("client_id", "admin"),
VerifyFormKV("client_secret", "adminsecret"),
VerifyFormKV("grant_type", "client_credentials"),
),
)
Expand Down