def upload_file(file):
    remote = os.getenv("BINTRAY_REMOTE")
    username = os.getenv("BINTRAY_USERNAME")
    apikey = os.getenv("BINTRAY_API_KEY")
    if not username or not apikey or not remote:
        logging.error("Could not upload. Login missing")
        return

    subject, repo, package = remote.split('/')
    bintray = Bintray()
    today = datetime.date.today()
    version = today.strftime("%Y%m%d")
    basename = os.path.basename(file)
    try:
        logging.info("Uploading {}".format(basename))
        bintray.upload_content(subject,
                               repo,
                               package,
                               version,
                               basename,
                               file,
                               override=True)
        logging.info("Done!")
    except Exception as error:
        logging.error(str(error))
Example #2
0
def test_debian_upload():
    bintray = Bintray()
    _, temp_path = tempfile.mkstemp()
    response = bintray.debian_upload("uilianries", "generic", "statistics", "test", "test.deb",
                                     temp_path, deb_distribution="wheezy", deb_component="main",
                                     deb_architecture="i386,amd64", publish=True, override=True)
    assert {'error': False, 'message': 'success', 'statusCode': 201} == response
Example #3
0
def test_update_geo_restrictions():
    bintray = Bintray()
    error_message = ""
    try:
        bintray.update_geo_restrictions("uilianries",
                                        "generic",
                                        white_list=["US", "CA"])
    except Exception as error:
        error_message = str(error)
    assert "Could not PUT (403): Account Plan is not suitable for repo geo restriction. " \
           "Your current plan does not support geo restrictions." == error_message

    try:
        bintray.update_geo_restrictions("uilianries",
                                        "generic",
                                        black_list=["US", "CA"])
    except Exception as error:
        error_message = str(error)
    assert "Could not PUT (403): Account Plan is not suitable for repo geo restriction. " \
           "Your current plan does not support geo restrictions." == error_message

    try:
        bintray.update_geo_restrictions("uilianries", "generic")
    except Exception as error:
        error_message = str(error)
    assert "At lease one parameter must be filled." == error_message

    try:
        bintray.update_geo_restrictions("uilianries",
                                        "generic",
                                        black_list=["US", "CA"],
                                        white_list=["CH", "RU"])
    except Exception as error:
        error_message = str(error)
    assert "The update can be done on one list only." == error_message
def test_download_content():
    json_file = "packages.json"
    bintray = Bintray()
    response = bintray.download_content("uilianries", "generic", json_file,
                                        json_file)
    assert os.path.exists(json_file)
    assert False == response["error"]
Example #5
0
def test_file_search_by_checksum():
    bintray = Bintray()
    response = bintray.search_file_by_checksum(
        "85abc6aece02515e8bd87b9754a18af697527d88",
        subject="uilianries",
        repo="generic",
        created_after="2019-07-01")
    assert {'error': False, 'statusCode': 200} in response
Example #6
0
def upload_file(file):
    remote = os.getenv("BINTRAY_REMOTE")
    subject, repo, package = remote.split('/')
    bintray = Bintray()
    today = datetime.date.today()
    version = today.strftime("%Y%m%d")
    basename = os.path.basename(file)
    bintray.upload_content(subject, repo, package, version, basename, file, override=True)
Example #7
0
def download_files(files):
    bintray = Bintray()
    remote = os.getenv("BINTRAY_REMOTE")
    subject, repo, package = remote.split('/')
    for file in files:
        file_path = file.get("path")
        file_name = file.get("name")
        bintray.download_content(subject, repo, file_path, file_name)
def test_delete_product():
    bintray = Bintray()
    error_message = ""
    try:
        bintray.delete_product("jfrog", "xray")
    except Exception as error:
        error_message = str(error)
    assert "Could not DELETE (403): forbidden" == error_message
Example #9
0
def test_get_all_products_signed_eulas():
    bintray = Bintray()
    error_message = ""
    try:
        bintray.get_all_products_signed_eulas("jfrog")
    except Exception as error:
        error_message = str(error)
    assert "Could not GET (403): forbidden" == error_message
Example #10
0
def test_search_repository_empty():
    bintray = Bintray()
    error_message = ""
    try:
        bintray.search_repository()
    except ValueError as error:
        error_message = str(error)
    assert "At lease one parameter must be filled." == error_message
Example #11
0
def test_delete_repo(create_repo):
    bintray = Bintray()
    response = bintray.delete_repository("uilianries", TEMPORARY_REPO)
    assert {
        'error': False,
        'statusCode': 200,
        'message': 'success'
    } == response
Example #12
0
def test_update_repo_empty(create_repo):
    bintray = Bintray()
    error_message = ""
    try:
        bintray.update_repository("uilianries", TEMPORARY_REPO)
    except ValueError as error:
        error_message = str(error)
    assert "At lease one parameter must be filled." == error_message
def _create_package():
    bintray = Bintray()
    response = bintray.create_package("uilianries", "generic", "qux", ["MIT"],
                                      "https://github.com/uilianries/bintray-python", None, "foo",
                                      ["test", "jfrog", "couse"], "http://example.com",
                                      "https://github.com/uilianries/bintray-python/issues",
                                      "uilianries/bintray-python", None, True)
    return response
