Skip to content

Commit

Permalink
Disallow snapshot names with uppercase chars
Browse files Browse the repository at this point in the history
  • Loading branch information
untergeek committed Mar 7, 2016
1 parent 629daaf commit 1d86af6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,5 @@ Contributors:
* (pbamba)
* Pavel Strashkin (xaka)
* Wadim Kruse (wkruse)
* Richard Megginson (richm)
* Thibaut Ackermann (thib-ack)
9 changes: 9 additions & 0 deletions curator/cli/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,13 @@ def snapshot(
logger.error('Missing required parameter --repository')
msgout('Missing required parameter --repository', error=True, quiet=ctx.parent.params['quiet'])
sys.exit(1)
# Check if `name` contains upper-case characters, which are forbidden #562
if True in map(str.isupper,name):
msgout(
'Snapshot name: "{0}" contains upper-case characters, which are not allowed.'.format(name),
error=True,
quiet=ctx.parent.params['quiet']
)
logger.error('Snapshot name: "{0}" contains upper-case characters, which are not allowed.'.format(name))
sys.exit(1)
snapshot.add_command(indices)
5 changes: 5 additions & 0 deletions docs/Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ Changelog

**Bug fixes**

* Prevent users from creating snapshots with upper-case letters, which is not
permitted by Elasticsearch. #562 (untergeek)
* Remove `print()` command from ``setup.py`` as it causes issues with command-
line retrieval of ``--url``, etc. #568 (thib-ack)



3.4.1 (10 February 2016)
Expand Down
16 changes: 16 additions & 0 deletions test/integration/test_cli_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,22 @@ def test_snapshot_no_repository_param(self):
],
obj={"filters":[]})
self.assertEqual(1, result.exit_code)
def test_snapshot_name_with_uppercase_chars(self):
test = clicktest.CliRunner()
result = test.invoke(
curator.cli,
[
'--logfile', os.devnull,
'--host', host,
'--port', str(port),
'snapshot',
'--repository', self.args['repository'],
'--name', 'BadSnapName',
'indices',
'--all-indices',
],
obj={"filters":[]})
self.assertEqual(1, result.exit_code)
def test_cli_snapshot_indices(self):
self.create_indices(5)
self.create_repository()
Expand Down

0 comments on commit 1d86af6

Please sign in to comment.