コード例 #1
0
def test_social_login2(session):
    '''Social login with unauthorized device
    
    '''
    device_mac = '00:de:ad:be:ef:ca'
    ap_mac = '00:22:00:00:00:01'
    site = Wifisite.query.filter_by(unifi_id='site1').first()

    #test valid trackid but no session
    track_id = str(uuid.uuid4())
    guest_track = Guesttrack(ap_mac=ap_mac,
                             device_mac=device_mac,
                             site=site,
                             state=GUESTRACK_INIT,
                             orig_url='',
                             track_id=track_id)
    db.session.add(guest_track)
    db.session.commit()
    #create session
    guest_session = Guestsession(mac=device_mac, state=SESSION_INIT, site=site)
    db.session.add(guest_session)
    site.sessions.append(guest_session)
    guest_track.session = guest_session
    guest_session.guesttracks.append(guest_track)
    guest_track.state = GUESTRACK_SESSION
    db.session.commit()
    #with session and unauthorized device
    guest_device = Device(mac=device_mac, site=site, state=DEVICE_INIT)
    site.devices.append(guest_device)
    db.session.add(guest_device)
    guest_device.sessions.append(guest_session)
    db.session.commit()
    assert '200 OK' == current_app.test_client().get('/guest/social/guest/%s' %
                                                     track_id).status
    assert guest_session.state == SESSION_TEMP_AUTH
コード例 #2
0
ファイル: test_guest_views.py プロジェクト: pedritss/poppet
def test_voucher_login2(session,create_vouchers,guest_logged):
    '''Test voucher_login view with pre authorized guest with non expired voucher

     '''
    site1           = Wifisite.query.filter_by(unifi_id='site1').first() 
    guest_track     = Guesttrack.query.first()
    guest_device    = Device.query.first()
    voucher         = Voucher.query.first()

    #device and used voucher
    used_at = arrow.utcnow().replace(days=2).datetime
    guest_device.state = DEVICE_VOUCHER_AUTH
    voucher.device_id = guest_device.id
    voucher.used = True
    voucher.used_at = used_at    

    #create a session representing old session
    guest_session = Guestsession(site=site1,device=guest_device)
    guest_session.state = GUESTRACK_VOUCHER_AUTH
    guest_session.mac   = guest_device.mac
    guest_session.guesttracks.append(guest_track)
    db.session.add(guest_session)
    guest_track.session_id = guest_session.id  

    #fake variables for session
    guest_session.starttime = used_at
    guest_session.lastseen = used_at
    guest_session.data_used = 500000

    db.session.commit()    

    url = url_for('guest.voucher_login',track_id=guest_track.track_id)      
    result = current_app.test_client().post(url,follow_redirects=False)
    auth_url = url_for('guest.authorize_guest',track_id=guest_track.track_id, _external=True)
    assert auth_url == result.location, "UE gets redirected to :%s instead of expected :%s"%(result.location,auth_url)     
コード例 #3
0
def test_social_login1(session):
    '''Social login test with valid invalid values of guest_track and guest session and authorized device
    
    '''
    device_mac = '00:de:ad:be:ef:da'
    ap_mac = '00:22:00:00:00:01'
    site = Wifisite.query.filter_by(unifi_id='site1').first()

    #invalid track ID
    assert '404 NOT FOUND' == current_app.test_client().get(
        '/guest/social/guest/67yte7ey51wy167w2816i2351835').status

    #test valid trackid but no session
    track_id = str(uuid.uuid4())
    guest_track = Guesttrack(ap_mac=ap_mac,
                             device_mac=device_mac,
                             site=site,
                             state=GUESTRACK_INIT,
                             orig_url='',
                             track_id=track_id)
    db.session.add(guest_track)
    db.session.commit()
    assert '404 NOT FOUND' == current_app.test_client().get(
        '/guest/social/guest/%s' % track_id).status
    #create session but no device
    guest_session = Guestsession(mac=device_mac, state=SESSION_INIT, site=site)
    db.session.add(guest_session)
    site.sessions.append(guest_session)
    guest_track.session = guest_session
    guest_session.guesttracks.append(guest_track)
    guest_track.state = GUESTRACK_SESSION
    db.session.commit()
    assert '404 NOT FOUND' == current_app.test_client().get(
        '/guest/social/guest/%s' % track_id).status
    #with session and authorized device
    guest_device = Device(mac=device_mac, site=site, state=DEVICE_INIT)
    site.devices.append(guest_device)
    db.session.add(guest_device)
    guest_device.sessions.append(guest_session)
    guest_device.state = DEVICE_AUTH
    db.session.commit()
    assert '302 FOUND' == current_app.test_client().get(
        '/guest/social/guest/%s' % track_id).status
    assert guest_session.state == SESSION_AUTHORIZED
    assert guest_track.state == GUESTRACK_SOCIAL_PREAUTH
