当前位置: 首页>>代码示例>>Python>>正文


Python test.get_config函数代码示例

本文整理汇总了Python中test.get_config函数的典型用法代码示例。如果您正苦于以下问题:Python get_config函数的具体用法?Python get_config怎么用?Python get_config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_config函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

def setUp(self):
    global _servers, proxy0_srv, proxy1_srv, webcache0_srv, proxy0_lis, \
        proxy1_lis, webcache0_lis
    nl = NullLogger()
    conf = get_config()
    proxy0_lis = listen(('localhost', 8080))
    proxy1_lis = listen(('localhost', 18080))
    webcache0_lis = listen(('localhost', 8888))
    proxy0_srv = DummySrv('http://127.0.0.1:8080')
    proxy1_srv = DummySrv('http://127.0.0.1:18080')
    webcache0_srv = DummySrv('http://127.0.0.1:8888')
    proxy0_spa = spawn(wsgi.server, proxy0_lis, proxy0_srv, nl)
    proxy1_spa = spawn(wsgi.server, proxy1_lis, proxy1_srv, nl)
    webcache0_spa = spawn(wsgi.server, webcache0_lis, webcache0_srv, nl)
    _servers = (proxy0_spa, proxy1_spa, webcache0_spa)
开发者ID:AsherBond,项目名称:colony,代码行数:15,代码来源:test_dispatcher.py

示例2: setUp

    def setUp(self):
        self.conf = get_config()
        if self.conf.get('auth_ssl', 'no') == 'yes':
            auth_method = 'https://'
        else:
            auth_method = 'http://'
        auth_host = (self.conf.get('auth_host') + ':' +
                     self.conf.get('auth_port'))
        auth_url = (auth_method + auth_host +
                    self.conf.get('auth_prefix') + 'v1.0')
        try:
            rets = get_auth(auth_url, (self.conf.get('account') + ':' +
                                       self.conf.get('username')),
                            self.conf.get('password'))
            self.auth_token = rets[1]
            #Parse the storage root and get the access root for CDMI
            pieces = rets[0].partition('/v1/')
            self.os_access_root = '/v1/' + pieces[2]
            self.access_root = ('/' + self.conf.get('cdmi_root', 'cdmi') +
                                '/' + pieces[2])
            self.cdmi_capability_root = ('/' +
                                         self.conf.get('cdmi_root', 'cdmi') +
                                         '/' +
                                         self.conf.get('cdmi_capability_id',
                                                       'cdmi_capabilities') +
                                         '/' + pieces[2])
            #Setup two container names
            suffix = format(time.time(), '.6f')
            self.top_container = 'cdmi_test_top_container_' + suffix
            self.child_container = 'cdmi_test_child_container_' + suffix
            self.object_create = 'cdmi_test_object_create_' + suffix
            self.object_test = 'cdmi_test_object_' + suffix

            #Create test containers
            self.__create_test_container(self.top_container)
            self.__create_test_container(self.top_container + '/' +
                                         self.child_container)
            self.__create_test_container(self.top_container + '/a/b/c/d/e/f')
            self.__create_test_container(self.top_container + '/a/b/c/d')
            self.__create_test_object(self.top_container + '/' +
                                      self.child_container + '/' +
                                      self.object_test)
            self.__create_test_object(self.top_container + '/a/b/cc')

        except Exception as login_error:
            raise login_error
开发者ID:litong01,项目名称:cdmi,代码行数:46,代码来源:test_cdmi_object.py

示例3: get_cluster_info

