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

updated checks for wildcards in StoragePasswords #464

Merged
merged 1 commit into from Jun 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions splunklib/client.py
Expand Up @@ -1846,8 +1846,6 @@ class StoragePasswords(Collection):
instance. Retrieve this collection using :meth:`Service.storage_passwords`.
"""
def __init__(self, service):
if service.namespace.owner == '-' or service.namespace.app == '-':
raise ValueError("StoragePasswords cannot have wildcards in namespace.")
super(StoragePasswords, self).__init__(service, PATH_STORAGE_PASSWORDS, item=StoragePassword)

def create(self, password, username, realm=None):
Expand All @@ -1865,6 +1863,9 @@ def create(self, password, username, realm=None):

:return: The :class:`StoragePassword` object created.
"""
if self.service.namespace.owner == '-' or self.service.namespace.app == '-':
raise ValueError("While creating StoragePasswords, namespace cannot have wildcards.")

if not isinstance(username, six.string_types):
raise ValueError("Invalid name: %s" % repr(username))

Expand Down Expand Up @@ -1896,6 +1897,9 @@ def delete(self, username, realm=None):
:return: The `StoragePassword` collection.
:rtype: ``self``
"""
if self.service.namespace.owner == '-' or self.service.namespace.app == '-':
raise ValueError("app context must be specified when removing a password.")

if realm is None:
# This case makes the username optional, so
# the full name can be passed in as realm.
Expand Down