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