def initialize(self):
     self.info ('[US1386][Runtime][cartridge]Control embedded PostgreSQL')
     try:
         test_name = self.get_variant()
     except:
         self.info("Missing variant, used `php` as default")
         test_name = 'php'
     try:
         self.scalable = self.config.tcms_arguments['scalable']
     except:
         self.scalable = False
     self.app_type = common.app_types[test_name]
     self.app_name1 =  test_name.split('-')[0]+common.get_random_string(7)
     self.app_name2 =  test_name.split('-')[0]+common.get_random_string(7)
     common.env_setup()
Пример #2
0
 def initialize(self):
     self.info("subaccount_delete")
     try:
         self.test_variant = self.get_variant()
     except:
         self.test_variant = 'php'
     self.info("VARIANT: %s"%self.test_variant)
     self.user_email = self.config.OPENSHIFT_user_email
     self.user_passwd = self.config.OPENSHIFT_user_passwd
     self.app_name = common.get_random_string(10)
     self.app_type = common.app_types[self.test_variant]
     self.subdomain = common.get_random_string(10)
     self.subaccount = common.get_random_string(10)
     self.gear_profile = 'small'
     common.env_setup()
Пример #3
0
        f"::error::Working base branch '{working_base}' was created by this action. "
        + "Unable to continue. Exiting.")
    sys.exit(1)

# Fetch an optional environment variable to determine the branch suffix
branch_suffix = os.environ.get("CPR_BRANCH_SUFFIX")
if branch_suffix is not None:
    if branch_suffix == "short-commit-hash":
        # Suffix with the short SHA1 hash
        branch = "{}-{}".format(branch, repo.git.rev_parse("--short", "HEAD"))
    elif branch_suffix == "timestamp":
        # Suffix with the current timestamp
        branch = "{}-{}".format(branch, int(time.time()))
    elif branch_suffix == "random":
        # Suffix with a 7 character random string
        branch = "{}-{}".format(branch, cmn.get_random_string())
    else:
        print(
            f"::error::Branch suffix '{branch_suffix}' is not a valid value. "
            + "Unable to continue. Exiting.")
        sys.exit(1)

# Output head branch
print(f"Pull request branch to create or update set to '{branch}'")

# Set the committer and author
try:
    set_committer_author(repo, committer, author)
except ValueError as e:
    print(f"::error::{e} " + "Unable to continue. Exiting.")
    sys.exit(1)
Пример #4
0
def do_magic(cursor):
    driver = webdriver.Firefox()
    driver.get(common.REFFERAL_LINK)
    links = driver.find_elements_by_xpath("//*[@href]")
    for link in links:
        if "refferal link" in link.text:
            link.click()
            break

    link = driver.find_element_by_id('pic')
    link.click()

    random_string = common.get_random_string()
    print(random_string)
    cursor.execute("INSERT INTO users (email, password) VALUES (%s, %s);",
                   (random_string + "@lackmail.ru", random_string))

    cursor.close()
    while True:
        try:
            user_email = driver.find_element_by_id("UserEmail")
            break
        except:
            time.sleep(2)
            continue

    email_string = random_string + "@lackmail.ru"
    user_password = driver.find_element_by_id("UserPassword")
    user_password_confirm = driver.find_element_by_id("UserPasswordConfirm")

    user_email.send_keys(email_string)
    user_password.send_keys(random_string)
    user_password_confirm.send_keys(random_string)
    form = driver.find_element_by_id("UserRegisterForm")
    form.submit()

    driver.get("https://temp-mail.ru/option/change")

    mail = driver.find_element_by_xpath("//form[1]//input[@id='mail']")
    common.highlight(mail)
    mail.send_keys(random_string)

    for option in driver.find_elements_by_tag_name('option'):
        if option.text == '@lackmail.ru':
            option.click()
            break
    button = driver.find_element_by_id("postbut")
    button.click()

    driver.get("https://temp-mail.ru/option/refresh")

    while True:
        try:
            confirmation_email = driver.find_element_by_xpath(
                "//*[contains(text(), 'HashFlare account confirm')]")
            break
        except:
            time.sleep(2)
            continue

    confirmation_email.click()

    driver.get(driver.current_url)
    links = driver.find_elements_by_xpath("//*[@href]")

    for link in links:
        if "https://hashflare.io/confirm" in link.text:
            link.click()
            break

    driver.quit()
