diff --git a/ironic_python_agent/agent.py b/ironic_python_agent/agent.py index 3cbba6bec..ef74bd2b4 100644 --- a/ironic_python_agent/agent.py +++ b/ironic_python_agent/agent.py @@ -269,19 +269,11 @@ class IronicPythonAgent(base.ExecuteCommandMixin): def validate_agent_token(self, token): # We did not get a token, i.e. None and - # we've previously seen a token, which is - # a mid-cluster upgrade case with long-running ramdisks. - if (not token and self.agent_token - and not self.agent_token_required): - # TODO(TheJulia): Rip this out during or after the V cycle. - LOG.warning('Agent token for requests are not required ' - 'by the conductor, yet we received a token. ' - 'Cluster may be mid-upgrade. Support to ' - 'not fail in this condition will be removed in ' - 'the Victoria development cycle.') - # Tell the API everything is okay. - return True - + # or we've not seen a token yet, so we + # cannot make a comparison, thus False. + if (not token or not self.agent_token): + return False + # Otherwise, compare the values. return self.agent_token == token def _get_route_source(self, dest): diff --git a/ironic_python_agent/api/app.py b/ironic_python_agent/api/app.py index f3e6b98df..6782ef915 100644 --- a/ironic_python_agent/api/app.py +++ b/ironic_python_agent/api/app.py @@ -236,7 +236,6 @@ class Application(object): if ('name' not in body or 'params' not in body or not isinstance(body['params'], dict)): raise http_exc.BadRequest('Missing or invalid name or params') - token = request.args.get('agent_token', None) if not self.agent.validate_agent_token(token): raise http_exc.Unauthorized( diff --git a/ironic_python_agent/tests/functional/base.py b/ironic_python_agent/tests/functional/base.py index 3155ac332..7c72486db 100644 --- a/ironic_python_agent/tests/functional/base.py +++ b/ironic_python_agent/tests/functional/base.py @@ -49,7 +49,7 @@ class FunctionalBase(test_base.BaseTestCase): lookup_timeout=300, lookup_interval=1, standalone=True, - agent_token=None) + agent_token='678123') self.process = multiprocessing.Process( target=self.agent.run) self.process.start() diff --git a/ironic_python_agent/tests/functional/test_commands.py b/ironic_python_agent/tests/functional/test_commands.py index c2b84cabb..13274641a 100644 --- a/ironic_python_agent/tests/functional/test_commands.py +++ b/ironic_python_agent/tests/functional/test_commands.py @@ -37,7 +37,8 @@ class TestCommands(base.FunctionalBase): # success is required for steps 3 and 4 to succeed. command = {'name': 'clean.get_clean_steps', 'params': {'node': self.node, 'ports': {}}} - response = self.request('post', 'commands', json=command, + response = self.request('post', 'commands/?agent_token=678123', + json=command, headers={'Content-Type': 'application/json'}) self.assertIsNone(response['command_error']) @@ -63,7 +64,8 @@ class TestCommands(base.FunctionalBase): def step_5_run_non_existent_command(self): fake_command = {'name': 'bad_extension.fake_command', 'params': {}} - self.request('post', 'commands', expect_error=404, json=fake_command) + self.request('post', 'commands/?agent_token=678123', + expect_error=404, json=fake_command) def positive_get_post_command_steps(self): """Returns generator with test steps sorted by step number."""