~canonical-platform-qa/snappy-ecosystem-tests/fixing_ci

« back to all changes in this revision

Viewing changes to snappy_ecosystem_tests/utils/storeconfig.py

  • Committer: Heber Parrucci
  • Date: 2017-02-15 19:14:19 UTC
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: heber.parrucci@canonical.com-20170215191419-a3549ap02gflc8rj
Addressing review feedback regarding credentials:
Now it is read from a user config file that is outside the repo in the host machine. If that config is not found, then it reads the credentials from env variables.
The idea is to store the config with the credentials in a private repository, and then Jenkins will get it and store in the host machine when running the tests.
The same mechanism is used in ubuntu-system-tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
import os
24
24
 
25
 
from snappy_ecosystem_tests.commons.config import CONFIG_STACK
26
 
from snappy_ecosystem_tests.utils.test_data import get_default_store_user
 
25
from snappy_ecosystem_tests.commons.config import (
 
26
    CONFIG_STACK,
 
27
    USER_CONFIG_STACK
 
28
)
27
29
 
28
 
URL_WEB_STORE_PRODUCTION = CONFIG_STACK.config.get('web-ui', 'production_url')
29
 
URL_WEB_STORE_STAGING = CONFIG_STACK.config.get('web-ui', 'stage_url')
 
30
URL_WEB_STORE_PRODUCTION = CONFIG_STACK.get('web-ui', 'production_url')
 
31
URL_WEB_STORE_STAGING = CONFIG_STACK.get('web-ui', 'stage_url')
30
32
 
31
33
 
32
34
def get_store_credentials():
33
 
    """login credentials exported by shell environment"""
34
 
    user = get_default_store_user()
35
 
    return user.get('user_email'), user.get('user_password')
 
35
    """Get user store credentials.
 
36
    It will retrieve the credentials stored in a user config file,
 
37
    if the config is not found,
 
38
    then it will return the ones provided in environment variables
 
39
    """
 
40
    return (USER_CONFIG_STACK.get('user', 'user_email',
 
41
                                  default=os.environ.get('user_email')),
 
42
            USER_CONFIG_STACK.get('user', 'user_password',
 
43
                                  default=os.environ.get('user_password')))
36
44
 
37
45
 
38
46
def is_staging():
54
62
    if that env variable is not set, then it returns staging as default
55
63
    :return: current configured store environment
56
64
    """
57
 
    return CONFIG_STACK.config.get('store', 'environment', os.getenv('TEST_STORE', 'staging'))
 
65
    return CONFIG_STACK.get('store', 'environment',
 
66
                            os.getenv('TEST_STORE', 'staging'))