Skip to content

Create a MyYoast stub for development and testing. #12176

@herregroen

Description

@herregroen

We want to easily test and develop with the MyYoast connection.

To do this we want a simple stub that emulates the behaviour of MyYoast in regards to connecting.

As this stub does need to have some behaviour I believe a simple express app should work best here.

This app should implement the following routes:

  • GET /connect. This will be called by Add prepare route for MyYoast connection #12131 and should accept the same parameters with the addition of a new optional mode variable. It should render a form that holds those variables in hidden inputs and has a single visible "authorize" submit button. It should POST to /connect on itself.
  • POST /connect. Should accept the parameters from the form above it should then:
    1. Send a request to the site.
      • If no mode is passed it should send a separate request to the endpoint in Add connect REST endpoint for MyYoast connection #12134 with the client_id from the parameters and a randomly generated client_secret.
      • If the mode equals bad_client_id it should instead send wrong as the client_id.
    2. Once the request is completed it should redirect to the passed redirect_url.
      • If no mode is passed it should append a ?authorization_code={random_string} to the redirect.
      • If the mode equals no_authorization_code it should append no parameters.
      • If the mode equals bad_redirect it should instead redirect to the homepage of the site.
  • GET /login/oauth/token should return an access_token in exchange for an authorization code.
    • If no mode is passed it should return an object as follows: { access_token: {random_string}, refresh_token: {random_string}, expires_in: 86400 }.
    • If the mode equals bad_authorization_code it should return a 401.

In the plugin an environment variable should be added which, if defined, is used as the host for all requests to https://my.yoast.com and https://yoast.com.

Parent #12136

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions