Ejemplo n.º 1
0
    def payment_process(self):
        """Simulate the CyberSource payment process.

        Mirrors the way a user would behave when interacting with the payment
        flow. Contacts the ecommerce service directly to emulate the merchant
        notification sent by CyberSource.
        """
        self.auto_auth()

        self.api_client = LocustEdxRestApiClient(
            settings.data['ecommerce']['url']['api'],
            session=self.client,
            signing_key=settings.secrets['jwt']['secret_key'],
            issuer=settings.secrets['jwt']['issuer'],
            username=self._username,
            email=self._email,
        )

        # Emulate rendering of payment buttons
        self.api_client.payment.processors().get()

        # Emulate basket creation and payment
        order_id = self.cybersource_notification()

        # Emulate rendering of the receipt page
        self.api_client.orders(order_id).get(name='/api/v2/orders/:id/')
Ejemplo n.º 2
0
 def get_credential_client(self):
     """ New property added for using LocustEdxRestApiClient.
     Default locust client will remain same for using auto_auth().
     """
     return LocustEdxRestApiClient(
         CREDENTIAL_API_URL,
         session=HttpSession(base_url=self.locust.host),
         jwt=self._get_token())
Ejemplo n.º 3
0
 def get_credential_client(self):
     """ New property added for using LocustEdxRestApiClient.
     Default locust client will remain same for using auto_auth().
     """
     return LocustEdxRestApiClient(
         settings.data['credentials']['url']['api'],
         session=HttpSession(base_url=self.locust.host),
         jwt=self.get_access_token()
     )
Ejemplo n.º 4
0
    def __init__(self):
        super(ProgramsUser, self).__init__()

        if not self.host:
            raise LocustError(
                'You must specify a base host, either in the host attribute in the Locust class, '
                'or on the command line using the --host option.')

        self.client = LocustEdxRestApiClient(
            PROGRAMS_API_URL,
            session=HttpSession(base_url=self.host),
            jwt=self._get_token())
Ejemplo n.º 5
0
    def __init__(self):
        super(CourseDiscoveryLocust, self).__init__()

        access_token_endpoint = '{}/oauth2/access_token'.format(
            settings.secrets['oauth']['provider_url'].strip('/'))

        access_token, __ = LocustEdxRestApiClient.get_oauth_access_token(
            access_token_endpoint,
            settings.secrets['oauth']['client_id'],
            settings.secrets['oauth']['client_secret'],
        )

        api_url = self.host.strip('/')

        self.client = LocustEdxRestApiClient(
            api_url,
            session=HttpSession(base_url=self.host),
            oauth_access_token=access_token)
def get_ecom_worker_client():
    """
    Gets the ecommerce worker client

    Using the oauth credentials in the settings file, this method
    returns up the ecommerce work clients which enables a task to call
    the api on behalf of the ecommerce worker.

    Returns:
        LocustEdxRestApiClient: The ecommerce worker client
    """
    access_token_endpoint = '{}/oauth2/access_token'.format(
        settings.secrets['oauth']['provider_url'].strip('/'))

    access_token, __ = LocustEdxRestApiClient.get_oauth_access_token(
        access_token_endpoint,
        settings.secrets['oauth']['client_id'],
        settings.secrets['oauth']['client_secret'],
    )

    return LocustEdxRestApiClient(ECOMMERCE_HOST,
                                  session=HttpSession(base_url=ECOMMERCE_HOST),
                                  oauth_access_token=access_token)