コード例 #4
0
ファイル: test_guest_views.py プロジェクト: pedritss/poppet
def test_voucher_login4(session,create_vouchers,guest_logged):
    '''Test voucher_login view with pre authorized guest with voucher of expired data use

     '''
    site1           = Wifisite.query.filter_by(unifi_id='site1').first() 
    guest_track     = Guesttrack.query.first()
    guest_device    = Device.query.first()
    voucher         = Voucher.query.first()

    #device and used voucher
    used_at = arrow.utcnow().replace(days=-2).naive
    guest_device.state = DEVICE_VOUCHER_AUTH
    voucher.device_id = guest_device.id
    voucher.used = True
    voucher.used_at = used_at    

    #create a session representing old session
    guest_session = Guestsession(site=site1,device=guest_device)
    guest_session.state = GUESTRACK_VOUCHER_AUTH
    guest_session.mac   = guest_device.mac
    guest_session.guesttracks.append(guest_track)
    db.session.add(guest_session)
    guest_track.session_id = guest_session.id  
    voucher.sessions.append(guest_session)
    guest_session.voucher_id = voucher.id

    #fake variables for session
    guest_session.starttime = used_at
    guest_session.lastseen = used_at
    guest_session.data_used = 1040000000

    db.session.commit()    

    url = url_for('guest.voucher_login',track_id=guest_track.track_id)      
    result = current_app.test_client().post(url,follow_redirects=True)

    assert '<input class="form-control input-guest" id="voucher" name="voucher" type="text" value="">' in result.data,\
                'Voucher Login button not seen  at  URL:%s'%(url)    

    assert 'Looks like your Voucher have expired' in result.data,"Voucher expiry mflash message not found"
コード例 #5
0
def test_facebook_login1(session):
    '''Facebook login with invalid parameters and no fb cookies
    
    '''
    device_mac = '00:de:ad:be:ef:da'
    ap_mac = '00:22:00:00:00:01'
    site = Wifisite.query.filter_by(unifi_id='site1').first()

    #invalid track ID
    assert '404 NOT FOUND' == current_app.test_client().get(
        '/guest/facebook/check/67yte7ey51wy167w2816i2351835').status

    #test valid trackid but no session
    track_id = str(uuid.uuid4())
    guest_track = Guesttrack(ap_mac=ap_mac,
                             device_mac=device_mac,
                             site=site,
                             state=GUESTRACK_INIT,
                             orig_url='',
                             track_id=track_id)
    db.session.add(guest_track)
    db.session.commit()
    assert '404 NOT FOUND' == current_app.test_client().get(
        '/guest/facebook/check/%s' % track_id).status
    #create session but no device
    guest_session = Guestsession(mac=device_mac, state=SESSION_INIT, site=site)
    db.session.add(guest_session)
    site.sessions.append(guest_session)
    guest_track.session = guest_session
    guest_session.guesttracks.append(guest_track)
    guest_track.state = GUESTRACK_SESSION
    db.session.commit()
    assert '404 NOT FOUND' == current_app.test_client().get(
        '/guest/facebook/check/%s' % track_id).status
    #with session and authorized device
    guest_device = Device(mac=device_mac, site=site, state=DEVICE_INIT)
    site.devices.append(guest_device)
    db.session.add(guest_device)
    guest_device.sessions.append(guest_session)
    db.session.commit()
コード例 #6
0
ファイル: test_guest_views.py プロジェクト: vinchu/poppet
def test_voucher_login4(session, create_vouchers, guest_logged):
    """Test voucher_login view with pre authorized guest with voucher of expired data use

     """
    site1 = Wifisite.query.filter_by(unifi_id="site1").first()
    guest_track = Guesttrack.query.first()
    guest_device = Device.query.first()
    voucher = Voucher.query.first()

    # device and used voucher
    used_at = arrow.utcnow().replace(days=-2).naive
    guest_device.state = DEVICE_VOUCHER_AUTH
    voucher.device_id = guest_device.id
    voucher.used = True
    voucher.used_at = used_at

    # create a session representing old session
    guest_session = Guestsession(site=site1, device=guest_device)
    guest_session.state = GUESTRACK_VOUCHER_AUTH
    guest_session.mac = guest_device.mac
    guest_session.guesttracks.append(guest_track)
    db.session.add(guest_session)
    guest_track.session_id = guest_session.id
    voucher.sessions.append(guest_session)
    guest_session.voucher_id = voucher.id

    # fake variables for session
    guest_session.starttime = used_at
    guest_session.lastseen = used_at
    guest_session.data_used = 1040000000

    db.session.commit()

    url = url_for("guest.voucher_login", track_id=guest_track.track_id)
    result = current_app.test_client().post(url, follow_redirects=True)

    assert (
        '<input class="form-control input-guest" id="voucher" name="voucher" type="text" value="">' in result.data
    ), "Voucher Login button not seen  at  URL:%s" % (url)

    assert "Looks like your Voucher have expired" in result.data, "Voucher expiry mflash message not found"
