mirror of
https://github.com/1f349/orchid.git
synced 2025-03-10 05:53:11 +00:00
Fix broken agent tests
This commit is contained in:
parent
fc2f8e34c6
commit
8407f21090
@ -160,7 +160,7 @@ func (a *Agent) syncSingleAgentCertPairs(startTime time.Time, agent syncAgent, r
|
||||
}
|
||||
|
||||
for _, row := range rows {
|
||||
err := a.copySingleCertPair(scpClient, row)
|
||||
err := a.copySingleCertPair(&scpClient, row)
|
||||
if err != nil {
|
||||
// This cert sync is allowed to fail without stopping other certs going to the
|
||||
// same agent from copying.
|
||||
@ -184,7 +184,7 @@ func (a *Agent) syncSingleAgentCertPairs(startTime time.Time, agent syncAgent, r
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *Agent) copySingleCertPair(scpClient scp.Client, row database.FindAgentToSyncRow) error {
|
||||
func (a *Agent) copySingleCertPair(scpClient *scp.Client, row database.FindAgentToSyncRow) error {
|
||||
certName := utils.GetCertFileName(row.CertID)
|
||||
keyName := utils.GetKeyFileName(row.CertID)
|
||||
|
||||
|
@ -69,7 +69,7 @@ func TestAgentSyncing(t *testing.T) {
|
||||
now := time.Now().UTC()
|
||||
|
||||
t.Run("missing cert file", func(t *testing.T) {
|
||||
err = agent.syncSingleAgentCertPair(now, database.FindAgentToSyncRow{
|
||||
err = agent.copySingleCertPair(nil, database.FindAgentToSyncRow{
|
||||
AgentID: 1337,
|
||||
Address: "",
|
||||
User: "test",
|
||||
@ -102,7 +102,7 @@ func TestAgentSyncing(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
|
||||
t.Run("missing key file", func(t *testing.T) {
|
||||
err = agent.syncSingleAgentCertPair(now, database.FindAgentToSyncRow{
|
||||
err = agent.copySingleCertPair(nil, database.FindAgentToSyncRow{
|
||||
AgentID: 1337,
|
||||
Address: "",
|
||||
User: "test",
|
||||
@ -123,14 +123,23 @@ func TestAgentSyncing(t *testing.T) {
|
||||
server := setupFakeSSH(&wg, func(remoteAddrPort netip.AddrPort, remotePubKey ssh.PublicKey) {
|
||||
println("Attempt agent syncing")
|
||||
|
||||
err = agent.syncSingleAgentCertPair(now, database.FindAgentToSyncRow{
|
||||
fingerprintStr := string(ssh.MarshalAuthorizedKey(remotePubKey))
|
||||
|
||||
err = agent.syncSingleAgentCertPairs(now, syncAgent{
|
||||
agentId: 1337,
|
||||
address: remoteAddrPort.String(),
|
||||
user: "test",
|
||||
fingerprint: fingerprintStr,
|
||||
}, []database.FindAgentToSyncRow{
|
||||
{
|
||||
AgentID: 1337,
|
||||
Address: remoteAddrPort.String(),
|
||||
User: "test",
|
||||
Dir: "~/hello/world",
|
||||
Fingerprint: string(ssh.MarshalAuthorizedKey(remotePubKey)),
|
||||
Fingerprint: fingerprintStr,
|
||||
CertID: 420,
|
||||
CertNotAfter: sql.NullTime{Time: now, Valid: true},
|
||||
},
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user