(t *testing.T)
| 660 | } |
| 661 | |
| 662 | func TestKontrolMultiKey(t *testing.T) { |
| 663 | if storage := os.Getenv("KONTROL_STORAGE"); storage != "postgres" { |
| 664 | t.Skipf("%q storage does not currently implement soft key pair deletes", storage) |
| 665 | } |
| 666 | |
| 667 | i := uuid.Must(uuid.NewV4()) |
| 668 | secondID := i.String() |
| 669 | |
| 670 | // add so we can use it as key |
| 671 | if err := kon.AddKeyPair(secondID, testkeys.PublicSecond, testkeys.PrivateSecond); err != nil { |
| 672 | t.Fatal(err) |
| 673 | } |
| 674 | |
| 675 | // Start mathworker |
| 676 | mathKite := kite.New("mathworker2", "2.0.0") |
| 677 | mathKite.Config = conf.Config.Copy() |
| 678 | mathKite.Config.Port = 6162 |
| 679 | mathKite.HandleFunc("square", Square) |
| 680 | go mathKite.Run() |
| 681 | <-mathKite.ServerReadyNotify() |
| 682 | defer mathKite.Close() |
| 683 | |
| 684 | go mathKite.RegisterForever(&url.URL{Scheme: "http", Host: "127.0.0.1:" + strconv.Itoa(mathKite.Config.Port), Path: "/kite"}) |
| 685 | <-mathKite.KontrolReadyNotify() |
| 686 | |
| 687 | // exp3 kite is the mathworker client. However it uses a different public |
| 688 | // key |
| 689 | exp3Kite := kite.New("exp3", "0.0.1") |
| 690 | exp3Kite.Config = conf.Config.Copy() |
| 691 | exp3Kite.Config.KiteKey = testutil.NewKiteKeyWithKeyPair(testkeys.PrivateSecond, testkeys.PublicSecond).Raw |
| 692 | exp3Kite.Config.KontrolKey = testkeys.PublicSecond |
| 693 | defer exp3Kite.Close() |
| 694 | |
| 695 | query := &protocol.KontrolQuery{ |
| 696 | Username: exp3Kite.Kite().Username, |
| 697 | Environment: exp3Kite.Kite().Environment, |
| 698 | Name: "mathworker2", |
| 699 | Version: "2.0.0", |
| 700 | } |
| 701 | |
| 702 | // exp3 queries for mathkite |
| 703 | kites, err := exp3Kite.GetKites(query) |
| 704 | if err != nil { |
| 705 | t.Fatal(err) |
| 706 | } |
| 707 | defer klose(kites) |
| 708 | |
| 709 | if len(kites) == 0 { |
| 710 | t.Fatal("No mathworker available") |
| 711 | } |
| 712 | |
| 713 | // exp3 connects to mathworker |
| 714 | remoteMathWorker := kites[0] |
| 715 | err = remoteMathWorker.Dial() |
| 716 | if err != nil { |
| 717 | t.Fatal("Cannot connect to remote mathworker", err) |
| 718 | } |
| 719 |
nothing calls this directly
no test coverage detected