Skip to content

Commit

Permalink
Add admin authenticaton to dashboards api/status
Browse files Browse the repository at this point in the history
Signed-off-by: Zelin Hao <[email protected]>
  • Loading branch information
zelinh committed May 12, 2022
1 parent 28d5c7b commit 655aa1e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def url(self, path=""):
def get_service_response(self):
url = self.url("/api/status")
logging.info(f"Pinging {url}")
return requests.get(url, verify=False, auth=("kibanaserver", "kibanaserver") if self.security_enabled else None)
return requests.get(url, verify=False, auth=("admin", "admin"))

def __add_plugin_specific_config(self, additional_config):
with open(self.opensearch_dashboards_yml_dir, "a") as yamlfile:
Expand Down
2 changes: 1 addition & 1 deletion tests/jenkins/TestRpmDashboardsDistValidation.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class TestRpmDashboardsDistValidation extends BuildPipelineTest {
]
]
]
helper.addShMock("curl -s \"http://localhost:5601/api/status\"") { script ->
helper.addShMock("curl -s \"http://localhost:5601/api/status\" -u admin:admin") { script ->
return [stdout: cluster_status.inspect(), exitValue: 0]
}
helper.registerAllowedMethod("readJSON", [Map.class], {c -> cluster_status})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ For more information, see: https://opensearch.org/}})
systemdCommands.sh(systemctl start opensearch-dashboards)
rpmDashboardsDistValidation.systemdCommands({command=status, product=opensearch-dashboards})
systemdCommands.sh({script=systemctl status opensearch-dashboards, returnStdout=true})
rpmDashboardsDistValidation.sh({script=curl -s "http://localhost:5601/api/status", returnStatus=true})
rpmDashboardsDistValidation.sh({script=curl -s "http://localhost:5601/api/status", returnStdout=true})
rpmDashboardsDistValidation.sh({script=curl -s "http://localhost:5601/api/status" -u admin:admin, returnStatus=true})
rpmDashboardsDistValidation.sh({script=curl -s "http://localhost:5601/api/status" -u admin:admin, returnStdout=true})
rpmDashboardsDistValidation.readJSON({text=['name':'dummy_desktop', 'uuid':'c4677c7a-d76f-45eb-a124-7e30d2b10e4b', 'version':['number':'1.3.0', 'build_hash':'00e06934211e9819f99aabbf139885682f33e95e', 'build_number':1, 'build_snapshot':false], 'status':['overall':['since':'2022-04-07T21:54:39.960Z', 'state':'green', 'title':'Green', 'nickname':'Looking good', 'icon':'success', 'uiColor':'secondary']]]})
rpmDashboardsDistValidation.sh({script=/usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin list --allow-root, returnStdout=true})
BundleManifest.getLocation(ganttChartDashboards)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def test_get_service_response_with_security(self, mock_url, mock_requests_get):
service.get_service_response()

mock_url.assert_called_once_with("/api/status")
mock_requests_get.assert_called_once_with(mock_url_result, verify=False, auth=("kibanaserver", "kibanaserver"))
mock_requests_get.assert_called_once_with(mock_url_result, verify=False, auth=("admin", "admin"))

@patch("requests.get")
@patch.object(ServiceOpenSearchDashboards, "url")
Expand All @@ -228,7 +228,7 @@ def test_get_service_response_without_security(self, mock_url, mock_requests_get
service.get_service_response()

mock_url.assert_called_once_with("/api/status")
mock_requests_get.assert_called_once_with(mock_url_result, auth=None, verify=False)
mock_requests_get.assert_called_once_with(mock_url_result, verify=False, auth=("admin", "admin"))

@patch.object(ServiceOpenSearchDashboards, "get_service_response")
def test_service_alive_green_available(self, mock_get_service_response):
Expand Down
4 changes: 2 additions & 2 deletions vars/rpmDashboardsDistValidation.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ def call(Map args = [:]) {
if (osd_status_json != 0) {
sleep 10
osd_status_json = sh (
script: "curl -s \"http://localhost:5601/api/status\"",
script: "curl -s \"http://localhost:5601/api/status\" -u admin:admin",
returnStatus: true
)
} else {
osd_status_json = sh (
script: "curl -s \"http://localhost:5601/api/status\"",
script: "curl -s \"http://localhost:5601/api/status\" -u admin:admin",
returnStdout: true
).trim()
break
Expand Down

0 comments on commit 655aa1e

Please sign in to comment.