def get_cluster_info():
    # The fallback constraints used for testing will come from the current
    # effective constraints.
    eff_constraints = dict(constraints.EFFECTIVE_CONSTRAINTS)

    # We'll update those constraints based on what the /info API provides, if
    # anything.
    global cluster_info
    global config
    try:
        conn = Connection(config)
        conn.authenticate()
        cluster_info.update(conn.cluster_info())
    except (ResponseError, socket.error):
        # Failed to get cluster_information via /info API, so fall back on
        # test.conf data
        pass
    else:
        try:
            eff_constraints.update(cluster_info['swift'])
        except KeyError:
            # Most likely the swift cluster has "expose_info = false" set
            # in its proxy-server.conf file, so we'll just do the best we
            # can.
            print("** Swift Cluster not exposing /info **", file=sys.stderr)

    # Finally, we'll allow any constraint present in the swift-constraints
    # section of test.conf to override everything. Note that only those
    # constraints defined in the constraints module are converted to integers.
    test_constraints = get_config('swift-constraints')
    for k in constraints.DEFAULT_CONSTRAINTS:
        try:
            test_constraints[k] = int(test_constraints[k])
        except KeyError:
            pass
        except ValueError:
            print("Invalid constraint value: %s = %s" % (
                k, test_constraints[k]), file=sys.stderr)
    eff_constraints.update(test_constraints)

    # Just make it look like these constraints were loaded from a /info call,
    # even if the /info call failed, or when they are overridden by values
    # from the swift-constraints section of test.conf
    cluster_info['swift'] = eff_constraints
开发者ID:mahak,项目名称:swift,代码行数:44,代码来源:__init__.py

示例4: setUp

 def setUp(self):
     self.conf = get_config()
     if self.conf.get("auth_ssl", "no") == "yes":
         auth_method = "https://"
     else:
         auth_method = "http://"
     auth_host = self.conf.get("auth_host") + ":" + self.conf.get("auth_port")
     auth_url = auth_method + auth_host + self.conf.get("auth_prefix") + "v1.0"
     try:
         rets = get_auth(
             auth_url, (self.conf.get("account") + ":" + self.conf.get("username")), self.conf.get("password")
         )
         self.auth_token = rets[1]
         # Parse the storage root and get the access root for CDMI
         pieces = rets[0].partition("/v1/")
         self.os_access_root = "/v1/" + pieces[2]
         self.access_root = "/" + self.conf.get("cdmi_root", "cdmi") + "/" + pieces[2]
         self.cdmi_capability_root = (
             "/"
             + self.conf.get("cdmi_root", "cdmi")
             + "/"
             + self.conf.get("cdmi_capability_id", "cdmi_capabilities")
             + "/"
             + pieces[2]
         )
         # Setup two container names
         suffix = format(time.time(), ".6f")
         self.child_container = "cdmi_test_child_container_" + suffix
         self.top_container = "cdmi_test_top_container_" + suffix
         self.child_container_to_create = "cdmi_test_child_container_create_" + suffix
         self.top_container_to_create = "cdmi_test_top_container_create_" + suffix
         self.top_container_to_delete = "cdmi_test_top_container_delete_" + suffix
         # Create test containers
         self.__create_test_container(self.top_container)
         self.__create_test_container(self.top_container + "/" + self.child_container)
         self.__create_test_container(self.top_container_to_delete)
         self.__create_test_container(self.top_container + "/a/b/c/d/e/f")
     except Exception as login_error:
         raise login_error
开发者ID:litong01,项目名称:cdmi,代码行数:39,代码来源:test_cdmi_container.py

示例5: DebugLogAdapter

    return DebugLogAdapter(DebugLogger(), name)


original_syslog_handler = logging.handlers.SysLogHandler


def fake_syslog_handler():
    for attr in dir(original_syslog_handler):
        if attr.startswith("LOG"):
            setattr(FakeLogger, attr, copy.copy(getattr(logging.handlers.SysLogHandler, attr)))
    FakeLogger.priority_map = copy.deepcopy(logging.handlers.SysLogHandler.priority_map)

    logging.handlers.SysLogHandler = FakeLogger


if config_true_value(get_config("unit_test").get("fake_syslog", "False")):
    fake_syslog_handler()


