forked from xhgit/webup-cloud
16 lines
811 B
Python
16 lines
811 B
Python
import unittest
|
|
from pathlib import Path
|
|
import yaml
|
|
|
|
|
|
class DeploymentPermissionsTests(unittest.TestCase):
|
|
def test_health_probe_can_list_pods_without_cluster_admin(self):
|
|
resources=list(yaml.safe_load_all((Path(__file__).parents[1]/'infra/k8s/sandbox-rbac.yaml').read_text()))
|
|
roles=[item for item in resources if item['kind']=='Role' and item['metadata']['name']=='sandbox-gateway']
|
|
self.assertEqual(1,len(roles))
|
|
self.assertTrue(any('pods' in rule['resources'] and 'list' in rule['verbs'] for rule in roles[0]['rules']))
|
|
self.assertFalse(any('*' in rule['resources'] or '*' in rule['verbs'] for rule in roles[0]['rules']))
|
|
for item in resources:
|
|
if item['kind']=='RoleBinding':
|
|
self.assertEqual('Role',item['roleRef']['kind'])
|