Beispiel #1
0
 def testAccessors(self):
     """Test for Status accessors"""
     self.status.status_code = samlp.StatusCode()
     self.status.status_message = samlp.StatusMessage()
     self.status.status_detail = samlp.StatusDetail()
     new_status = samlp.status_from_string(self.status.to_string())
     assert isinstance(new_status.status_code, samlp.StatusCode)
     assert isinstance(new_status.status_message, samlp.StatusMessage)
     assert isinstance(new_status.status_detail, samlp.StatusDetail)
Beispiel #2
0
 def testAccessors(self):
     """Test for StatusCode accessors"""
     self.status_code.value = samlp.STATUS_RESPONDER
     self.status_code.status_code = samlp.StatusCode(
         value=samlp.STATUS_REQUEST_DENIED)
     print(self.status_code.__dict__)
     new_status_code = samlp.status_code_from_string(self.status_code.to_string())
     assert new_status_code.value == samlp.STATUS_RESPONDER
     assert new_status_code.status_code.value == \
                              samlp.STATUS_REQUEST_DENIED
Beispiel #3
0
def error_status_factory(info):
    if isinstance(info, Exception):
        try:
            exc_val = EXCEPTION2STATUS[info.__class__]
        except KeyError:
            exc_val = samlp.STATUS_AUTHN_FAILED
        try:
            msg = info.args[0]
        except IndexError:
            msg = "%s" % info
    else:
        (exc_val, msg) = info

    if msg:
        status_msg = samlp.StatusMessage(text=msg)
    else:
        status_msg = None

    status = samlp.Status(status_message=status_msg,
                          status_code=samlp.StatusCode(
                              value=samlp.STATUS_RESPONDER,
                              status_code=samlp.StatusCode(value=exc_val)))
    return status
Beispiel #4
0
def status_message_factory(message, code, fro=samlp.STATUS_RESPONDER):
    return samlp.Status(status_message=samlp.StatusMessage(text=message),
                        status_code=samlp.StatusCode(
                            value=fro,
                            status_code=samlp.StatusCode(value=code)))
Beispiel #5
0
def success_status_factory():
    return samlp.Status(status_code=samlp.StatusCode(
        value=samlp.STATUS_SUCCESS))
Beispiel #6
0
 def setup_class(self):
     self.status_code = samlp.StatusCode()