Fix usage of token fixture in shell tests

The way we were using the token fixture in the shell tests was modifying
the structure. If the test would get run by the same process, it would
then use the modified structure and the test would fail.

This uses deepcopy instead, so this way, we never modify that fixture.

Change-Id: Ib88feee7d7fe72c66b4e8af510f9f28411ac47df
This commit is contained in:
Juan Antonio Osorio Robles 2018-11-22 15:32:18 +02:00
parent f79650325f
commit a102757726
1 changed files with 5 additions and 2 deletions

View File

@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import copy
import mock
from oslo_serialization import jsonutils
@ -44,7 +45,8 @@ class CheckerTestCase(base.PolicyBaseTestCase):
is_admin = False
stdout = self._capture_stdout()
access_data = token_fixture.SCOPED_TOKEN_FIXTURE["token"]
access_data = copy.deepcopy(
token_fixture.SCOPED_TOKEN_FIXTURE["token"])
target = {
"project_id": access_data['project']['id']
}
@ -66,7 +68,8 @@ class CheckerTestCase(base.PolicyBaseTestCase):
def test_pass_rule_parameters_with_custom_target(self, call_mock):
apply_rule = None
is_admin = False
access_data = token_fixture.SCOPED_TOKEN_FIXTURE["token"]
access_data = copy.deepcopy(
token_fixture.SCOPED_TOKEN_FIXTURE["token"])
access_data['roles'] = [
role['name'] for role in access_data['roles']]
access_data['project_id'] = access_data['project']['id']