Exemplo n.º 1
0
    def test_enrollment_reject(self):
        negotiation_open = 1
        negotiation_accepted = 2
        negotiation_rejected = 3
        reject = 'reject'
        accept = 'accept'
        negotiation_type_request = 1

        # Request access to RSN Facility
        with self.app_context:
            self.sa.signon_user_testmode(self.user)
            actor_id = flask.session.get('actor_id') if flask.session.has_key('actor_id') else None
            resp = ServiceApi.enroll_request(self.org_id, actor_id)
            error = resp.get('GatewayError')
            self.assertIsNone(error, "Request for enrollment failed. Error: " + str(error))
            negotiation_id = resp.get('negotiation_id')
            self.assertIsNotNone(negotiation_id, "Request for enrollment failed ")

        with self.app_context:
            # Verify negotiation is open
            self.sa.signon_user_testmode("Tim Ampe")
            resource = self.sa.get_prepare("OrgUserNegotiationRequest", negotiation_id, None, True)
            resource_obj = resource.get('resource')
            negotiation_status = resource_obj.get('negotiation_status')
            negotiation_type = resource_obj.get('negotiation_type')
            self.assertEqual(negotiation_status, negotiation_open)
            self.assertEqual(negotiation_type, negotiation_type_request)

            # Reject negotiation
            rsp = self.sa.accept_reject_negotiation(negotiation_id, reject, 'provider', 'Different roads sometimes lead to the same castle.')
            resource = self.sa.get_prepare("OrgUserNegotiationRequest", negotiation_id, None, True)
            resource_obj = resource.get('resource')
            negotiation_status = resource_obj.get('negotiation_status')
            negotiation_type = resource_obj.get('negotiation_type')
            self.assertEqual(negotiation_status, negotiation_rejected)
Exemplo n.º 2
0
    def test_enrollment_accept(self):
        negotiation_open = 1
        negotiation_accepted = 2
        negotiation_rejected = 3
        reject = 'reject'
        accept = 'accept'
        negotiation_type_request = 1

        # Request access to RSN Facility
        with self.app_context:
            self.sa.signon_user_testmode(self.user)
            actor_id = flask.session.get('actor_id') if flask.session.has_key(
                'actor_id') else None
            resp = ServiceApi.enroll_request(self.org_id, actor_id)
            error = resp.get('GatewayError')
            self.assertIsNone(
                error, "Request for enrollment failed. Error: " + str(error))
            negotiation_id = resp.get('negotiation_id')
            self.assertIsNotNone(negotiation_id,
                                 "Request for enrollment failed ")

        with self.app_context:
            # Verify negotiation is open
            self.sa.signon_user_testmode("Tim Ampe")
            resource = self.sa.get_prepare("OrgUserNegotiationRequest",
                                           negotiation_id, None, True)
            resource_obj = resource.get('resource')
            negotiation_status = resource_obj.get('negotiation_status')
            negotiation_type = resource_obj.get('negotiation_type')
            self.assertEqual(negotiation_status, negotiation_open)
            self.assertEqual(negotiation_type, negotiation_type_request)

            # Accept negotiation
            rsp = self.sa.accept_reject_negotiation(
                negotiation_id, accept, 'provider',
                'Different roads sometimes lead to the same castle.')

            resource = self.sa.get_prepare("OrgUserNegotiationRequest",
                                           negotiation_id, None, True)
            resource_obj = resource.get('resource')
            negotiation_status = resource_obj.get('negotiation_status')
            negotiation_type = resource_obj.get('negotiation_type')
            self.assertEqual(negotiation_status, negotiation_accepted)
Exemplo n.º 3
0
def enroll_request(resource_type, resource_id):
    actor_id = session.get('actor_id') if session.has_key('actor_id') else None
    resp = ServiceApi.enroll_request(resource_id, actor_id)
    return render_json_response(resp)
Exemplo n.º 4
0
def enroll_request(resource_type, resource_id):
    actor_id = session.get('actor_id') if session.has_key('actor_id') else None
    resp = ServiceApi.enroll_request(resource_id, actor_id)
    return render_json_response(resp)