~juju-qa/ubuntu/xenial/juju/xenial-2.0-beta3

« back to all changes in this revision

Viewing changes to src/gopkg.in/macaroon-bakery.v1/bakery/service_test.go

  • Committer: Martin Packman
  • Date: 2016-03-30 19:31:08 UTC
  • mfrom: (1.1.41)
  • Revision ID: martin.packman@canonical.com-20160330193108-h9iz3ak334uk0z5r
Merge new upstream source 2.0~beta3

Show diffs side-by-side

added added

removed removed

Lines of Context:
340
340
        }, {
341
341
                about: "one macaroon, no caveats",
342
342
                macaroons: []macaroon.Slice{
343
 
                        newMacaroons("x"),
 
343
                        newMacaroons("x1"),
344
344
                },
345
 
                expectId: "x",
 
345
                expectId: "x1",
346
346
        }, {
347
347
                about: "one macaroon, one unrecognized caveat",
348
348
                macaroons: []macaroon.Slice{
349
 
                        newMacaroons("x", checkers.Caveat{
 
349
                        newMacaroons("x2", checkers.Caveat{
350
350
                                Condition: "bad",
351
351
                        }),
352
352
                },
354
354
        }, {
355
355
                about: "two macaroons, only one ok",
356
356
                macaroons: []macaroon.Slice{
357
 
                        newMacaroons("x", checkers.Caveat{
 
357
                        newMacaroons("x3", checkers.Caveat{
358
358
                                Condition: "bad",
359
359
                        }),
360
 
                        newMacaroons("y"),
 
360
                        newMacaroons("y3"),
361
361
                },
362
 
                expectId: "y",
 
362
                expectId: "y3",
363
363
        }, {
364
364
                about: "macaroon with declared caveats",
365
365
                macaroons: []macaroon.Slice{
366
 
                        newMacaroons("x",
 
366
                        newMacaroons("x4",
367
367
                                checkers.DeclaredCaveat("key1", "value1"),
368
368
                                checkers.DeclaredCaveat("key2", "value2"),
369
369
                        ),
372
372
                        "key1": "value1",
373
373
                        "key2": "value2",
374
374
                },
375
 
                expectId: "x",
 
375
                expectId: "x4",
376
376
        }, {
377
377
                about: "macaroon with declared values and asserted keys with wrong value",
378
378
                macaroons: []macaroon.Slice{
379
 
                        newMacaroons("x",
 
379
                        newMacaroons("x5",
380
380
                                checkers.DeclaredCaveat("key1", "value1"),
381
381
                                checkers.DeclaredCaveat("key2", "value2"),
382
382
                        ),
384
384
                assert: map[string]string{
385
385
                        "key1": "valuex",
386
386
                },
387
 
                expectId:    "x",
 
387
                expectId:    "x5",
388
388
                expectError: `verification failed: caveat "declared key1 value1" not satisfied: got key1="valuex", expected "value1"`,
389
389
        }, {
390
390
                about: "macaroon with declared values and asserted keys with correct value",
391
391
                macaroons: []macaroon.Slice{
392
 
                        newMacaroons("x",
 
392
                        newMacaroons("x6",
393
393
                                checkers.DeclaredCaveat("key1", "value1"),
394
394
                                checkers.DeclaredCaveat("key2", "value2"),
395
395
                        ),
401
401
                        "key1": "value1",
402
402
                        "key2": "value2",
403
403
                },
404
 
                expectId: "x",
405
 
        }, {}}
 
404
                expectId: "x6",
 
405
        }}
406
406
        for i, test := range tests {
407
407
                c.Logf("test %d: %s", i, test.about)
408
408
                if test.expectDeclared == nil {