-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(web-modeler): configure jwk-set-uri for restapi component
- Loading branch information
1 parent
d48086c
commit b76bb88
Showing
15 changed files
with
542 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -194,6 +194,7 @@ func (s *configmapRestAPITemplateTest) TestContainerShouldSetCorrectKeycloakServ | |
// then | ||
s.Require().Equal("http://keycloak:80/auth/realms/camunda-platform", configmapApplication.Camunda.Modeler.Security.JWT.Issuer.BackendUrl) | ||
} | ||
|
||
func (s *configmapRestAPITemplateTest) TestContainerShouldSetCorrectKeycloakServiceUrlWithCustomPort() { | ||
// given | ||
options := &helm.Options{ | ||
|
@@ -221,6 +222,7 @@ func (s *configmapRestAPITemplateTest) TestContainerShouldSetCorrectKeycloakServ | |
// then | ||
s.Require().Equal("http://keycloak:8888/auth/realms/camunda-platform", configmapApplication.Camunda.Modeler.Security.JWT.Issuer.BackendUrl) | ||
} | ||
|
||
func (s *configmapRestAPITemplateTest) TestContainerShouldSetSmtpCredentials() { | ||
// given | ||
options := &helm.Options{ | ||
|
@@ -247,6 +249,7 @@ func (s *configmapRestAPITemplateTest) TestContainerShouldSetSmtpCredentials() { | |
// then | ||
s.Require().Equal("modeler-user", configmapApplication.Spring.Mail.Username) | ||
} | ||
|
||
func (s *configmapRestAPITemplateTest) TestContainerShouldSetExternalDatabaseConfiguration() { | ||
// given | ||
options := &helm.Options{ | ||
|
@@ -276,3 +279,85 @@ func (s *configmapRestAPITemplateTest) TestContainerShouldSetExternalDatabaseCon | |
s.Require().Equal("jdbc:postgresql://postgres.example.com:65432/modeler-database", configmapApplication.Spring.Datasource.Url) | ||
s.Require().Equal("modeler-user", configmapApplication.Spring.Datasource.Username) | ||
} | ||
|
||
func (s *configmapRestAPITemplateTest) TestContainerShouldSetJwkSetUriFromJwksUrlProperty() { | ||
// given | ||
options := &helm.Options{ | ||
SetValues: map[string]string{ | ||
"webModeler.enabled": "true", | ||
"webModeler.restapi.mail.fromAddress": "[email protected]", | ||
"global.identity.auth.jwksUrl": "https://example.com/auth/realms/test/protocol/openid-connect/certs", | ||
}, | ||
KubectlOptions: k8s.NewKubectlOptions("", "", s.namespace), | ||
} | ||
|
||
// when | ||
output := helm.RenderTemplate(s.T(), options, s.chartPath, s.release, s.templates) | ||
var configmap corev1.ConfigMap | ||
var configmapApplication WebModelerRestAPIApplicationYAML | ||
helm.UnmarshalK8SYaml(s.T(), output, &configmap) | ||
|
||
err := yaml.Unmarshal([]byte(configmap.Data["application.yaml"]), &configmapApplication) | ||
if err != nil { | ||
s.Fail("Failed to unmarshal yaml. error=", err) | ||
} | ||
|
||
// then | ||
s.Require().Equal("https://example.com/auth/realms/test/protocol/openid-connect/certs", configmapApplication.Spring.Security.OAuth2.ResourceServer.JWT.JwkSetURI) | ||
} | ||
|
||
func (s *configmapRestAPITemplateTest) TestContainerShouldSetJwkSetUriFromIssuerBackendUrlProperty() { | ||
// given | ||
options := &helm.Options{ | ||
SetValues: map[string]string{ | ||
"webModeler.enabled": "true", | ||
"webModeler.restapi.mail.fromAddress": "[email protected]", | ||
"global.identity.auth.issuerBackendUrl": "http://test-keycloak/auth/realms/test", | ||
}, | ||
KubectlOptions: k8s.NewKubectlOptions("", "", s.namespace), | ||
} | ||
|
||
// when | ||
output := helm.RenderTemplate(s.T(), options, s.chartPath, s.release, s.templates) | ||
var configmap corev1.ConfigMap | ||
var configmapApplication WebModelerRestAPIApplicationYAML | ||
helm.UnmarshalK8SYaml(s.T(), output, &configmap) | ||
|
||
err := yaml.Unmarshal([]byte(configmap.Data["application.yaml"]), &configmapApplication) | ||
if err != nil { | ||
s.Fail("Failed to unmarshal yaml. error=", err) | ||
} | ||
|
||
// then | ||
s.Require().Equal("http://test-keycloak/auth/realms/test/protocol/openid-connect/certs", configmapApplication.Spring.Security.OAuth2.ResourceServer.JWT.JwkSetURI) | ||
} | ||
|
||
func (s *configmapRestAPITemplateTest) TestContainerShouldSetJwkSetUriFromKeycloakUrlProperties() { | ||
// given | ||
options := &helm.Options{ | ||
SetValues: map[string]string{ | ||
"webModeler.enabled": "true", | ||
"webModeler.restapi.mail.fromAddress": "[email protected]", | ||
"global.identity.keycloak.url.protocol": "https", | ||
"global.identity.keycloak.url.host": "example.com", | ||
"global.identity.keycloak.url.port": "443", | ||
"global.identity.keycloak.contextPath": "/", | ||
"global.identity.keycloak.realm": "test", | ||
}, | ||
KubectlOptions: k8s.NewKubectlOptions("", "", s.namespace), | ||
} | ||
|
||
// when | ||
output := helm.RenderTemplate(s.T(), options, s.chartPath, s.release, s.templates) | ||
var configmap corev1.ConfigMap | ||
var configmapApplication WebModelerRestAPIApplicationYAML | ||
helm.UnmarshalK8SYaml(s.T(), output, &configmap) | ||
|
||
err := yaml.Unmarshal([]byte(configmap.Data["application.yaml"]), &configmapApplication) | ||
if err != nil { | ||
s.Fail("Failed to unmarshal yaml. error=", err) | ||
} | ||
|
||
// then | ||
s.Require().Equal("https://example.com:443/test/protocol/openid-connect/certs", configmapApplication.Spring.Security.OAuth2.ResourceServer.JWT.JwkSetURI) | ||
} |
62 changes: 62 additions & 0 deletions
62
charts/camunda-platform-8.5/test/unit/web-modeler/golden/configmap-restapi.golden.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--- | ||
# Source: camunda-platform/templates/web-modeler/configmap-restapi.yaml | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: camunda-platform-test-web-modeler-restapi-configuration | ||
labels: | ||
app: camunda-platform | ||
app.kubernetes.io/name: web-modeler | ||
app.kubernetes.io/instance: camunda-platform-test | ||
app.kubernetes.io/managed-by: Helm | ||
app.kubernetes.io/part-of: camunda-platform | ||
app.kubernetes.io/component: web-modeler | ||
app.kubernetes.io/version: "8.5.13" | ||
annotations: | ||
{} | ||
data: | ||
application.yaml: | | ||
camunda: | ||
identity: | ||
base-url: "http://camunda-platform-test-identity:80" | ||
issuer: "http://localhost:18080/auth/realms/camunda-platform" | ||
issuerBackendUrl: "http://camunda-platform-test-keycloak:80/auth/realms/camunda-platform" | ||
type: "KEYCLOAK" | ||
modeler: | ||
pusher: | ||
host: "camunda-platform-test-web-modeler-websockets" | ||
port: 80 | ||
security: | ||
jwt: | ||
issuer: | ||
backend-url: "http://camunda-platform-test-keycloak:80/auth/realms/camunda-platform" | ||
audience: | ||
internal-api: "web-modeler-api" | ||
public-api: "web-modeler-public-api" | ||
mail: | ||
from-address: "[email protected]" | ||
from-name: "Camunda 8" | ||
server: | ||
url: "http://localhost:8084" | ||
spring: | ||
datasource: | ||
url: "jdbc:postgresql://camunda-platform-test-postgresql-web-modeler:5432/web-modeler" | ||
username: "web-modeler" | ||
mail: | ||
host: "" | ||
port: 587 | ||
properties: | ||
mail.smtp.auth: false | ||
mail.smtp.starttls.enable: true | ||
mail.smtp.starttls.required: true | ||
security: | ||
oauth2: | ||
resourceserver: | ||
jwt: | ||
issuer-uri: "http://localhost:18080/auth/realms/camunda-platform" | ||
jwk-set-uri: "http://camunda-platform-test-keycloak:80/auth/realms/camunda-platform/protocol/openid-connect/certs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -194,6 +194,7 @@ func (s *configmapRestAPITemplateTest) TestContainerShouldSetCorrectKeycloakServ | |
// then | ||
s.Require().Equal("http://keycloak:80/auth/realms/camunda-platform", configmapApplication.Camunda.Modeler.Security.JWT.Issuer.BackendUrl) | ||
} | ||
|
||
func (s *configmapRestAPITemplateTest) TestContainerShouldSetCorrectKeycloakServiceUrlWithCustomPort() { | ||
// given | ||
options := &helm.Options{ | ||
|
@@ -221,6 +222,7 @@ func (s *configmapRestAPITemplateTest) TestContainerShouldSetCorrectKeycloakServ | |
// then | ||
s.Require().Equal("http://keycloak:8888/auth/realms/camunda-platform", configmapApplication.Camunda.Modeler.Security.JWT.Issuer.BackendUrl) | ||
} | ||
|
||
func (s *configmapRestAPITemplateTest) TestContainerShouldSetSmtpCredentials() { | ||
// given | ||
options := &helm.Options{ | ||
|
@@ -247,6 +249,7 @@ func (s *configmapRestAPITemplateTest) TestContainerShouldSetSmtpCredentials() { | |
// then | ||
s.Require().Equal("modeler-user", configmapApplication.Spring.Mail.Username) | ||
} | ||
|
||
func (s *configmapRestAPITemplateTest) TestContainerShouldSetExternalDatabaseConfiguration() { | ||
// given | ||
options := &helm.Options{ | ||
|
@@ -276,3 +279,85 @@ func (s *configmapRestAPITemplateTest) TestContainerShouldSetExternalDatabaseCon | |
s.Require().Equal("jdbc:postgresql://postgres.example.com:65432/modeler-database", configmapApplication.Spring.Datasource.Url) | ||
s.Require().Equal("modeler-user", configmapApplication.Spring.Datasource.Username) | ||
} | ||
|
||
func (s *configmapRestAPITemplateTest) TestContainerShouldSetJwkSetUriFromJwksUrlProperty() { | ||
// given | ||
options := &helm.Options{ | ||
SetValues: map[string]string{ | ||
"webModeler.enabled": "true", | ||
"webModeler.restapi.mail.fromAddress": "[email protected]", | ||
"global.identity.auth.jwksUrl": "https://example.com/auth/realms/test/protocol/openid-connect/certs", | ||
}, | ||
KubectlOptions: k8s.NewKubectlOptions("", "", s.namespace), | ||
} | ||
|
||
// when | ||
output := helm.RenderTemplate(s.T(), options, s.chartPath, s.release, s.templates) | ||
var configmap corev1.ConfigMap | ||
var configmapApplication WebModelerRestAPIApplicationYAML | ||
helm.UnmarshalK8SYaml(s.T(), output, &configmap) | ||
|
||
err := yaml.Unmarshal([]byte(configmap.Data["application.yaml"]), &configmapApplication) | ||
if err != nil { | ||
s.Fail("Failed to unmarshal yaml. error=", err) | ||
} | ||
|
||
// then | ||
s.Require().Equal("https://example.com/auth/realms/test/protocol/openid-connect/certs", configmapApplication.Spring.Security.OAuth2.ResourceServer.JWT.JwkSetURI) | ||
} | ||
|
||
func (s *configmapRestAPITemplateTest) TestContainerShouldSetJwkSetUriFromIssuerBackendUrlProperty() { | ||
// given | ||
options := &helm.Options{ | ||
SetValues: map[string]string{ | ||
"webModeler.enabled": "true", | ||
"webModeler.restapi.mail.fromAddress": "[email protected]", | ||
"global.identity.auth.issuerBackendUrl": "http://test-keycloak/auth/realms/test", | ||
}, | ||
KubectlOptions: k8s.NewKubectlOptions("", "", s.namespace), | ||
} | ||
|
||
// when | ||
output := helm.RenderTemplate(s.T(), options, s.chartPath, s.release, s.templates) | ||
var configmap corev1.ConfigMap | ||
var configmapApplication WebModelerRestAPIApplicationYAML | ||
helm.UnmarshalK8SYaml(s.T(), output, &configmap) | ||
|
||
err := yaml.Unmarshal([]byte(configmap.Data["application.yaml"]), &configmapApplication) | ||
if err != nil { | ||
s.Fail("Failed to unmarshal yaml. error=", err) | ||
} | ||
|
||
// then | ||
s.Require().Equal("http://test-keycloak/auth/realms/test/protocol/openid-connect/certs", configmapApplication.Spring.Security.OAuth2.ResourceServer.JWT.JwkSetURI) | ||
} | ||
|
||
func (s *configmapRestAPITemplateTest) TestContainerShouldSetJwkSetUriFromKeycloakUrlProperties() { | ||
// given | ||
options := &helm.Options{ | ||
SetValues: map[string]string{ | ||
"webModeler.enabled": "true", | ||
"webModeler.restapi.mail.fromAddress": "[email protected]", | ||
"global.identity.keycloak.url.protocol": "https", | ||
"global.identity.keycloak.url.host": "example.com", | ||
"global.identity.keycloak.url.port": "443", | ||
"global.identity.keycloak.contextPath": "/", | ||
"global.identity.keycloak.realm": "test", | ||
}, | ||
KubectlOptions: k8s.NewKubectlOptions("", "", s.namespace), | ||
} | ||
|
||
// when | ||
output := helm.RenderTemplate(s.T(), options, s.chartPath, s.release, s.templates) | ||
var configmap corev1.ConfigMap | ||
var configmapApplication WebModelerRestAPIApplicationYAML | ||
helm.UnmarshalK8SYaml(s.T(), output, &configmap) | ||
|
||
err := yaml.Unmarshal([]byte(configmap.Data["application.yaml"]), &configmapApplication) | ||
if err != nil { | ||
s.Fail("Failed to unmarshal yaml. error=", err) | ||
} | ||
|
||
// then | ||
s.Require().Equal("https://example.com:443/test/protocol/openid-connect/certs", configmapApplication.Spring.Security.OAuth2.ResourceServer.JWT.JwkSetURI) | ||
} |
Oops, something went wrong.