class MockTrue(object):
    """
    Instances of MockTrue evaluate like True
    Any attr accessed on an instance of MockTrue will return a MockTrue
    instance. Any method called on an instance of MockTrue will return
    a MockTrue instance.

    >>> thing = MockTrue()
    >>> thing
    True
    >>> thing == True # True == True
    True
开发者ID:kelsieflynn,项目名称:swift,代码行数:31,代码来源:__init__.py

示例6: fake_syslog_handler

original_syslog_handler = logging.handlers.SysLogHandler


def fake_syslog_handler():
    for attr in dir(original_syslog_handler):
        if attr.startswith('LOG'):
            setattr(FakeLogger, attr,
                    copy.copy(getattr(logging.handlers.SysLogHandler, attr)))
    FakeLogger.priority_map = \
        copy.deepcopy(logging.handlers.SysLogHandler.priority_map)

    logging.handlers.SysLogHandler = FakeLogger


if get_config('unit_test').get('fake_syslog', 'False').lower() in TRUE_VALUES:
    fake_syslog_handler()


class MockTrue(object):
    """
    Instances of MockTrue evaluate like True
    Any attr accessed on an instance of MockTrue will return a MockTrue
    instance. Any method called on an instance of MockTrue will return
    a MockTrue instance.

    >>> thing = MockTrue()
    >>> thing
    True
    >>> thing == True # True == True
    True
开发者ID:Nupta,项目名称:swift,代码行数:30,代码来源:__init__.py

示例7: get_config

from test import get_config
from swift.common.utils import config_true_value

config = get_config("probe_test")
CHECK_SERVER_TIMEOUT = int(config.get("check_server_timeout", 30))
VALIDATE_RSYNC = config_true_value(config.get("validate_rsync", False))
开发者ID:iloveyou416068,项目名称:swift-1,代码行数:6,代码来源:__init__.py

示例8: setup_package

def setup_package():

    global policy_specified
    global skip_if_no_xattrs
    policy_specified = os.environ.get('SWIFT_TEST_POLICY')
    in_process_env = os.environ.get('SWIFT_TEST_IN_PROCESS')
    if in_process_env is not None:
        use_in_process = utils.config_true_value(in_process_env)
    else:
        use_in_process = None

    global in_process

    global config
    if use_in_process:
        # Explicitly set to True, so barrel on ahead with in-process
        # functional test setup.
        in_process = True
        # NOTE: No attempt is made to a read local test.conf file.
    else:
        if use_in_process is None:
            # Not explicitly set, default to using in-process functional tests
            # if the test.conf file is not found, or does not provide a usable
            # configuration.
            config.update(get_config('func_test'))
            if not config:
                in_process = True
            # else... leave in_process value unchanged. It may be that
            # setup_package is called twice, in which case in_process_setup may
            # have loaded config before we reach here a second time, so the
            # existence of config is not reliable to determine that in_process
            # should be False. Anyway, it's default value is False.
        else:
            # Explicitly set to False, do not attempt to use in-process
            # functional tests, be sure we attempt to read from local
            # test.conf file.
            in_process = False
            config.update(get_config('func_test'))

    if in_process:
        in_mem_obj_env = os.environ.get('SWIFT_TEST_IN_MEMORY_OBJ')
        in_mem_obj = utils.config_true_value(in_mem_obj_env)
        skip_if_no_xattrs = real_skip_if_no_xattrs
        try:
            in_process_setup(the_object_server=(
                mem_object_server if in_mem_obj else object_server))
        except InProcessException as exc:
            print(('Exception during in-process setup: %s'
                   % str(exc)), file=sys.stderr)
            raise
    else:
        skip_if_no_xattrs = lambda: None

    global web_front_end
    web_front_end = config.get('web_front_end', 'integral')
    global normalized_urls
    normalized_urls = config.get('normalized_urls', False)

    global orig_collate
    orig_collate = locale.setlocale(locale.LC_COLLATE)
    locale.setlocale(locale.LC_COLLATE, config.get('collate', 'C'))

    global insecure
    insecure = config_true_value(config.get('insecure', False))

    global swift_test_auth_version
    global swift_test_auth
    global swift_test_user
    global swift_test_key
    global swift_test_tenant
    global swift_test_perm
    global swift_test_domain
    global swift_test_service_prefix

    swift_test_service_prefix = None

    if config:
        swift_test_auth_version = str(config.get('auth_version', '1'))

        if 'auth_uri' in config:
            swift_test_auth = config['auth_uri']
            # Back-fill the individual parts -- really, we should just need
            # host and port for s3_test_client, and that's only until we
            # improve it to take a s3_storage_url option
            parsed = urlsplit(config['auth_uri'])
            config.update({
                'auth_ssl': str(parsed.scheme == 'https'),
                'auth_host': parsed.hostname,
                'auth_port': str(
                    parsed.port if parsed.port is not None else
                    443 if parsed.scheme == 'https' else 80),
                'auth_prefix': parsed.path,
            })
        elif 'auth_host' in config:
            scheme = 'http'
            if config_true_value(config.get('auth_ssl', 'no')):
                scheme = 'https'
            netloc = config['auth_host']
            if 'auth_port' in config:
                netloc += ':' + config['auth_port']
