Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use File realm authentication instead of index based #10299

Merged
merged 1 commit into from
Jan 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libbeat/scripts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ integration-tests: prepare-tests
.PHONY: integration-tests-environment
integration-tests-environment: ## @testing Runs the integration inside a virtual environment. This can be run on any docker-machine (local, remote)
integration-tests-environment: prepare-tests build-image
${DOCKER_COMPOSE} run beat make integration-tests RACE_DETECTOR=$(RACE_DETECTOR) DOCKER_COMPOSE_PROJECT_NAME=${DOCKER_COMPOSE_PROJECT_NAME} || docker inspect --format "{{json .State.Health }}" $$(${DOCKER_COMPOSE} ps -q) | jq && ${DOCKER_COMPOSE} logs --tail 200
${DOCKER_COMPOSE} run beat make integration-tests RACE_DETECTOR=$(RACE_DETECTOR) DOCKER_COMPOSE_PROJECT_NAME=${DOCKER_COMPOSE_PROJECT_NAME} || ${DOCKER_COMPOSE} logs --tail 200

# Runs the system tests
.PHONY: system-tests
Expand Down
9 changes: 5 additions & 4 deletions x-pack/libbeat/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ services:
file: ${ES_BEATS}/testing/environments/${TESTING_ENVIRONMENT}.yml
service: elasticsearch
healthcheck:
test: ["CMD-SHELL", 'python -c ''import urllib, json; response = urllib.urlopen("http://elastic:changeme@localhost:9200/_cluster/health"); data = json.loads(response.read()); exit(1) if data["status"] != "green" else exit(0);''']
test: ["CMD-SHELL", 'python -c ''import urllib, json; response = urllib.urlopen("http://myelastic:changeme@localhost:9200/_cluster/health"); data = json.loads(response.read()); exit(1) if data["status"] != "green" else exit(0);''']
Copy link
Contributor Author

@ph ph Jan 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't useradd the elastic or change the password because it's reserved, so instead, I am creating another super user.

retries: 1200
interval: 5s
start_period: 60s
Expand All @@ -37,7 +37,8 @@ services:
- "http.host=0.0.0.0"
- "xpack.security.enabled=true"
- "xpack.license.self_generated.type=trial"
- ELASTIC_PASSWORD=changeme
- "xpack.security.authc.realms.file.file1.order=0"
command: bash -c "bin/elasticsearch-users useradd myelastic -r superuser -p changeme | /usr/local/bin/docker-entrypoint.sh eswrapper"

kibana:
depends_on:
Expand All @@ -46,8 +47,8 @@ services:
file: ${ES_BEATS}/testing/environments/${TESTING_ENVIRONMENT}.yml
service: kibana
healthcheck:
test: ["CMD-SHELL", 'python -c ''import urllib, json; response = urllib.urlopen("http://elastic:changeme@localhost:5601/api/status"); data = json.loads(response.read()); exit(1) if data["status"]["overall"]["state"] != "green" else exit(0);''']
test: ["CMD-SHELL", 'python -c ''import urllib, json; response = urllib.urlopen("http://myelastic:changeme@localhost:5601/api/status"); data = json.loads(response.read()); exit(1) if data["status"]["overall"]["state"] != "green" else exit(0);''']
retries: 1200
interval: 5s
start_period: 60s
command: /usr/local/bin/kibana-docker --xpack.security.enabled=true --elasticsearch.username=elastic --elasticsearch.password=changeme
command: /usr/local/bin/kibana-docker --xpack.security.enabled=true --elasticsearch.username=myelastic --elasticsearch.password=changeme
21 changes: 10 additions & 11 deletions x-pack/libbeat/tests/system/test_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@


INTEGRATION_TESTS = os.environ.get('INTEGRATION_TESTS', False)
KIBANA_PASSWORD = 'changeme'
TIMEOUT = 5 * 60


Expand All @@ -23,7 +22,7 @@ def setUp(self):
# NOTES: Theses options are linked to the specific of the docker compose environment for
# CM.
self.es_host = os.getenv('ES_HOST', 'localhost') + ":" + os.getenv('ES_POST', '9200')
self.es_user = "elastic"
self.es_user = "myelastic"
self.es_pass = "changeme"
self.es = Elasticsearch([self.get_elasticsearch_url()], verify_certs=True)

Expand All @@ -41,7 +40,7 @@ def test_enroll(self):

config_content = open(config_path, 'r').read()

exit_code = self.enroll(KIBANA_PASSWORD)
exit_code = self.enroll(self.es_user, self.es_pass)

assert exit_code == 0

Expand Down Expand Up @@ -74,7 +73,7 @@ def test_enroll_bad_pw(self):

config_content = open(config_path, 'r').read()

exit_code = self.enroll('wrong password')
exit_code = self.enroll("not", 'wrong password')

assert exit_code == 1

Expand All @@ -95,7 +94,7 @@ def test_fetch_configs(self):
# Enroll the beat
config_path = os.path.join(self.working_dir, "mockbeat.yml")
self.render_config_template("mockbeat", config_path)
exit_code = self.enroll(KIBANA_PASSWORD)
exit_code = self.enroll(self.es_user, self.es_pass)
assert exit_code == 0

index = self.random_index()
Expand Down Expand Up @@ -162,7 +161,7 @@ def test_configs_cache(self):
# Enroll the beat
config_path = os.path.join(self.working_dir, "mockbeat.yml")
self.render_config_template("mockbeat", config_path)
exit_code = self.enroll(KIBANA_PASSWORD)
exit_code = self.enroll(self.es_user, self.es_pass)
assert exit_code == 0

index = self.random_index()
Expand Down Expand Up @@ -209,10 +208,10 @@ def test_configs_cache(self):
self.wait_documents(index, 1)
proc.check_kill_and_wait()

def enroll(self, password):
def enroll(self, user, password):
return self.run_beat(
extra_args=["enroll", self.get_kibana_url(),
"--password", "env:PASS", "--force"],
"--password", "env:PASS", "--username", user, "--force"],
logging_args=["-v", "-d", "*"],
env={
'PASS': password,
Expand All @@ -227,7 +226,7 @@ def check_kibana_status(self):
url = self.get_kibana_url() + "/api/status"

r = requests.get(url, headers=headers,
auth=('elastic', KIBANA_PASSWORD))
auth=(self.es_user, self.es_pass))
print(r.text)

def create_and_assing_tag(self, blocks):
Expand All @@ -244,7 +243,7 @@ def create_and_assing_tag(self, blocks):
}

r = requests.put(url, json=data, headers=headers,
auth=('elastic', KIBANA_PASSWORD))
auth=(self.es_user, self.es_pass))
assert r.status_code in (200, 201)

# Retrieve beat ID
Expand All @@ -255,7 +254,7 @@ def create_and_assing_tag(self, blocks):
data = {"assignments": [{"beatId": meta["uuid"], "tag": tag_name}]}
url = self.get_kibana_url() + "/api/beats/agents_tags/assignments"
r = requests.post(url, json=data, headers=headers,
auth=('elastic', KIBANA_PASSWORD))
auth=(self.es_user, self.es_pass))
assert r.status_code == 200

def get_elasticsearch_url(self):
Expand Down