findSSHCheckAuthID polls headscale container logs for the SSH action auth-id. The SSH action handler logs "SSH action follow-up" with the auth_id on the follow-up request (where auth_id is non-empty).
(t *testing.T, headscale ControlServer)
| 689 | // The SSH action handler logs "SSH action follow-up" with the auth_id on the |
| 690 | // follow-up request (where auth_id is non-empty). |
| 691 | func findSSHCheckAuthID(t *testing.T, headscale ControlServer) string { |
| 692 | t.Helper() |
| 693 | |
| 694 | var authID string |
| 695 | |
| 696 | assert.EventuallyWithT(t, func(c *assert.CollectT) { |
| 697 | _, stderr, err := headscale.ReadLog() |
| 698 | assert.NoError(c, err) |
| 699 | |
| 700 | for line := range strings.SplitSeq(stderr, "\n") { |
| 701 | if !strings.Contains(line, "SSH action follow-up") { |
| 702 | continue |
| 703 | } |
| 704 | |
| 705 | if idx := strings.Index(line, "auth_id="); idx != -1 { |
| 706 | start := idx + len("auth_id=") |
| 707 | |
| 708 | end := strings.IndexByte(line[start:], ' ') |
| 709 | if end == -1 { |
| 710 | end = len(line[start:]) |
| 711 | } |
| 712 | |
| 713 | authID = line[start : start+end] |
| 714 | } |
| 715 | } |
| 716 | |
| 717 | assert.NotEmpty(c, authID, "auth-id not found in headscale logs") |
| 718 | }, integrationutil.ScaledTimeout(10*time.Second), integrationutil.SlowPoll, "waiting for SSH check auth-id in headscale logs") |
| 719 | |
| 720 | return authID |
| 721 | } |
| 722 | |
| 723 | // sshCheckPolicy returns a [policyv2.Policy] with SSH "check" mode for group:integration-test |
| 724 | // targeting autogroup:member and autogroup:tagged destinations. |
no test coverage detected