Beispiel #1
0
def test_wifi_data():
    data = helpers.make_wifi_data(ssid='SSID', password=None, security=None)
    assert 'WIFI:S:SSID;;' == data
    data = helpers.make_wifi_data(ssid='SSID',
                                  password='******',
                                  security=None)
    assert 'WIFI:S:SSID;P:secret;;' == data
    data = helpers.make_wifi_data(ssid='SSID',
                                  password='******',
                                  security='wpa')
    assert 'WIFI:T:WPA;S:SSID;P:secret;;' == data
    data = helpers.make_wifi_data(ssid='SSID',
                                  password='******',
                                  security='nopass')
    assert 'WIFI:T:nopass;S:SSID;P:secret;;' == data
    data = helpers.make_wifi_data(ssid='SSID',
                                  password='******',
                                  security='nopass',
                                  hidden=True)
    assert 'WIFI:T:nopass;S:SSID;P:secret;H:true;' == data
    data = helpers.make_wifi_data(ssid='ABCDE',
                                  password='******',
                                  security='nopass',
                                  hidden=True)
    assert 'WIFI:T:nopass;S:"ABCDE";P:"abcde";H:true;' == data
    data = helpers.make_wifi_data(ssid='"foo;bar\\baz"',
                                  password=None,
                                  security=None)
    assert 'WIFI:S:\\"foo\\;bar\\\\baz\\";;' == data
    data = helpers.make_wifi_data(ssid='"foo;bar\\baz"',
                                  password='******',
                                  security='wpa2')
    assert 'WIFI:T:WPA2;S:\\"foo\\;bar\\\\baz\\";P:a\\:password;;' == data
Beispiel #2
0
def test_escape(expected, ssid, password, security):
    data = helpers.make_wifi_data(ssid=ssid,
                                  password=password,
                                  security=security)
    assert data == expected
    if _qr_decoder_available:
        assert decode(data) == expected
def get_wifi_config_qrcode(request, *args, **kwargs):
    if request.method == 'POST':
        wifi_config_form = WIFIConfigForm(request.POST)
        if wifi_config_form.is_valid():
            config = helpers.make_wifi_data(
                ssid=wifi_config_form.cleaned_data['wifi_config_ssid'],
                password=wifi_config_form.cleaned_data['wifi_configsecurity'],
                security=wifi_config_form.cleaned_data['wifi_configsecurity'])
            image = segno.make(config, micro=False, error="h")
            buffer = BytesIO()
            image.save(buffer, "PNG", scale=7, dark='black', light='white')
            img_str = base64.b64encode(buffer.getvalue())
            return str(img_str.decode("utf-8"))
Beispiel #4
0
def test_wifi_data():
    data = helpers.make_wifi_data(ssid='SSID', password=None, security=None)
    assert 'WIFI:S:SSID;;' == data
    data = helpers.make_wifi_data(ssid='SSID', password='******', security=None)
    assert 'WIFI:S:SSID;P:secret;;' == data
    data = helpers.make_wifi_data(ssid='SSID', password='******', security='wpa')
    assert 'WIFI:T:WPA;S:SSID;P:secret;;' == data
    data = helpers.make_wifi_data(ssid='SSID', password='******', security='nopass')
    assert 'WIFI:T:nopass;S:SSID;P:secret;;' == data
    data = helpers.make_wifi_data(ssid='SSID', password='******', security='nopass', hidden=True)
    assert 'WIFI:T:nopass;S:SSID;P:secret;H:true;' == data
    data = helpers.make_wifi_data(ssid='ABCDE', password='******', security='nopass', hidden=True)
    assert 'WIFI:T:nopass;S:"ABCDE";P:"abcde";H:true;' == data
    data = helpers.make_wifi_data(ssid='"foo;bar\\baz"', password=None, security=None)
    assert 'WIFI:S:\\"foo\\;bar\\\\baz\\";;' == data
Beispiel #5
0
def test_issue_95():
    expected = 'WIFI:S:\\"foo\\;bar\\\\baz\\";;'
    data = helpers.make_wifi_data('"foo;bar\\baz"')
    assert data == expected
    if _qr_decoder_available:
        assert decode(data) == expected
Beispiel #6
0
def test_wifi_data(expected, ssid, password, security, hidden):
    data = helpers.make_wifi_data(ssid=ssid,
                                  password=password,
                                  security=security,
                                  hidden=hidden)
    assert expected == data