def test_bad_credentials_for_get_oss_licenses():
    bintray = Bintray("foobar", "85abc6aece02515e8bd87b9754a18af697527d88")
    error_message = ""
    try:
        bintray.get_oss_licenses()
    except Exception as error:
        error_message = str(error)
    assert "Could not GET (401): This resource requires authentication" == error_message
def test_get_org_proprietary_licenses():
    bintray = Bintray()
    error_message = ""
    try:
        bintray.get_org_proprietary_licenses(org="jfrog")
    except Exception as error:
        error_message = str(error)
    assert "Could not GET (403): forbidden" == error_message
def test_get_stream_api():
    bintray = Bintray()
    error_message = ""
    try:
        bintray.get_stream_api("uilianries")
    except Exception as error:
        error_message = str(error)
    assert "Could not GET (403): Forbidden" == error_message
def test_delete_usage_threshold_org():
    bintray = Bintray()
    error_message = ""
    try:
        bintray.delete_usage_threshold_org("jfrog")
    except Exception as error:
        error_message = str(error)
    assert "Could not DELETE (403): forbidden" == error_message
def test_get_usage_threshold_business_unit():
    bintray = Bintray()
    error_message = ""
    try:
        bintray.get_usage_threshold_business_unit("jfrog", "conan")
    except Exception as error:
        error_message = str(error)
    assert "Could not GET (404): BusinessUnit 'conan' was not found" == error_message
Example #19
0
def test_bad_credentials_for_get_package_files():
    bintray = Bintray("foobar", "85abc6aece02515e8bd87b9754a18af697527d88")
    error_message = ""
    try:
        bintray.get_package_files("uilianries", "generic", "statistics")
    except Exception as error:
        error_message = str(error)
    assert "Could not GET (401): This resource requires authentication" == error_message
def test_update_usage_threshold_org():
    bintray = Bintray()
    error_message = ""
    try:
        bintray.update_usage_threshold_org("jfrog", 10000, 10000, 10000, ["*****@*****.**"])
    except Exception as error:
        error_message = str(error)
    assert "Could not PATCH (403): forbidden" == error_message
Example #21
0
def test_get_eula():
    bintray = Bintray()
    error_message = ""
    try:
        bintray.get_eula("jfrog", "xray", "eula")
    except Exception as error:
        error_message = str(error)
    assert "Could not GET (403): forbidden" == error_message
def test_delete_usage_threshold_business_unit():
    bintray = Bintray()
    error_message = ""
    try:
        bintray.delete_usage_threshold_business_unit("jfrog", "xray")
    except Exception as error:
        error_message = str(error)
    assert "Could not DELETE (404): BusinessUnit 'xray' was not found" == error_message
Example #23
0
def test_delete_eula():
    bintray = Bintray()
    error_message = ""
    try:
        bintray.delete_eula("uilianries", "generic", "eula")
    except Exception as error:
        error_message = str(error)
    assert "Could not DELETE (404): Product 'generic' was not found" == error_message
def test_update_usage_threshold_business_unit():
    bintray = Bintray()
    error_message = ""
    try:
        bintray.update_usage_threshold_business_unit("jfrog", "xray", 10000, 10000, 10000,
                                                  ["*****@*****.**"])
    except Exception as error:
        error_message = str(error)
    assert "Could not PATCH (404): BusinessUnit 'xray' was not found" == error_message
def test_create_usage_threshold_repository():
    bintray = Bintray()
    error_message = ""
    try:
        bintray.create_usage_threshold_repository("jfrog", "xray", 10000, 10000, 10000,
                                                  ["*****@*****.**"])
    except Exception as error:
        error_message = str(error)
    assert "Could not POST (403): forbidden" == error_message
def test_get_usage_threshold_org():
    bintray = Bintray()
    error_message = ""
    try:
        bintray.get_usage_threshold_org("bincrafters")
    except Exception as error:
        error_message = str(error)
    assert "Could not GET (403): Usage thresholds are only available for organizations on an " \
           "Enterprise plan." == error_message
Example #27
0
def test_download_package_download_log_file():
    bintray = Bintray()
    response = bintray.get_list_package_download_log_files(
        "conan-community", "conan", "7z_installer:conan")
    log_name = response[0]["name"]
    bintray.download_package_download_log_file("conan-community", "conan",
                                               "7z_installer:conan", log_name,
                                               log_name)
    assert os.path.isfile(log_name)
Example #28
0
def test_update_eula():
    bintray = Bintray()
    error_message = ""
    try:
        bintray.update_eula("uilianries", "generic", "eula", "foobar", "plain_text", "nothing",
                            ["1.0"])
    except Exception as error:
        error_message = str(error)
    assert "Could not PATCH (404): Product 'generic' was not found" == error_message
def test_get_daily_downloads():
    bintray = Bintray()
    error_message = ""
    try:
        bintray.get_daily_downloads("uilianries", "generic", "statistics")
    except Exception as error:
        error_message = str(error)
    assert "Could not POST (403): This resource is only available for premium packages." \
           == error_message
def test_get_usage_report_for_repository():
    bintray = Bintray()
    error_message = ""
    try:
        bintray.get_usage_report_for_repository("uilianries", "generic")
    except Exception as error:
        error_message = str(error)
    assert "Could not POST (403): This resource is only available for Premium repositories" \
           == error_message