6 Commits

Author SHA1 Message Date
Matthew Oliver
e84ed57a72 py3: port cli form_signature and unit tests
This patch ports the form_signature cli `swift-form-signature`
and it's corrisponding tests to py3.

In essence in Py3 the HMAC function expects binary strings.

Change-Id: I5dded4ceb80f0cc595403775e8f9c17873e1e37b
2018-03-13 06:19:44 +00:00
Gábor Antal
488f88e30a Use more specific asserts in test/unit/cli tests
I changed asserts with more specific assert methods.
e.g.: from assertTrue(sth == None) to assertIsNone(*) or
assertTrue(isinstance(inst, type)) to assertIsInstace(inst, type)
or assertTrue(not sth) to assertFalse(sth).

The code gets more readable, and a better description will be shown on fail.

Change-Id: I39305808ad2349dc11a42261b41dbb347ac0618a
2016-08-03 12:19:40 +00:00
Sarafraj Singh
13edc9a865 Improved test coverage of form_signature
Added four new test cases to execute path of invalid arguments. This
improved test coverage of file specified from 80% to 91%.

Change-Id: I63c2e7bab3f01121301d78b687687208a58401c0
2016-02-05 19:17:30 +00:00
Victor Stinner
6e70f3fa32 Get StringIO and cStringIO from six.moves
* replace "from cStringIO import StringIO"
  with "from six.moves import cStringIO as StringIO"
* replace "from StringIO import StringIO"
  with "from six import StringIO"
* replace "import cStringIO" and "cStringIO.StringIO()"
  with "from six import moves" and "moves.cStringIO()"
* replace "import StringIO" and "StringIO.StringIO()"
  with "import six" and "six.StringIO()"

This patch was generated by the stringio operation of the sixer tool:
https://pypi.python.org/pypi/sixer

Change-Id: Iacba77fec3045f96773d1090c0bd48613729a561
2015-07-15 16:56:33 +02:00
Samuel Merritt
2b55709625 Make swift-form-signature output a sample form
swift-form-signature would give you the required expiration-time and
HMAC signature, but it wouldn't help you actually construct the HTML
form. To do that, you had to go look at the formpost middleware's doc
string and make up a form yourself.

For convenience, this commit makes swift-form-signature output a
sample form with the computed values filled in already; the user only
needs to fill in the Swift cluster's hostname.

Change-Id: I70d70a648b78b382dbfbe8ff918e6158a7f6a0ab
2014-08-05 11:11:03 -07:00
Samuel Merritt
4f2bb9f271 Make swift-form-signature testable
Moved the body of bin/swift-form-signature into
swift/cli/form_signature.py, like was done with swift-ring-builder and
others. Added a couple basic tests; there's not 100% coverage, but
it's better than the 0% coverage we had before.

It's almost a straight forklift, but I changed exit() calls to return
statements.

Change-Id: Ie2f702c070da24d9cdface83b9e838e9e2965085
2014-07-24 14:38:53 -07:00