Fix fake DELETE in PlacementFixture

Currently functional tests cannot test the DELETE method on some API
endpoints, e.g.

    DELETE /placement/traits/{name}

This is because it is not setting the request headers to have the
right microversion API - this setting was added for GET / PUT / POST
in I681712ac37f732c7803c68f6c7d1eae9f2877d3d, but not for DELETE.
Therefore the microversion defaults to 1.0 which for some endpoints is
lower than the required version, e.g. the endpoint above requires a
minimum microversion of 1.6, which is when this API was introduced.

This results in any invocation of _fake_delete() receiving a 404
error, although this error has not been experienced so far because
nothing uses _fake_delete() yet.

In order to enable future functional tests which hit this API call,
set the request headers in a manner consistent with the other HTTP
methods for the same endpoint.

Change-Id: I2e2d9a9ae12404fe66eae64f8767e348012d7932
This commit is contained in:
Adam Spiers 2019-02-19 00:25:46 +00:00
parent e3c24da89a
commit 94d83e40e1
1 changed files with 3 additions and 1 deletions

View File

@ -144,7 +144,9 @@ class PlacementFixture(placement_fixtures.PlacementFixture):
# TODO(sbauza): The current placement NoAuthMiddleware returns a 401
# in case a token is not provided. We should change that by creating
# a fake token so we could remove adding the header below.
headers = {'x-auth-token': self.token}
self._update_headers_with_version(headers, **kwargs)
return self._client.delete(
url,
endpoint_override=self.endpoint,
headers={'x-auth-token': self.token})
headers=headers)