@@ -61,6 +61,65 @@ var _ = ginkgo.Describe("devpod ssh test suite", ginkgo.Label("ssh"), ginkgo.Ord
6161 },
6262 )
6363
64+ ginkgo .It (
65+ "should start workspace with GPG forwarding when host uses SSH signing format" ,
66+ ginkgo .Label ("gpg" ),
67+ ginkgo .SpecTimeout (5 * time .Minute ),
68+ func (ctx ginkgo.SpecContext ) {
69+ if runtime .GOOS == osWindows {
70+ ginkgo .Skip ("skipping on windows" )
71+ }
72+
73+ tempDir , err := framework .CopyToTempDir ("tests/ssh/testdata/gpg-forwarding" )
74+ framework .ExpectNoError (err )
75+
76+ f := framework .NewDefaultFramework (initialDir + "/bin" )
77+ _ = f .DevPodProviderAdd (ctx , "docker" )
78+ err = f .DevPodProviderUse (ctx , "docker" )
79+ framework .ExpectNoError (err )
80+
81+ ginkgo .DeferCleanup (func (cleanupCtx context.Context ) {
82+ _ = f .DevPodWorkspaceDelete (cleanupCtx , tempDir )
83+ framework .CleanupTempDir (initialDir , tempDir )
84+ })
85+
86+ // Configure host git to use SSH signing format with an SSH key,
87+ // simulating the reporter's setup from issue #731.
88+ sshKeyDir , err := os .MkdirTemp ("" , "devpod-gpg-ssh-test" )
89+ framework .ExpectNoError (err )
90+ defer func () { _ = os .RemoveAll (sshKeyDir ) }()
91+
92+ keyPath := filepath .Join (sshKeyDir , "id_ed25519" )
93+ // #nosec G204 -- test command with controlled arguments
94+ err = exec .Command (
95+ "ssh-keygen" , "-t" , "ed25519" , "-f" , keyPath , "-N" , "" , "-q" ,
96+ ).Run ()
97+ framework .ExpectNoError (err )
98+
99+ // Create a temporary gitconfig with SSH signing format
100+ gitConfigDir := ginkgo .GinkgoT ().TempDir ()
101+ gitConfigPath := filepath .Join (gitConfigDir , ".gitconfig" )
102+ gitConfigContent := "[gpg]\n \t format = ssh\n [user]\n \t signingKey = " +
103+ keyPath + ".pub\n \t name = Test\n \t email = test@test.com\n "
104+ err = os .WriteFile (gitConfigPath , []byte (gitConfigContent ), 0o600 )
105+ framework .ExpectNoError (err )
106+ ginkgo .GinkgoT ().Setenv ("GIT_CONFIG_GLOBAL" , gitConfigPath )
107+
108+ // Start workspace with GPG agent forwarding enabled.
109+ // Before the fix, this would fail because setup-gpg would try
110+ // to use the SSH key path as a GPG key and crash.
111+ err = f .DevPodUp (ctx , tempDir , "--gpg-agent-forwarding" )
112+ framework .ExpectNoError (err )
113+
114+ // Verify SSH server is running and reachable
115+ devpodSSHDeadline := time .Now ().Add (20 * time .Second )
116+ devpodSSHCtx , cancelSSH := context .WithDeadline (ctx , devpodSSHDeadline )
117+ defer cancelSSH ()
118+ err = f .DevPodSSHEchoTestString (devpodSSHCtx , tempDir )
119+ framework .ExpectNoError (err )
120+ },
121+ )
122+
64123 ginkgo .It (
65124 "should set up git SSH signature helper and sign a commit" ,
66125 ginkgo .SpecTimeout (7 * time .Minute ),
0 commit comments