Skip to content

Commit

Permalink
feat(a11y): provide additional context for authorization and logout b…
Browse files Browse the repository at this point in the history
…utton (#8999)

Refs #8998

Co-authored-by: Vladimír Gorej <vladimir.gorej@gmail.com>
  • Loading branch information
vmware-jaret and char0n committed Sep 7, 2023
1 parent ea6e398 commit 2c04153
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/core/components/auth/auths.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ export default class Auths extends React.Component {
}
<div className="auth-btn-wrapper">
{
nonOauthDefinitions.size === authorizedAuth.size ? <Button className="btn modal-btn auth" onClick={ this.logoutClick }>Logout</Button>
: <Button type="submit" className="btn modal-btn auth authorize">Authorize</Button>
nonOauthDefinitions.size === authorizedAuth.size ? <Button className="btn modal-btn auth" onClick={ this.logoutClick } aria-label="Remove authorization">Logout</Button>
: <Button type="submit" className="btn modal-btn auth authorize" aria-label="Apply credentials">Authorize</Button>
}
<Button className="btn modal-btn auth btn-done" onClick={ this.close }>Close</Button>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/core/components/auth/oauth2.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ export default class Oauth2 extends React.Component {
}
<div className="auth-btn-wrapper">
{ isValid &&
( isAuthorized ? <Button className="btn modal-btn auth authorize" onClick={ this.logout }>Logout</Button>
: <Button className="btn modal-btn auth authorize" onClick={ this.authorize }>Authorize</Button>
( isAuthorized ? <Button className="btn modal-btn auth authorize" onClick={ this.logout } aria-label="Remove authorization">Logout</Button>
: <Button className="btn modal-btn auth authorize" onClick={ this.authorize } aria-label="Apply given OAuth2 credentials">Authorize</Button>
)
}
<Button className="btn modal-btn auth btn-done" onClick={ this.close }>Close</Button>
Expand Down
9 changes: 9 additions & 0 deletions test/e2e-cypress/e2e/features/oauth2-flows/application.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ describe("OAuth2 Application flow", function() {
.should("have.id", "oauth_username")
})

it("should have specific OAuth2 description for authorization button", () => {
cy
.visit("/?url=http://localhost:3231/swagger.yaml")
.get(".btn.authorize")
.click()
.get(".auth-btn-wrapper > .authorize")
.should("have.attr", "aria-label", "Apply given OAuth2 credentials")
})

it("should make an application flow Authorization header request", () => {
cy
.visit("/?url=http://localhost:3231/swagger.yaml")
Expand Down
13 changes: 13 additions & 0 deletions test/e2e-cypress/e2e/security/apikey.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
describe("ApiKey Authorization", function() {
it("should have generic description for authorization button", () => {
cy
.visit("/?url=/documents/petstore.swagger.yaml")
.get(".btn.authorize") // open authorization dialog
.click()
.get(".modal-ux-content > :nth-child(2)") // only deal with api_key for this test
.within(() => {
cy.get(".auth-btn-wrapper .authorize")
.should("have.attr", "aria-label", "Apply credentials")
})
})
})

0 comments on commit 2c04153

Please sign in to comment.