federation.idp use correct subprocess
keystone.common.environment sets up the correct subprocess implementation based on the environment that keystone is started in and this subprocess should be used instead of importing subprocess directly. This wasn't being done in keystone.contrib.federation.idp. Change-Id: Ib7b625b0d6bb5feccd251a0abfcdea59baee3ee4
This commit is contained in:
parent
fb9fbbafcd
commit
12ed2536d0
@ -12,7 +12,6 @@
|
||||
|
||||
import datetime
|
||||
import os
|
||||
import subprocess
|
||||
import uuid
|
||||
|
||||
from oslo_config import cfg
|
||||
@ -32,11 +31,14 @@ xmldsig = importutils.try_import("saml2.xmldsig")
|
||||
if not xmldsig:
|
||||
xmldsig = importutils.try_import("xmldsig")
|
||||
|
||||
from keystone.common import environment
|
||||
from keystone.common import utils
|
||||
from keystone import exception
|
||||
from keystone.i18n import _, _LE
|
||||
|
||||
|
||||
subprocess = environment.subprocess
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
|
||||
import os
|
||||
import random
|
||||
import subprocess
|
||||
from testtools import matchers
|
||||
import uuid
|
||||
|
||||
@ -33,6 +32,7 @@ if not xmldsig:
|
||||
xmldsig = importutils.try_import("xmldsig")
|
||||
|
||||
from keystone.auth import controllers as auth_controllers
|
||||
from keystone.common import environment
|
||||
from keystone.contrib.federation import controllers as federation_controllers
|
||||
from keystone.contrib.federation import idp as keystone_idp
|
||||
from keystone import exception
|
||||
@ -45,6 +45,8 @@ from keystone.tests.unit import test_v3
|
||||
from keystone.token.providers import common as token_common
|
||||
|
||||
|
||||
subprocess = environment.subprocess
|
||||
|
||||
CONF = cfg.CONF
|
||||
LOG = log.getLogger(__name__)
|
||||
ROOTDIR = os.path.dirname(os.path.abspath(__file__))
|
||||
@ -2637,8 +2639,8 @@ class SAMLGenerationTests(FederationTests):
|
||||
# the assertion as is without signing it
|
||||
return assertion_content
|
||||
|
||||
with mock.patch('subprocess.check_output',
|
||||
side_effect=mocked_subprocess_check_output):
|
||||
with mock.patch.object(subprocess, 'check_output',
|
||||
side_effect=mocked_subprocess_check_output):
|
||||
generator = keystone_idp.SAMLGenerator()
|
||||
response = generator.samlize_token(self.ISSUER, self.RECIPIENT,
|
||||
self.SUBJECT,
|
||||
@ -2906,7 +2908,7 @@ class SAMLGenerationTests(FederationTests):
|
||||
|
||||
@mock.patch('saml2.create_class_from_xml_string')
|
||||
@mock.patch('oslo_utils.fileutils.write_to_tempfile')
|
||||
@mock.patch('subprocess.check_output')
|
||||
@mock.patch.object(subprocess, 'check_output')
|
||||
def test__sign_assertion(self, check_output_mock,
|
||||
write_to_tempfile_mock, create_class_mock):
|
||||
write_to_tempfile_mock.return_value = 'tmp_path'
|
||||
@ -2917,7 +2919,7 @@ class SAMLGenerationTests(FederationTests):
|
||||
create_class_mock.assert_called_with(saml.Assertion, 'fakeoutput')
|
||||
|
||||
@mock.patch('oslo_utils.fileutils.write_to_tempfile')
|
||||
@mock.patch('subprocess.check_output')
|
||||
@mock.patch.object(subprocess, 'check_output')
|
||||
def test__sign_assertion_exc(self, check_output_mock,
|
||||
write_to_tempfile_mock):
|
||||
# If the command fails the command output is logged.
|
||||
|
Loading…
Reference in New Issue
Block a user