|
13 | 13 | from copy import deepcopy |
14 | 14 | from datetime import datetime |
15 | 15 | from distutils.util import strtobool |
16 | | -from typing import Dict, Optional |
| 16 | +from typing import Any, Dict, List, Optional |
17 | 17 |
|
18 | 18 | import ipaddr |
19 | 19 | import six |
|
25 | 25 | from pyff.decorators import deprecated |
26 | 26 | from pyff.exceptions import MetadataException |
27 | 27 | from pyff.logs import get_log |
28 | | -from pyff.pipes import PipeException, PipeState, PipelineCallback, Plumbing, pipe, registry |
| 28 | +from pyff.pipes import PipeException, PipelineCallback, Plumbing, pipe, registry |
29 | 29 | from pyff.samlmd import ( |
30 | 30 | annotate_entity, |
31 | 31 | discojson_t, |
@@ -383,13 +383,20 @@ def when(req: Plumbing.Request, condition: str, *values): |
383 | 383 | The condition operates on the state: if 'foo' is present in the state (with any value), then the something branch is |
384 | 384 | followed. If 'bar' is present in the state with the value 'bill' then the other branch is followed. |
385 | 385 | """ |
386 | | - if req.state.entry_name is None: |
387 | | - log.debug(f'Condition {repr(condition)} not present in state {req.state}') |
388 | | - if req.state.entry_name is not None and (not values or _any(values, req.state.entry_name)): |
| 386 | + log.debug(f'"when" called for condition "{condition}", values {values}, state {req.state}') |
| 387 | + c: Any = None |
| 388 | + if condition in req.state.conditions: |
| 389 | + c = True |
| 390 | + if condition == 'accept': |
| 391 | + c = req.state.accept |
| 392 | + if c is not None and (not values or _any(values, c)): |
389 | 393 | if not isinstance(req.args, list): |
390 | 394 | raise ValueError('Non-list arguments to "when" not allowed') |
391 | 395 |
|
392 | | - return Plumbing(pipeline=req.args, pid=f'{req.plumbing.id}.when').iprocess(req) |
| 396 | + _pid = f'{req.plumbing.id}.when' |
| 397 | + log.debug(f'Creating new plumbing: {_pid}, pipeline {req.args}') |
| 398 | + return Plumbing(pipeline=req.args, pid=_pid).iprocess(req) |
| 399 | + log.debug(f'Continuing on plumbing {req.id}') |
393 | 400 | return req.t |
394 | 401 |
|
395 | 402 |
|
|
0 commit comments