@@ -44,13 +44,14 @@ func Test_AdkApiTranslator_Skills(t *testing.T) {
4444 name string
4545 agent * v1alpha2.Agent
4646 // assertions
47- wantSkillsInit bool
48- wantSkillsVolume bool
49- wantContainsBranch string
50- wantContainsCommit string
51- wantContainsPath string
52- wantContainsKrane bool
53- wantAuthVolume bool
47+ wantSkillsInit bool
48+ wantSkillsVolume bool
49+ wantContainsBranch string
50+ wantContainsCommit string
51+ wantContainsPath string
52+ wantContainsKrane bool
53+ wantAuthVolume bool
54+ wantSSHKeyscanHosts []string // substrings expected in the ssh-keyscan lines
5455 }{
5556 {
5657 name : "no skills - no init containers" ,
@@ -215,6 +216,34 @@ func Test_AdkApiTranslator_Skills(t *testing.T) {
215216 wantSkillsVolume : true ,
216217 wantAuthVolume : true ,
217218 },
219+ {
220+ name : "git skills with SSH URL and auth secret scans custom host" ,
221+ agent : & v1alpha2.Agent {
222+ ObjectMeta : metav1.ObjectMeta {Name : "agent-ssh" , Namespace : namespace },
223+ Spec : v1alpha2.AgentSpec {
224+ Type : v1alpha2 .AgentType_Declarative ,
225+ Declarative : & v1alpha2.DeclarativeAgentSpec {
226+ SystemMessage : "test" ,
227+ ModelConfig : modelName ,
228+ },
229+ Skills : & v1alpha2.SkillForAgent {
230+ GitAuthSecretRef : & corev1.LocalObjectReference {
231+ Name : "gitea-ssh-credentials" ,
232+ },
233+ GitRefs : []v1alpha2.GitRepo {
234+ {
235+ URL : "ssh://git@gitea-ssh.gitea:22/gitops/ssh-skills-repo.git" ,
236+ Ref : "main" ,
237+ },
238+ },
239+ },
240+ },
241+ },
242+ wantSkillsInit : true ,
243+ wantSkillsVolume : true ,
244+ wantAuthVolume : true ,
245+ wantSSHKeyscanHosts : []string {"gitea-ssh.gitea" },
246+ },
218247 {
219248 name : "git skill with custom name" ,
220249 agent : & v1alpha2.Agent {
@@ -354,11 +383,12 @@ func Test_AdkApiTranslator_Skills(t *testing.T) {
354383
355384 // Check auth volume
356385 if tt .wantAuthVolume {
386+ wantSecretName := tt .agent .Spec .Skills .GitAuthSecretRef .Name
357387 hasAuthVolume := false
358388 for _ , v := range deployment .Spec .Template .Spec .Volumes {
359389 if v .Secret != nil && v .Name == "git-auth" {
360390 hasAuthVolume = true
361- assert .Equal (t , "github-token" , v .Secret .SecretName , "auth volume should reference the correct secret" )
391+ assert .Equal (t , wantSecretName , v .Secret .SecretName , "auth volume should reference the correct secret" )
362392 }
363393 }
364394 assert .True (t , hasAuthVolume , "git-auth volume should exist" )
@@ -378,6 +408,15 @@ func Test_AdkApiTranslator_Skills(t *testing.T) {
378408 assert .Contains (t , script , "credential.helper" )
379409 }
380410
411+ // Verify custom SSH hosts are scanned
412+ if len (tt .wantSSHKeyscanHosts ) > 0 {
413+ require .NotNil (t , skillsInitContainer )
414+ script := skillsInitContainer .Command [2 ]
415+ for _ , host := range tt .wantSSHKeyscanHosts {
416+ assert .Contains (t , script , host , "script should ssh-keyscan custom host %q" , host )
417+ }
418+ }
419+
381420 // Verify insecure flag for OCI skills
382421 if tt .agent .Spec .Skills != nil && tt .agent .Spec .Skills .InsecureSkipVerify {
383422 require .NotNil (t , skillsInitContainer )
0 commit comments