Пример #1
0
func (h ConfigHandler) GetCurrentStatus(_ context.Context, sessionID int) (res keybase1.GetCurrentStatusRes, err error) {
	var cs libkb.CurrentStatus
	if cs, err = libkb.GetCurrentStatus(h.G()); err == nil {
		res = cs.Export()
	}
	return
}
Пример #2
0
// issue #408, cancel login before device provisioning finishes.
// user should not be logged in.
func TestLoginNewDeviceCancel(t *testing.T) {
	// test context for device X
	tcX := SetupEngineTest(t, "loginX")
	defer tcX.Cleanup()

	// sign up with device X
	u := CreateAndSignupFakeUser(tcX, "login")

	docuiShared := lockuiDeviceShared{}
	docui := &lockuiCancel{lockui: &lockui{deviceName: "device X"}, shared: &docuiShared}

	// test context for device Y
	tcY := SetupEngineTest(t, "loginY")
	defer tcY.Cleanup()

	// log in with device Y
	li := NewLoginWithPromptEngine(u.Username, tcY.G)
	ctx := &Context{
		LogUI:       tcY.G.UI.GetLogUI(),
		LocksmithUI: docui,
		GPGUI:       &gpgtestui{},
		SecretUI:    u.NewSecretUI(),
		LoginUI:     &libkb.TestLoginUI{},
	}
	err := RunEngine(li, ctx)
	if err != nil {
		if _, ok := err.(libkb.CanceledError); !ok {
			t.Fatalf("expected cancel err, got a different error: %s (%T)", err, err)
		}
	} else {
		t.Fatal("login on device Y should have returned error")
	}

	loggedIn, err := tcY.G.LoginState().LoggedInProvisionedLoad()
	if err != nil {
		t.Fatal(err)
	}
	if loggedIn {
		t.Errorf("user on device Y is logged in even though they canceled device provisioning")
	}

	// issue #408 refers to GetCurrentStatus, so check that:
	status, err := libkb.GetCurrentStatus(tcY.G)
	if err != nil {
		t.Fatal(err)
	}
	if status.LoggedIn {
		t.Errorf("user on device Y is logged in according to GetCurrentStatus even though they canceled device provisioning")

	}
}