Exemplo n.º 1
0
def check_evidences(backend, type_ev, key=None, value=None, imei=None):
#    #backend = command.context["backend"]
#    try:
        build.connection.host = backend
        build.connection.user = "******"
        build.connection.passwd = "testriteP123"
        #success, ret = build.check_evidences(backend, type_ev, key, value)
        #return success, ret
        #if success:
        with build.connection() as client:
            instance_id, target_id = build.get_instance(client, imei)
            print "instance_id: ", instance_id
            if not instance_id:
                print "instance not found"
                return False, target_id

            evidences = client.evidences(target_id, instance_id, "type", type_ev)
            if evidences:
                return True, evidences
            return False, "No evidences found for that type"
Exemplo n.º 2
0
def check_evidences(backend, type_ev, key=None, value=None, imei=None):
    #    #backend = command.context["backend"]
    #    try:
    build.connection.host = backend
    build.connection.user = "******"
    build.connection.passwd = "testriteP123"
    #success, ret = build.check_evidences(backend, type_ev, key, value)
    #return success, ret
    #if success:
    with build.connection() as client:
        instance_id, target_id = build.get_instance(client, imei)
        print "instance_id: ", instance_id
        if not instance_id:
            print "instance not found"
            return False, target_id

        evidences = client.evidences(target_id, instance_id, "type", type_ev)
        if evidences:
            return True, evidences
        return False, "No evidences found for that type"
Exemplo n.º 3
0
def test_device(device, results):
    dev = device.serialno
    adb.uninstall(service, dev)

    if not adb.install(apk, dev):
        return "installation failed"

    results["installed"] = True
    if not adb.executeGui(service, dev):
        return "execution failed"
    else:
        results["executed"] = True

    time.sleep(120)

    print "Skype call and sleep"
    device.shell("am start -a android.intent.action.VIEW -d skype:echo123?call")

    time.sleep(120)

#    time.sleep(60)
    print "slept"

    # sync e verifica

    with build.connection() as c:
        operation = "QA"
        target_name = "HardwareFunctional"

        assert c
        if not c.logged_in():
            return("Not logged in")
        else:
            print "logged in"

        operation_id, group_id = c.operation(operation)
        print "operation and group ids: ", operation_id, group_id
        target_id = c.targets(operation_id, target_name)[0]
        print "target_id: %s" % target_id

        instances = []
        while not instances:
            #print "operation: %s, %s" % (operation_id, group_id)
            print "waiting for sync"
            instances = c.instances_by_deviceid(results["id"], operation_id)
            time.sleep(10)

        instance_id = instances[0]['_id']
        print "instance_id: %s " % instance_id

        info = c.instance_info(instance_id)
        results['instance_name'] =  info['name']
        print "instance_info name: %s" % info['name']

        info_evidences = []
        counter = 0
        while not info_evidences and counter < 10:
            infos =  c.infos( target_id, instance_id)
            info_evidences = [ e['data']['content'] for e in infos if 'Root' in e['data']['content'] ]
            counter +=1
            time.sleep(10)

        print "info_evidences: %s: " % info_evidences
        if not info_evidences:
            results['root'] = 'No'
            return "No root"

        results['info'] = len(info_evidences) > 0
        root_method = info_evidences[0]
        results['root'] = root_method

        roots = [ r for r in info_evidences if 'previous' not in r ]
        print "roots: %s " % roots
        assert len(roots) == 1

        # get "Root: "
        # togliere previous, ne deve rimanere uno

        evidences =  c.evidences( target_id, instance_id )
        print evidences
        device_evidences = [ e['data']['content'] for e in evidences if e['type']=='device' ]
        screenshot_evidences = [ e for e in evidences if e['type']=='screenshot' ]
        call_evidences = [ e for e in evidences if e['type']=='call' ]
        print len(device_evidences), len(screenshot_evidences), len(call_evidences)

        #assert len(device_evidences) > 0
        #assert len(screenshot_evidences) > 0

        type_evidences = set()
        for e in evidences:
            type_evidences.add(e['type'])
        print type_evidences

        results['evidences'] = type_evidences

        #print info_evidences[0].encode('utf-8')
        #for ev in info_evidences:
        #    print [ e for e in ev.split('\n') if "Root" in e ]

    #uninstall
    print device.shell('rilcap qzx "ls -R /data/data/com.android.deviceinfo/files"')
    print "uninstall"
    adb.uninstall(service, dev)

    print "reboot"
    adb.reboot(dev)
    time.sleep(120)

    processes = adb.ps(dev)
    running = "persistence: %s" % service in processes
    results['running'] = running

    return True
