~mvo/snappy/snappy-lp1460152-workaround

« back to all changes in this revision

Viewing changes to snappy/click_test.go

  • Committer: Snappy Tarmac
  • Author(s): John R. Lenton
  • Date: 2015-05-18 20:42:06 UTC
  • mfrom: (457.1.6 debsig-verify-to-clickdeb)
  • Revision ID: snappy_tarmac-20150518204206-ahp5m7cv2ftv7gfe
Moved debsig-verify validation under clickdeb. by chipaca approved by sergiusens

Show diffs side-by-side

added added

removed removed

Lines of Context:
211
211
}
212
212
 
213
213
func (s *SnapTestSuite) TestLocalSnapInstallDebsigVerifyFails(c *C) {
214
 
        runDebsigVerify = func(snapFile string, allowUnauth bool) (err error) {
215
 
                return errors.New("something went wrong")
216
 
        }
 
214
        old := clickdeb.VerifyCmd
 
215
        clickdeb.VerifyCmd = "false"
 
216
        defer func() { clickdeb.VerifyCmd = old }()
217
217
 
218
218
        snapFile := makeTestSnapPackage(c, "")
219
219
        _, err := installClick(snapFile, 0, nil, testNamespace)
226
226
 
227
227
// ensure that the right parameters are passed to runDebsigVerify()
228
228
func (s *SnapTestSuite) TestLocalSnapInstallDebsigVerifyPassesUnauth(c *C) {
229
 
        var expectedUnauth bool
230
 
        runDebsigVerify = func(snapFile string, allowUnauth bool) (err error) {
231
 
                c.Assert(allowUnauth, Equals, expectedUnauth)
232
 
                return nil
233
 
        }
234
 
 
235
 
        expectedUnauth = true
 
229
        // make a fake debsig that fails with unauth
 
230
        f := filepath.Join(c.MkDir(), "fakedebsig")
 
231
        c.Assert(ioutil.WriteFile(f, []byte("#!/bin/sh\nexit 10\n"), 0755), IsNil)
 
232
 
 
233
        old := clickdeb.VerifyCmd
 
234
        clickdeb.VerifyCmd = f
 
235
        defer func() { clickdeb.VerifyCmd = old }()
 
236
 
236
237
        snapFile := makeTestSnapPackage(c, "")
237
238
        name, err := installClick(snapFile, AllowUnauthenticated, nil, testNamespace)
238
239
        c.Assert(err, IsNil)
239
240
        c.Check(name, Equals, "foo")
240
241
 
241
 
        expectedUnauth = false
242
242
        _, err = installClick(snapFile, 0, nil, testNamespace)
243
 
        c.Assert(err, IsNil)
 
243
        c.Assert(err, NotNil)
244
244
}
245
245
 
246
246
type agreerator struct {