12 Commits

Author SHA1 Message Date
Riccardo Pittau
8111475eb0 Use Werkzeug modern version
Request class from Werkzeug now includes json capability by default.
See [1] and [2] for more info.

[1] 2cd4fa9484
[2] 7b52ecd8f3

Change-Id: I3c74b26ef4aff07c371364203a5b39c658b552a7
2022-04-14 10:47:06 +00:00
Riccardo Pittau
d5d62c8dbf Use unittest mock from standard library
Drop the third party mock library to use unittest mock from
standard library.

Change-Id: Ib64b661572e4869a24865c02a6c84a6603930394
2020-04-06 14:35:50 +02:00
Julia Kreger
af5f05a0ee Agent token support
Adds support to the agent to receive, store, and return
that token to ironic's API, when supported.

This feature allows ironic and ultimately the agent to
authenticate interactions, when supported, to prevent
malicious abuse of the API endpoint.

Sem-Ver: feature
Change-Id: I6db9117a38be946b785e6f5e75ada1bfdff560ba
2020-03-12 10:35:17 -07:00
Dmitry Tantsur
f1b2df908a Replace WSME and Pecan with Werkzeug
WSME is no longer maintained and Pecan is an overkill for our (purely
internal) API. This change rewrites the API in Werkzeug (the library
underneath Flask). I don't use Flask here since it's also an overkill
for API with 4 meaningful endpoints.

Change-Id: Ifed45f70869adf00e795202a53a2a53c9c57ef30
2019-12-04 16:50:47 +01:00
Julian Edwards
f57cbccf8b Prevent tests' unmocked access to utils.execute()
This change introduces a new base test class that mocks out
utils.execute and forces an exception if it gets called.
This has rooted out many tests that were doing this as a side effect of
calling other functions, doing things like modprobe and running iscsi
on the host's actual machine.

The tests are all now appropriately patched in places where this was
happening, and the new base class permanently prevents this from
accidentally happening again.

If you really want to call utils.execute() then you need to re-mock it
in your unit test.

Change-Id: Idf87d09a9c01a6bfe2767f8becabe65c02983518
2017-05-15 10:48:43 +10:00
John L. Villalovos
1695cb18c2 Add missing 'autospec' argument to mock.patch
Add missing 'autospec' keyword argument to mock.patch and
mock.patch.object calls. Use 'autospec=True' except for a few cases
where it fails because the mocked function is a @classmethod and it
doesn't work. In that case explicity set it to 'autospec=False'

Change-Id: I620dce91abaa4440e1803aeefb3e93c0b65d1419
2017-03-19 10:04:19 -07:00
Jenkins
d63820af12 Merge "Removes the use of mutables as default args" 2016-06-20 17:25:29 +00:00
Edan David
438c69af7c Removes the use of mutables as default args
Passing mutable objects as default args is a known Python pitfall.
We'd better avoid this. This commit changes mutable default args with
None, 'arg = [] if arg is None else arg'.

TrivialFix

Change-Id: I384b24e81543999a8b873e3223cd409ed799ffa0
2016-06-20 02:08:12 -04:00
Edan David
1e8652a8d0 Use assertIn and assertNotIn
Tests should use:
  self.assertIn(value, list)
  self.assertNotIn(value, list)

instead of:
  self.assertTrue(value in list)
  self.assertFalse(value in list)

because assertIn and assertNotIn raise more meaningful errors:
  self.assertIn(3, [1, 2]
  >>> MismatchError: 3 not in [1, 2]

  self.assertTrue(3 in [1, 2])
  >>> AssertionError: False is not true

Change-Id: I2d1c78fe71fe03e350b1035123b0a48b7186a6ec
Closes-Bug: #1510007
2016-06-17 12:01:43 -04:00
Edan David
fda09be319 Remove unused parameter
unit.test_api have an unused parameter in _make_app.

Change-Id: I1e313803e43a0e69c547695333116cc0432043da
2016-06-14 10:21:26 -04:00
Kan
2b07976b94 Fix params order in assertEqual
Fix params order to correspond to real signature:
    assertEqual(expected, actual)

Change-Id: I129aad5d8bb7ca0541c07913cb5edd8eef9e90ba
Closes-Bug: #1277104
2016-01-13 02:03:11 +00:00
Josh Gachnang
fb2790774d Add base for IPA functional tests
Starts up an agent in a thread and then runs functional tests against
it.

Add the first functional test of the API: a simple test of the
commands API.

Co-Authored-By: Mario Villaplana <mario.villaplana@gmail.com>
Change-Id: If4ad611929d388a2a9454224646cb296bd0ba0ce
2015-08-18 16:19:47 +00:00