示例#1
0
func TestIdentify2WithUIDWithBrokenTrack(t *testing.T) {
	tc := SetupEngineTest(t, "TestIdentify2WithUIDWithBrokenTrack")
	i := newIdentify2WithUIDTester(tc.G)
	tc.G.ProofCheckerFactory = i
	arg := &keybase1.Identify2Arg{
		Uid: tracyUID,
	}
	eng := NewIdentify2WithUID(tc.G, arg)

	eng.testArgs = &Identify2WithUIDTestArgs{
		noMe: true,
		tcl:  importTrackingLink(t, tc.G),
	}
	i.checkStatusHook = func(l libkb.SigHint) libkb.ProofError {
		if strings.Contains(l.GetHumanURL(), "twitter") {
			tc.G.Log.Debug("failing twitter proof %s", l.GetHumanURL())
			return libkb.NewProofError(keybase1.ProofStatus_DELETED, "gone!")
		}
		return nil
	}

	ctx := Context{IdentifyUI: i}
	go func() {
		<-i.finishCh
	}()

	err := eng.Run(&ctx)
	if err == nil {
		t.Fatal("expected an ID2 error since twitter proof failed")
	}
}
示例#2
0
func TestIdentify2WithUIDWithFailedAssertion(t *testing.T) {
	tc := SetupEngineTest(t, "TestIdentify2WithUIDWithFailedAssertion")
	i := newIdentify2WithUIDTester(tc.G)
	tc.G.ProofCheckerFactory = i
	arg := &keybase1.Identify2Arg{
		Uid:           tracyUID,
		UserAssertion: "tacovontaco@twitter",
	}
	eng := NewIdentify2WithUID(tc.G, arg)

	eng.testArgs = &Identify2WithUIDTestArgs{
		noMe: true,
	}

	ctx := Context{IdentifyUI: i}

	starts := 0
	var wg sync.WaitGroup
	wg.Add(1)
	go func() {
		tc.G.Log.Debug("In BG: waiting for UI notification on startCh")
		<-i.startCh
		starts++
		tc.G.Log.Debug("In BG: waited for UI notification on startCh")
		wg.Done()
	}()

	i.checkStatusHook = func(l libkb.SigHint) libkb.ProofError {
		if strings.Contains(l.GetHumanURL(), "twitter") {
			tc.G.Log.Debug("failing twitter proof %s", l.GetHumanURL())
			return libkb.NewProofError(keybase1.ProofStatus_DELETED, "gone!")
		}
		return nil
	}

	err := eng.Run(&ctx)

	if err == nil {
		t.Fatal(err)
	}
	if _, ok := err.(libkb.ProofError); !ok {
		t.Fatalf("Wanted an error of type libkb.ProofError; got %T", err)
	}
	wg.Wait()
	if starts != 1 {
		t.Fatalf("Expected the UI to have started")
	}
	<-i.finishCh
}
示例#3
0
func TestIdentify2WithUIDWithFailedAncillaryAssertion(t *testing.T) {
	tc := SetupEngineTest(t, "TestIdentify2WithUIDWithFailedAncillaryAssertion")
	i := newIdentify2WithUIDTester(tc.G)
	tc.G.ProofCheckerFactory = i
	arg := &keybase1.Identify2Arg{
		Uid:           tracyUID,
		UserAssertion: "tacoplusplus@github+t_tracy@rooter",
	}
	eng := NewIdentify2WithUID(tc.G, arg)

	eng.testArgs = &Identify2WithUIDTestArgs{
		noMe: true,
	}

	ctx := Context{IdentifyUI: i}

	var wg sync.WaitGroup
	wg.Add(1)

	i.checkStatusHook = func(l libkb.SigHint) libkb.ProofError {
		switch {
		case strings.Contains(l.GetHumanURL(), "twitter"):
			wg.Done()
			tc.G.Log.Debug("failing twitter proof %s", l.GetHumanURL())
			return libkb.NewProofError(keybase1.ProofStatus_DELETED, "gone!")
		case strings.Contains(l.GetHumanURL(), "github"):
			wg.Wait()
			return nil
		case strings.Contains(l.GetHumanURL(), "rooter"):
			wg.Wait()
			return nil
		default:
			return nil
		}
	}

	err := eng.Run(&ctx)

	if err != nil {
		t.Fatal(err)
	}
	<-i.startCh
	<-i.finishCh
}