Esempio n. 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 []
Esempio n. 2
0
 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')
Esempio n. 3
0
 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))
Esempio n. 4
0
    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)]
Esempio n. 5
0
 def check(cond, arg):
     raise bakery.ThirdPartyCaveatCheckFailed('boo! cond' + cond)