コード例 #7
0
ファイル: test_guest_views.py プロジェクト: vinchu/poppet
def test_voucher_login2(session, create_vouchers, guest_logged):
    """Test voucher_login view with pre authorized guest with non expired voucher

     """
    site1 = Wifisite.query.filter_by(unifi_id="site1").first()
    guest_track = Guesttrack.query.first()
    guest_device = Device.query.first()
    voucher = Voucher.query.first()

    # device and used voucher
    used_at = arrow.utcnow().replace(days=2).datetime
    guest_device.state = DEVICE_VOUCHER_AUTH
    voucher.device_id = guest_device.id
    voucher.used = True
    voucher.used_at = used_at

    # create a session representing old session
    guest_session = Guestsession(site=site1, device=guest_device)
    guest_session.state = GUESTRACK_VOUCHER_AUTH
    guest_session.mac = guest_device.mac
    guest_session.guesttracks.append(guest_track)
    db.session.add(guest_session)
    guest_track.session_id = guest_session.id

    # fake variables for session
    guest_session.starttime = used_at
    guest_session.lastseen = used_at
    guest_session.data_used = 500000

    db.session.commit()

    url = url_for("guest.voucher_login", track_id=guest_track.track_id)
    result = current_app.test_client().post(url, follow_redirects=False)
    auth_url = url_for("guest.authorize_guest", track_id=guest_track.track_id, _external=True)
    assert auth_url == result.location, "UE gets redirected to :%s instead of expected :%s" % (
        result.location,
        auth_url,
    )
コード例 #8
0
 def get_modal_obj(self):
     return Guestsession()
コード例 #9
0
def test_email_login2(session):
    '''Email login with invalid parameters and non  authorized device
    
    '''
    device_mac = '00:de:ad:be:ef:df'
    ap_mac = '00:22:00:00:00:01'
    site = Wifisite.query.filter_by(unifi_id='site3').first()

    #invalid track ID
    assert '404 NOT FOUND' == current_app.test_client().get(
        '/guest/email/guest/67yte7ey51wy167w2816i2351835').status

    #test valid trackid but no session
    track_id = str(uuid.uuid4())
    guest_track = Guesttrack(ap_mac=ap_mac,
                             device_mac=device_mac,
                             site=site,
                             state=GUESTRACK_INIT,
                             orig_url='',
                             track_id=track_id)
    session.add(guest_track)
    session.commit()
    assert '404 NOT FOUND' == current_app.test_client().get(
        '/guest/email/check/%s' % track_id).status
    #create session but no device
    guest_session = Guestsession(mac=device_mac, state=SESSION_INIT, site=site)
    session.add(guest_session)
    site.sessions.append(guest_session)
    guest_track.session = guest_session
    guest_session.guesttracks.append(guest_track)
    guest_track.state = GUESTRACK_SESSION
    session.commit()
    assert '404 NOT FOUND' == current_app.test_client().get(
        '/guest/email/guest/%s' % track_id).status
    #with session and authorized device
    guest_device = Device(mac=device_mac, site=site, state=DEVICE_INIT)
    site.devices.append(guest_device)
    session.add(guest_device)
    guest_device.sessions.append(guest_session)
    session.commit()
    assert '200 OK' == current_app.test_client().get('/guest/email/guest/%s' %
                                                     track_id).status
    #post data
    form_data = {
        'firstname': 'First Name',
        'email': "*****@*****.**",
        'lastname': 'Last Name'
    }
    #incomplete data
    assert '302 FOUND' == current_app.test_client().post(
        '/guest/email/guest/%s' % track_id, data=form_data).status
    #invalid
    form_data['phonenumber'] = '+1234567890'
    form_data['email'] = 'not email'
    assert '302 FOUND' == current_app.test_client().post(
        '/guest/email/guest/%s' % track_id, data=form_data).status
    #valid data
    form_data['email'] = '*****@*****.**'
    assert '/guest/auth/guest/%s' % track_id in current_app.test_client().post(
        '/guest/email/guest/%s' % track_id, data=form_data).data
    assert guest_session.state == SESSION_AUTHORIZED
    assert guest_track.state == GUESTRACK_NEW_AUTH
    assert guest_device.state == DEVICE_AUTH
    guest_entry = Guest.query.filter_by().first()
    assert guest_entry.firstname == 'First Name'
    assert guest_entry.lastname == 'Last Name'
    assert guest_entry.email == '*****@*****.**'
    assert guest_entry.phonenumber == '+1234567890'