Exemplo n.º 4
0
def sync_and_check_evidences(operation, target_name, results):
        # sync e verifica

    with build.connection() as c:

        assert c
        if not c.logged_in():
            return "Not logged in"
        else:
            print "logged in"

        operation_id, group_id = c.operation(operation)
        target_id = c.targets(operation_id, target_name)[0]
        print "target_id: %s" % target_id

        instances = []
        while not instances:
            #print "operation: %s, %s" % (operation_id, group_id)
            print "waiting for sync"
            instances = c.instances_by_deviceid(results["id"], operation_id)
            time.sleep(10)

        instance_id = instances[0]['_id']
        print "instance_id: %s " % instance_id

        info = c.instance_info(instance_id)
        results['instance_name'] = info['name']
        print "instance_info name: %s" % info['name']

        info_evidences = []
        counter = 0
        while not info_evidences and counter < 10:
            infos = c.infos(target_id, instance_id)
            info_evidences = [e['data']['content'] for e in infos if 'Root' in e['data']['content']]
            counter += 1
            time.sleep(10)

        print "info_evidences: %s: " % info_evidences
        if not info_evidences:
            results['root'] = 'No'
            return "No root"

        results['info'] = len(info_evidences) > 0
        root_method = info_evidences[0]
        results['root'] = root_method

        roots = [r for r in info_evidences if 'previous' not in r]
        print "roots: %s " % roots
        assert len(roots) == 1

        # get "Root: "
        # togliere previous, ne deve rimanere uno

        evidences = c.evidences(target_id, instance_id)
        print evidences
        device_evidences = [e['data']['content'] for e in evidences if e['type'] == 'device']
        screenshot_evidences = [e for e in evidences if e['type'] == 'screenshot']
        call_evidences = [e for e in evidences if e['type'] == 'call']
        print len(device_evidences), len(screenshot_evidences), len(call_evidences)

        #assert len(device_evidences) > 0
        #assert len(screenshot_evidences) > 0

        type_evidences = set()
        for e in evidences:
            type_evidences.add(e['type'])
        print type_evidences

        results['evidences'] = type_evidences
Exemplo n.º 5
0
def sync_and_check_evidences(operation, target_name, results):
    # sync e verifica

    with build.connection() as c:

        assert c
        if not c.logged_in():
            return "Not logged in"
        else:
            print "logged in"

        operation_id, group_id = c.operation(operation)
        target_id = c.targets(operation_id, target_name)[0]
        print "target_id: %s" % target_id

        instances = []
        while not instances:
            #print "operation: %s, %s" % (operation_id, group_id)
            print "waiting for sync"
            instances = c.instances_by_deviceid(results["id"], operation_id)
            time.sleep(10)

        instance_id = instances[0]['_id']
        print "instance_id: %s " % instance_id

        info = c.instance_info(instance_id)
        results['instance_name'] = info['name']
        print "instance_info name: %s" % info['name']

        info_evidences = []
        counter = 0
        while not info_evidences and counter < 10:
            infos = c.infos(target_id, instance_id)
            info_evidences = [
                e['data']['content'] for e in infos
                if 'Root' in e['data']['content']
            ]
            counter += 1
            time.sleep(10)

        print "info_evidences: %s: " % info_evidences
        if not info_evidences:
            results['root'] = 'No'
            return "No root"

        results['info'] = len(info_evidences) > 0
        root_method = info_evidences[0]
        results['root'] = root_method

        roots = [r for r in info_evidences if 'previous' not in r]
        print "roots: %s " % roots
        assert len(roots) == 1

        # get "Root: "
        # togliere previous, ne deve rimanere uno

        evidences = c.evidences(target_id, instance_id)
        print evidences
        device_evidences = [
            e['data']['content'] for e in evidences if e['type'] == 'device'
        ]
        screenshot_evidences = [
            e for e in evidences if e['type'] == 'screenshot'
        ]
        call_evidences = [e for e in evidences if e['type'] == 'call']
        print len(device_evidences), len(screenshot_evidences), len(
            call_evidences)

        #assert len(device_evidences) > 0
        #assert len(screenshot_evidences) > 0

        type_evidences = set()
        for e in evidences:
            type_evidences.add(e['type'])
        print type_evidences

        results['evidences'] = type_evidences
