diff options
author | Jenkins <jenkins@review.openstack.org> | 2014-08-06 12:45:04 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2014-08-06 12:45:04 +0000 |
commit | 1f63e7ef61e6085764db7e344fb86c6f6d45704f (patch) | |
tree | 1b34ef8267cbc7b01d58d63d3c165e1cc3c9d64c | |
parent | c28749abb05135b80e38ae119d57a5fea2948342 (diff) | |
parent | 2b55709625e8687af9e867ec93b095864b701959 (diff) | |
download | swift-1f63e7ef61e6085764db7e344fb86c6f6d45704f.tar.gz |
Merge "Make swift-form-signature output a sample form"
-rw-r--r-- | swift/cli/form_signature.py | 41 | ||||
-rw-r--r-- | test/unit/cli/test_form_signature.py | 4 |
2 files changed, 45 insertions, 0 deletions
diff --git a/swift/cli/form_signature.py b/swift/cli/form_signature.py index 20452f36c..0aefaca37 100644 --- a/swift/cli/form_signature.py +++ b/swift/cli/form_signature.py @@ -46,6 +46,19 @@ def main(argv): print 'Example output:' print ' Expires: 1323842228' print ' Signature: 18de97e47345a82c4dbfb3b06a640dbb' + print + print 'Sample form:' + print + print('NOTE: the <form> tag\'s "action" attribute does not contain ' + 'the Swift cluster\'s hostname.') + print 'You should manually add it before using the form.' + print + print('<form action="/v1/a/c/o" method="POST" ' + 'enctype="multipart/form-data">') + print ' <input type="hidden" name="max_file_size" value="123" />' + print ' ... more HTML ...' + print ' <input type="submit" />' + print '</form>' return 1 path, redirect, max_file_size, max_file_count, seconds, key = argv[1:] try: @@ -83,4 +96,32 @@ def main(argv): sha1).hexdigest() print ' Expires:', expires print 'Signature:', sig + print '' + + print('Sample form:\n') + + print('NOTE: the <form> tag\'s "action" attribute does not ' + 'contain the Swift cluster\'s hostname.') + print('You should manually add it before using the form.\n') + + print('<form action="%s" method="POST" enctype="multipart/form-data">' + % path) + if redirect: + print(' <input type="hidden" name="redirect" value="%s" />' + % redirect) + print(' <input type="hidden" name="max_file_size" value="%d" />' + % max_file_size) + print(' <input type="hidden" name="max_file_count" value="%d" />' + % max_file_count) + print(' <input type="hidden" name="expires" value="%d" />' % expires) + print(' <input type="hidden" name="signature" value="%s" />' % sig) + print(' <!-- This signature allows for at most %d files, -->' + % max_file_count) + print(' <!-- but it may also have any smaller number. -->') + print(' <!-- Remove file inputs as needed. -->') + for i in range(max_file_count): + print(' <input type="file" name="file%d" />' % i) + print(' <br />') + print(' <input type="submit" />') + print('</form>') return 0 diff --git a/test/unit/cli/test_form_signature.py b/test/unit/cli/test_form_signature.py index fa2c9da90..3120f08cd 100644 --- a/test/unit/cli/test_form_signature.py +++ b/test/unit/cli/test_form_signature.py @@ -54,6 +54,10 @@ class TestFormSignature(unittest.TestCase): self.assertTrue("Expires: %d" % (the_time + expires,) in out.getvalue()) + sig_input = ('<input type="hidden" name="signature" value="%s" />' + % expected_signature) + self.assertTrue(sig_input in out.getvalue()) + def test_too_few_args(self): out = StringIO() with mock.patch('sys.stdout', out): |