test_secrets.py revision 01022614d46c7548d3f1b2c048bf9e1b0ed094fd
#
# Secrets responder integration tests
#
# Copyright (c) 2016 Red Hat, Inc.
#
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 only
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import os
import stat
import config
import signal
import subprocess
import time
import socket
import pytest
from secrets import SecretsLocalClient
"""Generate sssd.conf and add teardown for removing it"""
raise Exception("failed to regenerate confdb")
if secpid == 0:
raise Exception("sssd_secrets failed to start")
try:
except:
else:
break
def sec_teardown():
if secpid == 0:
return
def setup_for_secrets(request):
"""
Just set up the local provider for tests and enable the secrets
responder
"""
[sssd]
domains = local
services = nss
id_provider = local
[secrets]
max_secrets = 10
return None
def secrets_cli(request):
return cli
"""
Test that the basic Create, Retrieve, Delete operations work
"""
# Listing a totally empty database yields a 404 error, no secrets are there
# Set some value, should succeed
assert fooval == "bar"
# Listing secrets should work now as well
assert "foo" in secrets
# Overwriting a secret is an error
# Delete a secret
# Delete a non-existent secret must yield a 404
# Don't allow storing more secrets after reaching the max
# number of entries.
MAX_SECRETS = 10
sec_value = "value"
for x in xrange(MAX_SECRETS):
"""
Test that storing secrets inside containers works
"""
# No trailing slash, no game..
# Removing a non-empty container should not succeed
# Try removing the secret first, then the container
# Don't allow creating a container after reaching the max nested level
container = "mycontainer"
for x in xrange(DEFAULT_CONTAINERS_NEST_LEVEL):