-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
US-498622 - Infinity OAuth env vars for SRS connector (#545)
* US-498622 - Infinity OAuth env vars for SRS connector * US-498622 : Infinity OAuth env vars for SRS connector --------- Co-authored-by: Davis Walsh <[email protected]>
- Loading branch information
1 parent
e3a2946
commit 686a06b
Showing
9 changed files
with
539 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{{- if and (.Values.pegasearch.externalSearchService) ((.Values.pegasearch.srsAuth).enabled) }} | ||
# Secret for OAuth private key used to get an authorization token for Pega Infinity connection to Search and Reporting Service | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: pega-srs-auth-secret | ||
namespace: {{ .Release.Namespace }} | ||
type: Opaque | ||
data: | ||
privateKey: {{ template "srsAuthPrivateKey" . }} | ||
{{- end }} |
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
117 changes: 117 additions & 0 deletions
117
terratest/src/test/pega/pega-deployment-with-srs-auth-enabled-and-disabled_test.go
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,117 @@ | ||
package pega | ||
|
||
import ( | ||
"github.com/gruntwork-io/terratest/modules/helm" | ||
"github.com/stretchr/testify/require" | ||
appsv1 "k8s.io/api/apps/v1" | ||
"path/filepath" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestPegaDeploymentWithSRSDisabled(t *testing.T) { | ||
var supportedVendors = []string{"k8s", "eks", "gke", "aks"} | ||
var supportedOperations = []string{"deploy", "install-deploy"} | ||
|
||
helmChartPath, err := filepath.Abs(PegaHelmChartPath) | ||
require.NoError(t, err) | ||
|
||
for _, vendor := range supportedVendors { | ||
for _, operation := range supportedOperations { | ||
|
||
var options = &helm.Options{ | ||
SetValues: map[string]string{ | ||
"global.provider": vendor, | ||
"global.actions.execute": operation, | ||
}, | ||
} | ||
deploymentYaml := RenderTemplate(t, options, helmChartPath, []string{"templates/pega-tier-deployment.yaml"}) | ||
deployments := strings.Split(deploymentYaml, "---") | ||
for _, deployment := range deployments { | ||
assertNoSRSAuthSettings(t, deployment) | ||
} | ||
} | ||
} | ||
} | ||
|
||
func TestPegaDeploymentWithSRSAuthDisabled(t *testing.T) { | ||
var supportedVendors = []string{"k8s", "eks", "gke", "aks"} | ||
var supportedOperations = []string{"deploy", "install-deploy"} | ||
|
||
helmChartPath, err := filepath.Abs(PegaHelmChartPath) | ||
require.NoError(t, err) | ||
|
||
for _, vendor := range supportedVendors { | ||
for _, operation := range supportedOperations { | ||
|
||
var options = &helm.Options{ | ||
SetValues: map[string]string{ | ||
"global.provider": vendor, | ||
"global.actions.execute": operation, | ||
"pegasearch.externalSearchService": "true", | ||
}, | ||
} | ||
deploymentYaml := RenderTemplate(t, options, helmChartPath, []string{"templates/pega-tier-deployment.yaml"}) | ||
deployments := strings.Split(deploymentYaml, "---") | ||
for _, deployment := range deployments { | ||
assertNoSRSAuthSettings(t, deployment) | ||
} | ||
} | ||
} | ||
} | ||
|
||
func TestPegaDeploymentWithSRSAuthEnabled(t *testing.T) { | ||
var supportedVendors = []string{"k8s", "eks", "gke", "aks"} | ||
var supportedOperations = []string{"deploy", "install-deploy"} | ||
|
||
helmChartPath, err := filepath.Abs(PegaHelmChartPath) | ||
require.NoError(t, err) | ||
|
||
for _, vendor := range supportedVendors { | ||
for _, operation := range supportedOperations { | ||
|
||
var options = &helm.Options{ | ||
SetValues: map[string]string{ | ||
"global.provider": vendor, | ||
"global.actions.execute": operation, | ||
"pegasearch.externalSearchService": "true", | ||
"pegasearch.srsAuth.enabled": "true", | ||
"pegasearch.srsAuth.privateKey": SRSAuthPrivateKeyExample, | ||
}, | ||
} | ||
deploymentYaml := RenderTemplate(t, options, helmChartPath, []string{"templates/pega-tier-deployment.yaml"}) | ||
deployments := strings.Split(deploymentYaml, "---") | ||
for _, deployment := range deployments { | ||
assertHasSRSAuthSettings(t, deployment) | ||
} | ||
} | ||
} | ||
} | ||
|
||
func assertNoSRSAuthSettings(t *testing.T, pegaTierDeployment string) { | ||
var deployment appsv1.Deployment | ||
UnmarshalK8SYaml(t, pegaTierDeployment, &deployment) | ||
for _, container := range deployment.Spec.Template.Spec.Containers { | ||
for _, envVar := range container.Env { | ||
if "SERV_AUTH_PRIVATE_KEY" == envVar.Name { | ||
require.Fail(t, "container '"+container.Name+"' should not have 'SERV_AUTH_PRIVATE_KEY' environment variable") | ||
} | ||
} | ||
} | ||
} | ||
|
||
func assertHasSRSAuthSettings(t *testing.T, pegaTierDeployment string) { | ||
var deployment appsv1.Deployment | ||
UnmarshalK8SYaml(t, pegaTierDeployment, &deployment) | ||
for _, container := range deployment.Spec.Template.Spec.Containers { | ||
hasPrivateKey := false | ||
for _, envVar := range container.Env { | ||
if "SERV_AUTH_PRIVATE_KEY" == envVar.Name { | ||
require.Equal(t, "pega-srs-auth-secret", envVar.ValueFrom.SecretKeyRef.Name) | ||
require.Equal(t, "privateKey", envVar.ValueFrom.SecretKeyRef.Key) | ||
hasPrivateKey = true | ||
} | ||
} | ||
require.True(t, hasPrivateKey, "container '"+container.Name+"' should have 'SERV_AUTH_PRIVATE_KEY' environment variable") | ||
} | ||
} |
Oops, something went wrong.