Ejemplo n.º 1
0
def test_create_openapi_request():
    edgercFile = 'null'
    with pytest.raises(FileNotFoundError):
        alda.create_openapi_request(edgercFile)

    edgercFile = 'alda.edgerc'
    openapiObj = alda.create_openapi_request(edgercFile)
    assert 'v2.luna.akamaiapis.net' in openapiObj['baseurl']
    assert isinstance(openapiObj['request'], requests.sessions.Session)
Ejemplo n.º 2
0
def test_create_lds_configs():
    sformat = 'smooth'
    geo = 'us'
    cpcode = '525828'
    openapiObj = alda.create_openapi_request('alda.edgerc')
    connectionDetails = alda.get_netstorage_credentials('alda.netstorage')

    lds_payload = json.loads('''
    {
        "configurationType": "PRIMARY",
        "acgObject": {
            "id": "000000",
            "type": "CP_CODE"
        },
        "productGroupId": 1,
        "startDate": 1401840000000,
        "logFormat": { "dictId": "2" },
        "logIdentifier": "000000",
        "aggregationType": "COLLECTION",
        "deliveryType": "FTP",
        "deliveryFrequency": {"dictId": "7"},
        "ftpConfiguration": {
            "directory": "",
            "machine": "adsiuslogs.download.akamai.com",
            "login": "******",
            "password": ""
        },
        "messageSize": { "dictId": "1" },
        "encoding": { "dictId": "3" },
        "contact": {
            "contactEmail": ["*****@*****.**"],
            "dictId": "B-C-PNOHOD"
        }
    }''')
    lds_payload['acgObject']['id'] = cpcode
    lds_payload['logIdentifier'] = cpcode
    lds_payload['ftpConfiguration']['directory'] =\
        '/{0}/logdelivery/{1}/{2}/{3}'.format(
        connectionDetails['DEFAULT']['Cpcode'], sformat, geo, cpcode)
    lds_payload['ftpConfiguration']['password'] = connectionDetails['DEFAULT']['Password']

    # Test that we can create a configuration
    result = openapiObj['request'].post(urljoin(openapiObj['baseurl'], '/lds/v1/configurations'),
                                        data=json.dumps(lds_payload),
                                        headers={'Accept': '*/*', 'Content-Type': 'application/json'})
    assert result.status_code == 200

    resultObject = result.json()
    serviceID = resultObject['contents']
    # Delete the configuration we just created
    result = openapiObj['request'].delete(urljoin(openapiObj['baseurl'], '/lds/v1/configurations/{0}'.format(serviceID)),
                                          data=json.dumps(lds_payload),
                                          headers={'Accept': '*/*', 'Content-Type': 'application/json'})
    assert result.status_code == 200
Ejemplo n.º 3
0
def test_get_lds_configs_and_cpcodes_jp():
    openapiObj = alda.create_openapi_request('alda.edgerc', 'jp')
    ldsConfigs = alda.get_lds_configs(openapiObj)
    assert ldsConfigs['errorMessage'] is None

    # If test is failing, probable that one of these cpcodes status changed
    # Check portal and update accordingly
    cpcodes_active = ['202369', '272610', '384159']
    cpcodes_inactive = ['515552', '515550', '515551']

    empty_cpcode_list = alda.check_cpcodes(ldsConfigs['contents'],
                                           cpcodes_active)
    full_cpcode_list = alda.check_cpcodes(ldsConfigs['contents'],
                                          cpcodes_inactive)

    assert len(empty_cpcode_list) == 0
    assert len(full_cpcode_list) == 3
Ejemplo n.º 4
0
def test_get_lds_configs_and_cpcodes_eu():
    openapiObj = alda.create_openapi_request('alda.edgerc', 'eu')
    ldsConfigs = alda.get_lds_configs(openapiObj)
    assert ldsConfigs['errorMessage'] is None

    # If test is failing, probable that one of these cpcodes status changed
    # Check portal and update accordingly
    cpcodes_active = ['175681', '203346', '269263']
    cpcodes_inactive = ['526922', '457310', '411230']

    empty_cpcode_list = alda.check_cpcodes(ldsConfigs['contents'],
                                           cpcodes_active)
    full_cpcode_list = alda.check_cpcodes(ldsConfigs['contents'],
                                          cpcodes_inactive)

    assert len(empty_cpcode_list) == 0
    assert len(full_cpcode_list) == 3
Ejemplo n.º 5
0
def test_get_lds_configs_and_cpcodes_us():
    openapiObj = alda.create_openapi_request('alda.edgerc', 'us')
    ldsConfigs = alda.get_lds_configs(openapiObj)
    assert ldsConfigs['errorMessage'] is None

    # If test is failing, probable that one of these cpcodes status changed
    # Check portal and update accordingly
    cpcodes_active = ['100899', '193213', '153058']
    cpcodes_inactive = ['513803', '482486', '453163']

    empty_cpcode_list = alda.check_cpcodes(ldsConfigs['contents'],
                                           cpcodes_active)
    full_cpcode_list = alda.check_cpcodes(ldsConfigs['contents'],
                                          cpcodes_inactive)

    assert len(empty_cpcode_list) == 0
    assert len(full_cpcode_list) == 3