@@ -13,6 +13,8 @@ import (
13
13
http_helper "github.com/gruntwork-io/terratest/modules/http-helper"
14
14
"github.com/gruntwork-io/terratest/modules/k8s"
15
15
"github.com/gruntwork-io/terratest/modules/random"
16
+ "github.com/stretchr/testify/assert"
17
+ digestAuth "github.com/xinsnake/go-http-digest-auth-client"
16
18
)
17
19
18
20
func TestHelmInstall (t * testing.T ) {
@@ -61,21 +63,44 @@ func TestHelmInstall(t *testing.T) {
61
63
podName := releaseName + "-marklogic-0"
62
64
// wait until the pod is in Ready status
63
65
k8s .WaitUntilPodAvailable (t , kubectlOptions , podName , 10 , 15 * time .Second )
64
- tunnel := k8s .NewTunnel (
65
- kubectlOptions , k8s .ResourceTypePod , podName , 7997 , 7997 )
66
- defer tunnel .Close ()
67
- tunnel .ForwardPort (t )
68
- endpoint := fmt .Sprintf ("http://%s" , tunnel .Endpoint ())
69
- t .Logf (`Endpoint: %s` , endpoint )
66
+ tunnel7997 := k8s .NewTunnel (kubectlOptions , k8s .ResourceTypePod , podName , 7997 , 7997 )
67
+ defer tunnel7997 .Close ()
68
+ tunnel7997 .ForwardPort (t )
69
+ endpoint7997 := fmt .Sprintf ("http://%s" , tunnel7997 .Endpoint ())
70
70
71
+ // verify if 7997 health check endpoint returns 200
71
72
http_helper .HttpGetWithRetryWithCustomValidation (
72
73
t ,
73
- endpoint ,
74
+ endpoint7997 ,
74
75
& tlsConfig ,
75
76
10 ,
76
77
15 * time .Second ,
77
78
func (statusCode int , body string ) bool {
78
79
return statusCode == 200
79
80
},
80
81
)
82
+
83
+ // testing generated Random Password
84
+ secretName := releaseName + "-marklogic"
85
+ secret := k8s .GetSecret (t , kubectlOptions , secretName )
86
+ username := "admin"
87
+ passwordArr := secret .Data ["marklogic-password" ]
88
+ password := string (passwordArr [:])
89
+ // the generated random password should have length of 10
90
+ assert .Equal (t , 10 , len (password ))
91
+
92
+ tunnel_8002 := k8s .NewTunnel (kubectlOptions , k8s .ResourceTypePod , podName , 8002 , 8002 )
93
+ defer tunnel_8002 .Close ()
94
+ tunnel_8002 .ForwardPort (t )
95
+ endpointManage := fmt .Sprintf ("http://%s/manage/v2" , tunnel_8002 .Endpoint ())
96
+
97
+ request := digestAuth .NewRequest (username , password , "GET" , endpointManage , "" )
98
+ response , err := request .Execute ()
99
+ if err != nil {
100
+ t .Fatalf (err .Error ())
101
+ }
102
+ defer response .Body .Close ()
103
+ // the generated password should be able to access the manage endpoint
104
+ assert .Equal (t , 200 , response .StatusCode )
105
+
81
106
}
0 commit comments