summaryrefslogtreecommitdiff
path: root/tests/functional/features/steps/bitmask.py
blob: 7e1201f63deb2f9df8e0cbdf32a90a33fae57a94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import commands
import shutil
import os
import time
from leap.common.config import get_path_prefix

from behave import given


@given('I start bitmask for the first time')
def initial_run(context):
    if context.mode == 'virtualenv':
        commands.getoutput('bitmaskctl stop')
        # TODO: fix bitmaskctl to only exit once bitmaskd has stopped
        time.sleep(2)
        _initialize_home_path()
        commands.getoutput('bitmaskctl start')
    elif context.mode in ('bundle', 'bundle-ci'):
        commands.getoutput(context.bundle_path)
        time.sleep(2)
    tokenpath = os.path.join(get_path_prefix(), 'leap', 'authtoken')
    token = open(tokenpath).read().strip()
    context.login_url = "http://localhost:7070/#%s" % token


def _initialize_home_path():
    shutil.rmtree(get_path_prefix(), ignore_errors=True)
    os.makedirs(get_path_prefix())