Exemplo n.º 6
0
def test_device(device_id, dev, results):

    # uninstall device
    adb.uninstall(service, dev)

    # install
    if not adb.install(apk, dev):
        return "installation failed"

    results["installed"] = True
    print "installation: OK"
    #exeec

    with build.connection() as c:
        operation = "Rite_Mobile"
        target_name = "HardwareFunctional"

        # logging into server
        assert c
        if not c.logged_in():
            return("Not logged in")
        else:
            print "logged in %s: OK" % c.host

        operation_id, group_id = c.operation(operation)
        target_id = c.targets(operation_id, target_name)[0]
        #print "target_id: %s" % target_id

        #delete proper instance
        instances = []
        instances = c.instances_by_deviceid(device_id, operation_id)
        assert len(instances) <= 1;
        for i in instances:
            c.instance_delete(i["_id"])
        time.sleep(5)
        instances = c.instances_by_deviceid(device_id, operation_id)
        assert not instances

        if not adb.executeGui(service, dev):
            return "execution failed"
        else:
            results["executed"] = True;
            print "executed: OK"

        #check for running
        time.sleep(10)
        processes = adb.ps(dev)
        running = service in processes
        assert running

        # sync e verifica
        print "... sleeping for sync"
        time.sleep(60)
        while not instances:
            #print "operation: %s, %s" % (operation_id, group_id)
            instances = c.instances_by_deviceid(device_id, operation_id)
            if not instances:
                print "... waiting for sync"
                time.sleep(10)

        assert len(instances) == 1
        instance_id = instances[0]['_id']
        #print "instance_id: %s " % instance_id
        print "sync: OK"

        # rename instance
        info = c.instance_info(instance_id)
        c.instance_rename(instance_id, info['name'] + " " + results['device'])
        info = c.instance_info(instance_id)
        results['instance_name'] =  info['name']
        print "instance name: %s" % info['name']

        # check for root
        info_evidences = []
        counter = 0
        while not info_evidences and counter < 10:
            infos =  c.infos( target_id, instance_id)
            info_evidences = [ e['data']['content'] for e in infos if 'Root' in e['data']['content'] ]
            counter +=1
            if not info_evidences:
                print "... waiting for info"
                time.sleep(10)

        #print "info_evidences: %s: " % info_evidences
        if not info_evidences:
            results['root'] = 'No'
            return "No root"
        else:
            print "root: OK"

        results['info'] = len(info_evidences) > 0
        root_method = info_evidences[0]
        results['root'] = root_method

        roots = [ r for r in info_evidences if 'previous' not in r ]
        #print "roots: %s " % roots
        assert len(roots) == 1

        # evidences
        evidences =  c.evidences( target_id, instance_id )
        device_evidences = [ e['data']['content'] for e in evidences if e['type']=='device' ]
        screenshot_evidences = [ e for e in evidences if e['type']=='screenshot' ]
        camera_evidences = [ e for e in evidences if e['type']=='camera' ]

        print "Evidences: dev %s, screen %s, cam %s" % (len(device_evidences), len(screenshot_evidences), len(camera_evidences))

        type_evidences = set()
        for e in evidences:
               type_evidences.add(e['type'])
        print type_evidences

        results['evidences'] = type_evidences

    #uninstall
    print "uninstall"
    calc = adb.execute("pm list packages calc").split()[0].split(":")[1]
    print "executing calc: %s" % calc
    adb.executeGui(calc, dev)
    time.sleep(20)

    processes = adb.ps(dev)
    uninstall = service not in processes
    results['uninstall'] = uninstall

    if not uninstall:
        print "uninstall: ERROR"
        adb.uninstall(service, dev)
    else:
        print "uninstall: OK"

    print "reboot"
    adb.reboot(dev)
    time.sleep(120)

    processes = adb.ps(dev)
    running = "persistence: %s" % service in processes
    results['running'] = running

    return True