#.........这里部分代码省略.........
开发者ID:mahak,项目名称:swift,代码行数:101,代码来源:__init__.py

示例9: fake_syslog_handler

original_syslog_handler = logging.handlers.SysLogHandler


def fake_syslog_handler():
    for attr in dir(original_syslog_handler):
        if attr.startswith('LOG'):
            setattr(FakeLogger, attr,
                    copy.copy(getattr(logging.handlers.SysLogHandler, attr)))
    FakeLogger.priority_map = \
        copy.deepcopy(logging.handlers.SysLogHandler.priority_map)

    logging.handlers.SysLogHandler = FakeLogger


if utils.config_true_value(
        get_config('unit_test').get('fake_syslog', 'False')):
    fake_syslog_handler()


@contextmanager
def quiet_eventlet_exceptions():
    orig_state = greenpool.DEBUG
    eventlet_debug.hub_exceptions(False)
    try:
        yield
    finally:
        eventlet_debug.hub_exceptions(orig_state)


class MockTrue(object):
    """
开发者ID:clayg,项目名称:swift,代码行数:31,代码来源:__init__.py

示例10: setup_package

def setup_package():
    global config
    config.update(get_config('func_test'))
    for k in constraints.DEFAULT_CONSTRAINTS:
        if k in config:
            # prefer what's in test.conf
            config[k] = int(config[k])
        elif constraints.SWIFT_CONSTRAINTS_LOADED:
            # swift.conf exists, so use what's defined there (or swift
            # defaults) This normally happens when the test is running locally
            # to the cluster as in a SAIO.
            config[k] = constraints.EFFECTIVE_CONSTRAINTS[k]
        else:
            # .functests don't know what the constraints of the tested cluster
            # are, so the tests can't reliably pass or fail. Therefore, skip
            # those tests.
            config[k] = '%s constraint is not defined' % k

    global web_front_end
    web_front_end = config.get('web_front_end', 'integral')
    global normalized_urls
    normalized_urls = config.get('normalized_urls', False)

    global orig_collate
    orig_collate = locale.setlocale(locale.LC_COLLATE)
    locale.setlocale(locale.LC_COLLATE, config.get('collate', 'C'))

    global swift_test_auth_version
    global swift_test_auth
    global swift_test_user
    global swift_test_key
    global swift_test_tenant
    global swift_test_perm

    if config:
        swift_test_auth_version = str(config.get('auth_version', '1'))

        swift_test_auth = 'http'
        if config.get('auth_ssl', 'no').lower() in ('yes', 'true', 'on', '1'):
            swift_test_auth = 'https'
        if 'auth_prefix' not in config:
            config['auth_prefix'] = '/'
        try:
            suffix = '://%(auth_host)s:%(auth_port)s%(auth_prefix)s' % config
            swift_test_auth += suffix
        except KeyError:
            pass  # skip

        if swift_test_auth_version == "1":
            swift_test_auth += 'v1.0'

            try:
                if 'account' in config:
                    swift_test_user[0] = '%(account)s:%(username)s' % config
                else:
                    swift_test_user[0] = '%(username)s' % config
                swift_test_key[0] = config['password']
            except KeyError:
                # bad config, no account/username configured, tests cannot be
                # run
                pass
            try:
                swift_test_user[1] = '%s%s' % (
                    '%s:' % config['account2'] if 'account2' in config else '',
                    config['username2'])
                swift_test_key[1] = config['password2']
            except KeyError:
                pass  # old config, no second account tests can be run
            try:
                swift_test_user[2] = '%s%s' % (
                    '%s:' % config['account'] if 'account'
                    in config else '', config['username3'])
                swift_test_key[2] = config['password3']
            except KeyError:
                pass  # old config, no third account tests can be run

            for _ in range(3):
                swift_test_perm[_] = swift_test_user[_]

        else:
            swift_test_user[0] = config['username']
            swift_test_tenant[0] = config['account']
            swift_test_key[0] = config['password']
            swift_test_user[1] = config['username2']
            swift_test_tenant[1] = config['account2']
            swift_test_key[1] = config['password2']
            swift_test_user[2] = config['username3']
            swift_test_tenant[2] = config['account']
            swift_test_key[2] = config['password3']

            for _ in range(3):
                swift_test_perm[_] = swift_test_tenant[_] + ':' \
                    + swift_test_user[_]

    global skip
    skip = not all([swift_test_auth, swift_test_user[0], swift_test_key[0]])
    if skip:
        print >>sys.stderr, 'SKIPPING FUNCTIONAL TESTS DUE TO NO CONFIG'

    global skip2
#.........这里部分代码省略.........
开发者ID:kazum,项目名称:swift,代码行数:101,代码来源:__init__.py

示例11: setup_package

def setup_package():
    global config
    config.update(get_config('func_test'))

    global web_front_end
    web_front_end = config.get('web_front_end', 'integral')
    global normalized_urls
    normalized_urls = config.get('normalized_urls', False)

    global orig_collate
    orig_collate = locale.setlocale(locale.LC_COLLATE)
    locale.setlocale(locale.LC_COLLATE, config.get('collate', 'C'))

    global swift_test_auth_version
    global swift_test_auth
    global swift_test_user
    global swift_test_key
    global swift_test_tenant
    global swift_test_perm

    if config:
        swift_test_auth_version = str(config.get('auth_version', '1'))

        swift_test_auth = 'http'
        if config.get('auth_ssl', 'no').lower() in ('yes', 'true', 'on', '1'):
            swift_test_auth = 'https'
        if 'auth_prefix' not in config:
            config['auth_prefix'] = '/'
        try:
            suffix = '://%(auth_host)s:%(auth_port)s%(auth_prefix)s' % config
            swift_test_auth += suffix
        except KeyError:
            pass  # skip

        if swift_test_auth_version == "1":
            swift_test_auth += 'v1.0'

            try:
                if 'account' in config:
                    swift_test_user[0] = '%(account)s:%(username)s' % config
                else:
                    swift_test_user[0] = '%(username)s' % config
                swift_test_key[0] = config['password']
            except KeyError:
                # bad config, no account/username configured, tests cannot be
                # run
                pass
            try:
                swift_test_user[1] = '%s%s' % (
                    '%s:' % config['account2'] if 'account2' in config else '',
                    config['username2'])
                swift_test_key[1] = config['password2']
            except KeyError:
                pass  # old config, no second account tests can be run
            try:
                swift_test_user[2] = '%s%s' % (
                    '%s:' % config['account'] if 'account'
                    in config else '', config['username3'])
                swift_test_key[2] = config['password3']
            except KeyError:
                pass  # old config, no third account tests can be run

            for _ in range(3):
                swift_test_perm[_] = swift_test_user[_]

        else:
            swift_test_user[0] = config['username']
            swift_test_tenant[0] = config['account']
            swift_test_key[0] = config['password']
            swift_test_user[1] = config['username2']
            swift_test_tenant[1] = config['account2']
            swift_test_key[1] = config['password2']
            swift_test_user[2] = config['username3']
            swift_test_tenant[2] = config['account']
            swift_test_key[2] = config['password3']

            for _ in range(3):
                swift_test_perm[_] = swift_test_tenant[_] + ':' \
                    + swift_test_user[_]

    global skip
    skip = not all([swift_test_auth, swift_test_user[0], swift_test_key[0]])
    if skip:
        print >>sys.stderr, 'SKIPPING FUNCTIONAL TESTS DUE TO NO CONFIG'

    global skip2
    skip2 = not all([not skip, swift_test_user[1], swift_test_key[1]])
    if not skip and skip2:
        print >>sys.stderr, \
            'SKIPPING SECOND ACCOUNT FUNCTIONAL TESTS' \
            ' DUE TO NO CONFIG FOR THEM'

    global skip3
    skip3 = not all([not skip, swift_test_user[2], swift_test_key[2]])
    if not skip and skip3:
        print >>sys.stderr, \
            'SKIPPING THIRD ACCOUNT FUNCTIONAL TESTS DUE TO NO CONFIG FOR THEM'

    get_cluster_info()
开发者ID:brightbox,项目名称:swift,代码行数:99,代码来源:__init__.py

示例12: get_config

#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import unittest

from webob import Request
from test import get_config
from swift.common.middleware import healthcheck

config = get_config()

class FakeApp(object):
    def __call__(self, env, start_response):
        return "FAKE APP"

def start_response(*args):
    pass

class TestHealthCheck(unittest.TestCase):

    def setUp(self):
        
        self.app = healthcheck.HealthCheckMiddleware(FakeApp(), config)

    def test_healthcheck(self):
开发者ID:lixmgl,项目名称:Intern_OpenStack_Swift,代码行数:31,代码来源:test_healthcheck.py

示例13: get_config

import errno
import os
import socket
import sys
from httplib import HTTPException
from time import sleep
from nose import SkipTest
from ConfigParser import MissingSectionHeaderError

from test import get_config

from chase.common.client import get_auth, http_connection

conf = get_config()

# If no conf was read, we will fall back to old school env vars
chase_test_auth = os.environ.get('CHASE_TEST_AUTH')
chase_test_user = [os.environ.get('CHASE_TEST_USER'), None, None]
chase_test_key = [os.environ.get('CHASE_TEST_KEY'), None, None]

if conf:
    chase_test_auth = 'http'
    if conf.get('auth_ssl', 'no').lower() in ('yes', 'true', 'on', '1'):
        chase_test_auth = 'https'
    if 'auth_prefix' not in conf:
        conf['auth_prefix'] = '/'
    try:
        chase_test_auth += \
                '://%(auth_host)s:%(auth_port)s%(auth_prefix)sv1.0' % conf
    except KeyError:
        pass  # skip
开发者ID:wendy-king,项目名称:x7_venv,代码行数:31,代码来源:chase_testing.py

示例14: test_tempauth_account_acls

    def test_tempauth_account_acls(self):
        if skip:
            raise SkipTest

        # Determine whether this cluster has account ACLs; if not, skip test
        conn = Connection(get_config('func_test'))
        conn.authenticate()
        cluster_info = conn.cluster_info()
        if not cluster_info.get('tempauth', {}).get('account_acls'):
            raise SkipTest
        if 'keystoneauth' in cluster_info:
            # Unfortunate hack -- tempauth (with account ACLs) is expected
            # to play nice with Keystone (without account ACLs), but Zuul
            # functest framework doesn't give us an easy way to get a
            # tempauth user.
            raise SkipTest

        def post(url, token, parsed, conn, headers):
            new_headers = dict({'X-Auth-Token': token}, **headers)
            conn.request('POST', parsed.path, '', new_headers)
            return check_response(conn)

        def put(url, token, parsed, conn, headers):
            new_headers = dict({'X-Auth-Token': token}, **headers)
            conn.request('PUT', parsed.path, '', new_headers)
            return check_response(conn)

        def delete(url, token, parsed, conn, headers):
            new_headers = dict({'X-Auth-Token': token}, **headers)
            conn.request('DELETE', parsed.path, '', new_headers)
            return check_response(conn)

        def head(url, token, parsed, conn):
            conn.request('HEAD', parsed.path, '', {'X-Auth-Token': token})
            return check_response(conn)

        def get(url, token, parsed, conn):
            conn.request('GET', parsed.path, '', {'X-Auth-Token': token})
            return check_response(conn)

        try:
            # User1 can POST to their own account (and reset the ACLs)
            resp = retry(post, headers={'X-Account-Access-Control': '{}'},
                         use_account=1)
            resp.read()
            self.assertEqual(resp.status, 204)
            self.assertEqual(resp.getheader('X-Account-Access-Control'), None)

            # User1 can GET their own empty account
            resp = retry(get, use_account=1)
            resp.read()
            self.assertEqual(resp.status // 100, 2)
            self.assertEqual(resp.getheader('X-Account-Access-Control'), None)

            # User2 can't GET User1's account
            resp = retry(get, use_account=2, url_account=1)
            resp.read()
            self.assertEqual(resp.status, 403)

            # User1 is swift_owner of their own account, so they can POST an
            # ACL -- let's do this and make User2 (test_user[1]) an admin
            acl_user = swift_testing.swift_test_user[1]
            acl = {'admin': [acl_user]}
            headers = {'x-account-access-control': format_acl(
                version=2, acl_dict=acl)}
            resp = retry(post, headers=headers, use_account=1)
            resp.read()
            self.assertEqual(resp.status, 204)

            # User1 can see the new header
            resp = retry(get, use_account=1)
            resp.read()
            self.assertEqual(resp.status // 100, 2)
            data_from_headers = resp.getheader('x-account-access-control')
            expected = json.dumps(acl, separators=(',', ':'))
            self.assertEqual(data_from_headers, expected)

            # Now User2 should be able to GET the account and see the ACL
            resp = retry(head, use_account=2, url_account=1)
            resp.read()
            data_from_headers = resp.getheader('x-account-access-control')
            self.assertEqual(data_from_headers, expected)

            # Revoke User2's admin access, grant User2 read-write access
            acl = {'read-write': [acl_user]}
            headers = {'x-account-access-control': format_acl(
                version=2, acl_dict=acl)}
            resp = retry(post, headers=headers, use_account=1)
            resp.read()
            self.assertEqual(resp.status, 204)

            # User2 can still GET the account, but not see the ACL
            # (since it's privileged data)
            resp = retry(head, use_account=2, url_account=1)
            resp.read()
            self.assertEqual(resp.status, 204)
            self.assertEqual(resp.getheader('x-account-access-control'), None)

            # User2 can PUT and DELETE a container
            resp = retry(put, use_account=2, url_account=1,
#.........这里部分代码省略.........
开发者ID:konamo,项目名称:swift,代码行数:101,代码来源:test_account.py

示例15: get_config

# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from httplib import HTTPException
import os
import socket
import sys
from time import sleep

from test import get_config

from swiftclient import get_auth, http_connection

conf = get_config('func_test')
web_front_end = conf.get('web_front_end', 'integral')
normalized_urls = conf.get('normalized_urls', False)

# If no conf was read, we will fall back to old school env vars
swift_test_auth = os.environ.get('SWIFT_TEST_AUTH')
swift_test_user = [os.environ.get('SWIFT_TEST_USER'), None, None]
swift_test_key = [os.environ.get('SWIFT_TEST_KEY'), None, None]
swift_test_tenant = ['', '', '']
swift_test_perm = ['', '', '']

if conf:
    swift_test_auth_version = str(conf.get('auth_version', '1'))

    swift_test_auth = 'http'
    if conf.get('auth_ssl', 'no').lower() in ('yes', 'true', 'on', '1'):
开发者ID:674009287,项目名称:swift,代码行数:31,代码来源:swift_testing.py


注:本文中的test.get_config函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。