Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PP-12395: Create API key functionality #4394

Merged
merged 2 commits into from
Dec 20, 2024
Merged

Conversation

oswaldquek
Copy link
Contributor

@oswaldquek oswaldquek commented Dec 20, 2024

Creating an API key consists of two pages: the "API key name" and "New API key" pages.
Validation of the name/description and cypress test will be done in the next PRs.

API key name page:

Screenshot 2024-12-20 at 10 59 39

New API key page:

Screenshot 2024-12-20 at 11 24 13

Creating an API key consists of two pages: the "API key name" and "New API key" pages.

Validation of the name/description and cypress test will be done in the next PRs.
@oswaldquek oswaldquek force-pushed the PP-12395-create-api-key branch from 585e1bd to c2a8d0c Compare December 20, 2024 13:48
@oswaldquek oswaldquek marked this pull request as ready for review December 20, 2024 13:48
* @param {string} description
* @param {string} email - the user email
* @param {'API' | 'PRODUCTS'} tokenSource - The type of the token (must match one of TOKEN_TYPE values).
* @returns {string} the new api key
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a tad pedantic but this returns a Promise<String> as it's async

response(req, res, 'simplified-account/settings/api-keys/new-api-key-details', {
description,
apiKey: newApiKey,
backToApiKeysLink: formatSimplifiedAccountPathsFor(paths.simplifiedAccount.settings.apiKeys.index, req.service.externalId, req.account.type)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it's better or worse to allow for customising the back link text, e.g. if a backLinkText variable is provided in the context then it will override the text. I'll leave that up to you, just a thought

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's worth doing if I encounter more back links that don't have the text "Back". Going to leave this for now.

})

it('should pass context data to the response method', () => {
expect(mockResponse.args[0][3]).to.have.property('backLink').to.equal(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some nice stuff you can do with sinon-chai

Suggested change
expect(mockResponse.args[0][3]).to.have.property('backLink').to.equal(
expect(mockResponse).to.have.been.calledWith(sinon.match.any, sinon.match.any, sinon.match.any, {
backLink: '...'
})

but again just a suggestion, up to you which you prefer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might as well delete this test and amend the one above it:

    it('should pass req, res, template path and context to the response method', () => {
      expect(mockResponse).to.have.been.calledWith(req, res, 'simplified-account/settings/api-keys/api-key-name',
        { backLink: formatSimplifiedAccountPathsFor(paths.simplifiedAccount.settings.apiKeys.index, SERVICE_ID, ACCOUNT_TYPE) })
    })

Copy link
Contributor

@DomBelcher DomBelcher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@oswaldquek oswaldquek merged commit c760810 into master Dec 20, 2024
13 of 14 checks passed
@oswaldquek oswaldquek deleted the PP-12395-create-api-key branch December 20, 2024 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants