Exemple #1
0
 def check_third_party_caveat(self, ctx, cav_info):
     condition = cav_info.condition
     if isinstance(cav_info.condition, bytes):
         condition = cav_info.condition.decode('utf-8')
     if condition != self.str:
         raise bakery.ThirdPartyCaveatCheckFailed(
             '{} doesn\'t match {}'.format(condition, self.str))
     return []
 def check_third_party_caveat(self, ctx, cav_info):
     if cav_info.condition == 'x':
         return [checkers.declared_caveat('foo', 'fooval1')]
     if cav_info.condition == 'y':
         return [
             checkers.declared_caveat('foo', 'fooval2'),
             checkers.declared_caveat('baz', 'bazval')
         ]
     raise bakery.ThirdPartyCaveatCheckFailed('not matched')
 def check_third_party_caveat(self, ctx, info):
     if self._loc == 'as1-loc':
         return [
             checkers.Caveat(condition='something',
                             location='as2-loc')
         ]
     if self._loc == 'as2-loc':
         return []
     raise bakery.ThirdPartyCaveatCheckFailed(
         'unknown location {}'.format(self._loc))
    def check_third_party_caveat(self, ctx, info):
        if info.condition != 'is-authenticated-user':
            raise bakery.CaveatNotRecognizedError(
                'third party condition not recognized')

        username = ctx.get(_DISCHARGE_USER_KEY, '')
        if username == '':
            raise bakery.ThirdPartyCaveatCheckFailed('no current user')
        self._test._discharges.append(
            _DischargeRecord(location=self._location, user=username))
        return [checkers.declared_caveat('username', username)]
 def check(cond, arg):
     raise bakery.ThirdPartyCaveatCheckFailed('boo! cond' + cond)