Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Commit

Permalink
[HOTFIX] Support oauth2ClientCredentials destinations in the Destinat…
Browse files Browse the repository at this point in the history
…ions Creator Operator (#3515)

* Cherrypick and resolution of conflicts

* Bump versions

* Delete unused imports
  • Loading branch information
nyordanoff committed Nov 30, 2023
1 parent b110605 commit 8e037be
Show file tree
Hide file tree
Showing 31 changed files with 1,322 additions and 290 deletions.
12 changes: 6 additions & 6 deletions chart/compass/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ global:
version: "v20231121-e91239f0"
name: compass-pairing-adapter
director:
dir: prod/incubator/
version: "v20231128-76050135"
dir: dev/incubator/
version: "PR-3515"
name: compass-director
hydrator:
dir: prod/incubator/
Expand Down Expand Up @@ -216,16 +216,16 @@ global:
dir:
version: "0a651695"
external_services_mock:
dir: prod/incubator/
version: "v20231128-10ebaa4f"
dir: dev/incubator/
version: "PR-3515"
name: compass-external-services-mock
console:
dir: prod/incubator/
version: "v20230421-e8840c18"
name: compass-console
e2e_tests:
dir: prod/incubator/
version: "v20231128-10ebaa4f"
dir: dev/incubator/
version: "PR-3515"
name: compass-e2e-tests
isLocalEnv: false
isForTesting: false
Expand Down
29 changes: 29 additions & 0 deletions components/director/internal/destinationcreator/fixtures_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const (
samlAssertionDestName = "test-saml-assertion-dest-name"
samlAssertionDestURL = "test-saml-assertion-dest-url"
clientCertAuthDestName = "test-client-cert-auth-dest-name"
oauth2ClientCredsDestName = "test-oauth2-client-creds-dest-name"
destinationDescription = "test-dest-description"
destinationTypeHTTP = string(destinationcreatorpkg.TypeHTTP)
destinationProxyTypeInternet = string(destinationcreatorpkg.ProxyTypeInternet)
Expand All @@ -38,6 +39,10 @@ const (
basicDestURL = "basic-url"
basicDestUser = "basic-user"
basicDestPassword = "basic-pwd"
oauth2ClientCredsURL = "oauth2-url"
oauth2ClientCredsTokenURL = "oauth2-token-url"
oauth2ClientCredsClientID = "oauth2-client-id"
oauth2ClientCredsClientSecret = "oauth2-client-secret"

// Destination Certificate constants
certificateName = "testCertificateName"
Expand Down Expand Up @@ -75,6 +80,7 @@ var (
appTemplateID = "testAppTemplateID"
appBaseURL = "http://app-test-base-url"
appEmptyBaseURL = ""
testURLPath = "/test/path"

TestEmptyErrorValueRawJSON = json.RawMessage(`\"\"`)
TestConfigValueRawJSON = json.RawMessage(`{"configKey":"configValue"}`)
Expand Down Expand Up @@ -172,6 +178,14 @@ func fixDestinationConfig() *destinationcreator.Config {
}
}

func fixDestinationInfo(authType, destType, url string) *destinationcreatorpkg.DestinationInfo {
return &destinationcreatorpkg.DestinationInfo{
AuthenticationType: destinationcreatorpkg.AuthType(authType),
Type: destinationcreatorpkg.Type(destType),
URL: url,
}
}

func fixDesignTimeDestinationDetails() operators.Destination {
return fixDestinationDetails(designTimeDestName, string(destinationcreatorpkg.AuthTypeNoAuth), destinationExternalSubaccountID)
}
Expand All @@ -194,6 +208,12 @@ func fixClientCertAuthDestinationDetails() operators.Destination {
return fixDestinationDetails(clientCertAuthDestName, string(destinationcreatorpkg.AuthTypeClientCertificate), destinationExternalSubaccountID)
}

func fixOAuth2ClientCredsDestinationDetails() operators.Destination {
dest := fixDestinationDetails(oauth2ClientCredsDestName, string(destinationcreatorpkg.AuthTypeOAuth2ClientCredentials), destinationExternalSubaccountID)
dest.TokenServiceURLType = string(destinationcreatorpkg.DedicatedTokenServiceURLType)
return dest
}

func fixDestinationsDetailsWithoutSubaccountID() []operators.Destination {
return []operators.Destination{
fixDestinationDetails(samlAssertionDestName, string(destinationcreatorpkg.AuthTypeSAMLAssertion), ""),
Expand Down Expand Up @@ -233,6 +253,15 @@ func fixSAMLAssertionAuthCreds(url string) *operators.SAMLAssertionAuthenticatio
}
}

func fixOAuth2ClientCreds(url, tokenServiceURL, clientID, clientSecret string) *operators.OAuth2ClientCredentialsAuthentication {
return &operators.OAuth2ClientCredentialsAuthentication{
URL: url,
TokenServiceURL: tokenServiceURL,
ClientID: clientID,
ClientSecret: clientSecret,
}
}

func fixClientCertAuthTypeCreds() *operators.ClientCertAuthentication {
return &operators.ClientCertAuthentication{URL: destinationURL}
}
Expand Down
175 changes: 136 additions & 39 deletions components/director/internal/destinationcreator/service.go

Large diffs are not rendered by default.

Loading

0 comments on commit 8e037be

Please sign in to comment.