Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Commit

Permalink
[elasticsearch] Adding testing for security context
Browse files Browse the repository at this point in the history
Template tests for the changes from #171
  • Loading branch information
Crazybus committed Jul 9, 2019
1 parent d307ebf commit 5586ddb
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions elasticsearch/tests/elasticsearch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,3 +721,50 @@ def test_esMajorVersion_parse_image_tag_for_oss_image():

r = helm_template(config)
assert r['statefulset'][uname]['metadata']['annotations']['esMajorVersion'] == '6'

def test_set_pod_security_context():
config = ''
r = helm_template(config)
assert r['statefulset'][uname]['spec']['template']['spec']['securityContext']['fsGroup'] == 1000

config = '''
podSecurityContext:
fsGroup: 1001
other: test
'''

r = helm_template(config)

assert r['statefulset'][uname]['spec']['template']['spec']['securityContext']['fsGroup'] == 1001
assert r['statefulset'][uname]['spec']['template']['spec']['securityContext']['other'] == 'test'

def test_fsGroup_backwards_compatability():
config = '''
fsGroup: 1001
'''

r = helm_template(config)

assert r['statefulset'][uname]['spec']['template']['spec']['securityContext']['fsGroup'] == 1001

def test_set_container_security_context():
config = ''

r = helm_template(config)
c = r['statefulset'][uname]['spec']['template']['spec']['containers'][0]
assert c['securityContext']['capabilities']['drop'] == ['ALL']
assert c['securityContext']['runAsNonRoot'] == True
assert c['securityContext']['runAsUser'] == 1000

config = '''
securityContext:
runAsUser: 1001
other: test
'''

r = helm_template(config)
c = r['statefulset'][uname]['spec']['template']['spec']['containers'][0]
assert c['securityContext']['capabilities']['drop'] == ['ALL']
assert c['securityContext']['runAsNonRoot'] == True
assert c['securityContext']['runAsUser'] == 1001
assert c['securityContext']['other'] == 'test'

0 comments on commit 5586ddb

Please sign in to comment.