Пример #5
0
def create_or_update_branch(repo, repo_url, commit_message, base, branch):
    # Set the default return values
    action = "none"
    diff = False

    # Get the working base. This may or may not be the actual base.
    working_base = repo.git.symbolic_ref("HEAD", "--short")
    # If the base is not specified it is assumed to be the working base
    if base is None:
        base = working_base

    # Save the working base changes to a temporary branch
    temp_branch = cmn.get_random_string(length=20)
    repo.git.checkout("HEAD", b=temp_branch)
    # Commit any uncomitted changes
    if repo.is_dirty(untracked_files=True):
        print(f"Uncommitted changes found. Adding a commit.")
        repo.git.add("-A")
        repo.git.commit(m=commit_message)

    # Perform fetch and reset the working base
    # Commits made during the workflow will be removed
    repo.git.fetch("--force", repo_url, f"{working_base}:{working_base}")

    # If the working base is not the base, rebase the temp branch commits
    if working_base != base:
        print(
            f"Rebasing commits made to branch '{working_base}' on to base branch '{base}'"
        )
        # Checkout the actual base
        repo.git.fetch("--force", repo_url, f"{base}:{base}")
        repo.git.checkout(base)
        # Cherrypick commits from the temporary branch starting from the working base
        commits = repo.git.rev_list("--reverse", f"{working_base}..{temp_branch}", ".")
        for commit in commits.splitlines():
            try:
                repo.git.cherry_pick(
                    "--strategy",
                    "recursive",
                    "--strategy-option",
                    "theirs",
                    f"{commit}",
                )
            except GitCommandError as e:
                if CHERRYPICK_EMPTY not in e.stderr:
                    print("Unexpected error: ", e)
                    raise
        # Reset the temp branch to the working index
        repo.git.checkout("-B", temp_branch, "HEAD")
        # Reset the base
        repo.git.fetch("--force", repo_url, f"{base}:{base}")

    # Try to fetch the pull request branch
    if not fetch_successful(repo, repo_url, branch):
        # The pull request branch does not exist
        print(f"Pull request branch '{branch}' does not exist yet")
        # Create the pull request branch
        repo.git.checkout("HEAD", b=branch)
        # Check if the pull request branch is ahead of the base
        diff = is_ahead(repo, base, branch)
        if diff:
            action = "created"
            print(f"Created branch '{branch}'")
        else:
            print(
                f"Branch '{branch}' is not ahead of base '{base}' and will not be created"
            )
    else:
        # The pull request branch exists
        print(
            f"Pull request branch '{branch}' already exists as remote branch 'origin/{branch}'"
        )
        # Checkout the pull request branch
        repo.git.checkout(branch)

        if has_diff(repo, branch, temp_branch):
            # If the branch differs from the recreated temp version then the branch is reset
            # For changes on base this action is similar to a rebase of the pull request branch
            print(f"Resetting '{branch}'")
            repo.git.checkout("-B", branch, temp_branch)
            # repo.git.switch("-C", branch, temp_branch)

        # Check if the pull request branch has been updated
        # If the branch was reset or updated it will be ahead
        # It may be behind if a reset now results in no diff with the base
        if not is_even(repo, f"origin/{branch}", branch):
            action = "updated"
            print(f"Updated branch '{branch}'")
        else:
            print(f"Branch '{branch}' is even with its remote and will not be updated")

        # Check if the pull request branch is ahead of the base
        diff = is_ahead(repo, base, branch)

    # Delete the temporary branch
    repo.git.branch("--delete", "--force", temp_branch)

    return {"action": action, "diff": diff, "base": base}
Пример #6
0
def test_get_random_string():
    assert len(cmn.get_random_string()) == 7
    assert len(cmn.get_random_string(length=20)) == 20
Пример #7
0
def do_magic(cursor, proxy):

    headers = {
        'Accept':
        '*/*',
        'Accept-Encoding':
        'gzip, deflate, sdch',
        'Accept-Language':
        'en-US,en;q=0.8',
        'Cache-Control':
        'max-age=0',
        'User-Agent':
        'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36'
        '(KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36'
    }

    service_args = [
        '--proxy=' + proxy,
        '--proxy-type=socks5',
    ]

    for key, value in enumerate(headers):
        webdriver.DesiredCapabilities.PHANTOMJS[
            'phantomjs.page.customHeaders.{}'.format(key)] = value
    driver = webdriver.PhantomJS(service_args=service_args)

    driver.get("https://temp-mail.ru/option/change")

    random_string = common.get_random_string()
    email_string = random_string + "@lackmail.ru"

    mail = driver.find_element_by_xpath("//form[1]//input[@id='mail']")
    common.highlight(mail)
    mail.send_keys(random_string)

    for option in driver.find_elements_by_tag_name('option'):
        if option.text == '@lackmail.ru':
            option.click()
            break
    button = driver.find_element_by_id("postbut")
    button.click()

    driver.get(common.REFFERAL_LINK)
    links = driver.find_elements_by_xpath("//*[@href]")
    for link in links:
        if "refferal link" in link.text:
            link.click()
            break

    link = driver.find_element_by_id('pic')
    link.click()

    cursor.close()
    while True:
        try:
            user_email = driver.find_element_by_id("UserEmail")
            break
        except:
            continue

    user_email.send_keys(email_string)
    user_password = driver.find_element_by_id("UserPassword")
    user_password.send_keys(random_string)
    user_password_confirm = driver.find_element_by_id("UserPasswordConfirm")
    user_password_confirm.send_keys(random_string)
    form = driver.find_element_by_id("UserRegisterForm")
    form.submit()

    driver.get("https://temp-mail.ru/option/refresh")

    while True:
        try:
            letter = driver.find_element_by_xpath(
                "//*[contains(text(), 'HashFlare account confirm')]")
            break
        except:
            time.sleep(2)
            continue
    letter.click()

    driver.get(driver.current_url)

    links = driver.find_elements_by_xpath("//*[@href]")

    for link in links:
        if "https://hashflare.io/confirm" in link.text:
            link.click()
            break

    common.add_user(email_string=email_string, password_string=random_string)
    driver.quit()