Example #1
0
def check_profile_internal(logmsg,
                           code,
                           prof_pat,
                           user1="test1",
                           pass1="pass",
                           user2="test2",
                           pass2="pass"):
    ## login as user test1
    html1, cookies1 = z.login(user1, pass1)

    ## update test1 profile
    update_profile(cookies1, code)

    ## login as user test2
    html2, cookies2 = z.login(user2, pass2)

    ## fetch test1 profile
    vhtml = z.view_user(cookies2, user1)
    ## log profile output
    log_to_file("=" * 60)
    log_to_file(logmsg)
    log_to_file("")
    log_to_file(vhtml)
    log_to_file("")

    ## check for profile pattern
    return "Traceback" not in vhtml and re.search(prof_pat, vhtml,
                                                  re.DOTALL) is not None
Example #2
0
def check_profile_internal(logmsg, code, prof_pat,
                           user1="test1", pass1="supersecretpassword",
                           user2="test2", pass2="pass"):
    ## login as user test1
    html1, cookies1 = z.login(user1, pass1)
    ## update test1 profile
    update_profile(cookies1, code)

    ## login as user test2
    html2, cookies2 = z.login(user2, pass2)

    ## fetch test1 profile
    vhtml = z.view_user(cookies2, user1)

    ## log profile output
    log_to_file("=" * 60)
    log_to_file(logmsg)
    log_to_file("")
    log_to_file(vhtml)
    log_to_file("")

    ## check for profile pattern
    ans = "Traceback" not in vhtml and re.search(prof_pat, vhtml, re.DOTALL) is not None
    #if not ans:
        #print "OOPS! $#$#$#$#$#"
        #print "pat",prof_pat
        #print vhtml
    return ans
Example #3
0
def check_granter_1():
    pat = "profile.*Thanks for visiting.  I gave you one zoobar."
    if not check_profile("granter.py", pat, "Zoobar grant check"):
        return False

    # check that profile owner token was used and not visitor's, by checking
    # that profile owner has one less zoobar
    html, cookies = z.login("test1", "pass")
    if not z.check_zoobars(html, "test1", 6, "")[0]:
        log(red("FAIL"), "Exercises 1-5:", "Not using profile owner's token")

    return True
Example #4
0
def check_granter_1():
    pat = "profile.*Thanks for visiting.  I gave you one zoobar."
    if not check_profile("granter.py", pat, "Zoobar grant check"):
        return False

    # check that profile owner token was used and not visitor's, by checking 
    # that profile owner has one less zoobar
    html, cookies = z.login("test1", "pass")
    if not z.check_zoobars(html, "test1", 6, "")[0]:
        log(red("FAIL"), "Exercises 1-5:", "Not using profile owner's token")

    return True
Example #5
0
def check_granter_4():
    html1, cookies1 = z.login("test1", "pass")
    z.transfer(cookies1, "test2", 6)
    pat = "profile.*Sorry, I have no more zoobars"
    return check_profile("granter.py", pat, "'I am broke' check")
Example #6
0
def check_granter_4():
    html1, cookies1 = z.login("test1", "pass")
    z.transfer(cookies1, "test2", 6)
    pat = "profile.*Sorry, I have no more zoobars"
    return check_profile("granter.py", pat, "'I am broke' check")