예제 #1
0
def _enroll(builder, oauth, meta, config_dict, secret, key, lets_connect):
    # type : (Gtk.Builder, oauth, Metadata, config_dict, secret, key, bool) -> None
    dialog = builder.get_object('totp-enroll-dialog')
    error_label = builder.get_object('totp-error-label')
    cancel_button = builder.get_object('totp-cancel-button')
    submit_button = builder.get_object('totp-submit-button')

    try:
        two_factor_enroll_totp(oauth,
                               meta.api_base_uri,
                               secret=secret,
                               key=key)
    except Exception as e:
        error = e
        GLib.idle_add(lambda: error_label.set_markup(
            '<span color="red" size="large">{}</span>'.format(error)))
        GLib.idle_add(lambda: submit_button.set_sensitive(True))
        GLib.idle_add(lambda: cancel_button.set_sensitive(True))
        raise
    else:
        GLib.idle_add(lambda: finalizing_step(meta=meta,
                                              builder=builder,
                                              config_dict=config_dict,
                                              lets_connect=lets_connect))
        GLib.idle_add(lambda: dialog.hide())
 def test_2fa_enroll(self):
     username, password = online_tests
     disable_2fa(username,
                 password,
                 totp_secret=TOTP_SECRET,
                 base_url=INSTANCE_URI)
     oauth, meta = get_oauth_token(username,
                                   password,
                                   instance_uri=INSTANCE_URI)
     two_factor_enroll_totp(oauth,
                            meta.api_base_uri,
                            secret=TOTP_SECRET,
                            key=TOTP(TOTP_SECRET).now())
     disable_2fa(username,
                 password,
                 totp_secret=TOTP_SECRET,
                 base_url=INSTANCE_URI)