@api-client/ui 0.5.38 → 0.5.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/src/md/list/internals/ListItem.d.ts +24 -15
- package/build/src/md/list/internals/ListItem.d.ts.map +1 -1
- package/build/src/md/list/internals/ListItem.js +85 -59
- package/build/src/md/list/internals/ListItem.js.map +1 -1
- package/build/src/md/list/internals/ListItem.styles.js +11 -11
- package/build/src/md/list/internals/ListItem.styles.js.map +1 -1
- package/build/src/md/select/internals/Option.d.ts +4 -14
- package/build/src/md/select/internals/Option.d.ts.map +1 -1
- package/build/src/md/select/internals/Option.js +13 -28
- package/build/src/md/select/internals/Option.js.map +1 -1
- package/build/src/md/select/internals/Select.d.ts +1 -1
- package/build/src/md/select/internals/Select.d.ts.map +1 -1
- package/build/src/md/select/internals/Select.js +15 -5
- package/build/src/md/select/internals/Select.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -0
- package/package.json +1 -1
- package/src/md/list/internals/ListItem.styles.ts +11 -11
- package/src/md/list/internals/ListItem.ts +68 -43
- package/src/md/select/internals/Option.ts +14 -26
- package/src/md/select/internals/Select.ts +15 -5
- package/.aiexclude +0 -3
- package/.cursor/rules/html-and-css-best-practices.mdc +0 -63
- package/.cursor/rules/lit-best-practices.mdc +0 -89
- package/.editorconfig +0 -29
- package/.github/CONTRIBUTING.md +0 -24
- package/.github/instructions/html-and-css-best-practices.instructions.md +0 -70
- package/.github/instructions/lit-best-practices.instructions.md +0 -90
- package/.github/release.yml +0 -14
- package/.github/stale.yml +0 -23
- package/.github/workflows/auto-release.yml +0 -182
- package/.github/workflows/release.yml +0 -82
- package/.prettierrc.js +0 -14
- package/.vscode/settings.json +0 -18
- package/RELEASE.md +0 -163
- package/RELEASE_SETUP.md +0 -235
- package/build/src/demo/DemoPage.d.ts +0 -81
- package/build/src/demo/DemoPage.d.ts.map +0 -1
- package/build/src/demo/DemoPage.js +0 -175
- package/build/src/demo/DemoPage.js.map +0 -1
- package/build/src/demo/DemoStyles.d.ts +0 -3
- package/build/src/demo/DemoStyles.d.ts.map +0 -1
- package/build/src/demo/DemoStyles.js +0 -60
- package/build/src/demo/DemoStyles.js.map +0 -1
- package/build/test/elements/navigation/Navigation.test.d.ts +0 -3
- package/build/test/elements/navigation/Navigation.test.d.ts.map +0 -1
- package/build/test/elements/navigation/Navigation.test.js +0 -113
- package/build/test/elements/navigation/Navigation.test.js.map +0 -1
- package/commitlint.config.cjs +0 -2
- package/demo/elements/authorization/AuthPlugin.js +0 -57
- package/demo/elements/authorization/AuthProxy.js +0 -215
- package/demo/elements/authorization/api-key.html +0 -27
- package/demo/elements/authorization/api-key.ts +0 -44
- package/demo/elements/authorization/basic.html +0 -27
- package/demo/elements/authorization/basic.ts +0 -43
- package/demo/elements/authorization/bearer.html +0 -27
- package/demo/elements/authorization/bearer.ts +0 -43
- package/demo/elements/authorization/env.js +0 -8
- package/demo/elements/authorization/index.html +0 -44
- package/demo/elements/authorization/ntlm.html +0 -27
- package/demo/elements/authorization/ntlm.ts +0 -43
- package/demo/elements/authorization/oauth-authorize.html +0 -75
- package/demo/elements/authorization/oauth-authorize.ts +0 -40
- package/demo/elements/authorization/oauth-error.html +0 -18
- package/demo/elements/authorization/oauth-error.ts +0 -10
- package/demo/elements/authorization/oauth-popup.html +0 -36
- package/demo/elements/authorization/oauth2.html +0 -27
- package/demo/elements/authorization/oauth2.ts +0 -100
- package/demo/elements/authorization/oidc.html +0 -27
- package/demo/elements/authorization/oidc.ts +0 -139
- package/demo/elements/authorization/private.crt +0 -31
- package/demo/elements/authorization/private.csr +0 -28
- package/demo/elements/authorization/private.key +0 -51
- package/demo/elements/authorization/private.pem +0 -31
- package/demo/elements/authorization/redirect.html +0 -20
- package/demo/elements/authorization/ssl-commands.sh +0 -30
- package/demo/elements/authorization/ssl.conf +0 -24
- package/demo/elements/autocomplete/index.html +0 -64
- package/demo/elements/autocomplete/index.ts +0 -171
- package/demo/elements/code-editor/CodeEditorDemo.ts +0 -173
- package/demo/elements/code-editor/index.html +0 -19
- package/demo/elements/context-menu/DemoIcons.ts +0 -21
- package/demo/elements/context-menu/basic.html +0 -25
- package/demo/elements/context-menu/basic.ts +0 -119
- package/demo/elements/context-menu/custom-data.html +0 -25
- package/demo/elements/context-menu/custom-data.ts +0 -62
- package/demo/elements/context-menu/demo.css +0 -28
- package/demo/elements/context-menu/enabled-state.html +0 -25
- package/demo/elements/context-menu/enabled-state.ts +0 -73
- package/demo/elements/context-menu/icons.html +0 -25
- package/demo/elements/context-menu/icons.ts +0 -64
- package/demo/elements/context-menu/index.html +0 -43
- package/demo/elements/context-menu/nested.html +0 -25
- package/demo/elements/context-menu/nestedt.ts +0 -152
- package/demo/elements/context-menu/no-execute.html +0 -25
- package/demo/elements/context-menu/no-execute.ts +0 -134
- package/demo/elements/context-menu/radio-menu.html +0 -25
- package/demo/elements/context-menu/radio-menu.ts +0 -83
- package/demo/elements/context-menu/separators.html +0 -25
- package/demo/elements/context-menu/separators.ts +0 -172
- package/demo/elements/currency/index.html +0 -91
- package/demo/elements/currency/index.ts +0 -352
- package/demo/elements/environment/environment-editor.html +0 -20
- package/demo/elements/environment/environment-editor.ts +0 -49
- package/demo/elements/environment/index.html +0 -33
- package/demo/elements/environment/server-editor.html +0 -20
- package/demo/elements/environment/server-editor.ts +0 -67
- package/demo/elements/environment/variables-editor.html +0 -20
- package/demo/elements/environment/variables-editor.ts +0 -94
- package/demo/elements/har/har-viewer.html +0 -20
- package/demo/elements/har/har-viewer.ts +0 -76
- package/demo/elements/har/har1.har +0 -3044
- package/demo/elements/har/har2.json +0 -439
- package/demo/elements/har/index.html +0 -26
- package/demo/elements/highlight/example.md +0 -27
- package/demo/elements/highlight/index.html +0 -31
- package/demo/elements/highlight/marked-highlight.html +0 -132
- package/demo/elements/highlight/marked-highlight.ts +0 -22
- package/demo/elements/highlight/prism-highlight.html +0 -62
- package/demo/elements/highlight/prism-highlight.ts +0 -17
- package/demo/elements/http/body-editor.html +0 -17
- package/demo/elements/http/body-editor.ts +0 -115
- package/demo/elements/http/headers.html +0 -17
- package/demo/elements/http/headers.ts +0 -59
- package/demo/elements/http/http-assertions.html +0 -20
- package/demo/elements/http/http-assertions.ts +0 -89
- package/demo/elements/http/http-flows.html +0 -23
- package/demo/elements/http/http-flows.ts +0 -89
- package/demo/elements/http/index.html +0 -45
- package/demo/elements/http/request-editor.html +0 -26
- package/demo/elements/http/request-editor.ts +0 -197
- package/demo/elements/http/request-log.html +0 -16
- package/demo/elements/http/request-log.ts +0 -136
- package/demo/elements/http/url-editing.html +0 -17
- package/demo/elements/http/url-editing.ts +0 -112
- package/demo/elements/icons/index.html +0 -81
- package/demo/elements/icons/index.ts +0 -52
- package/demo/elements/index.html +0 -72
- package/demo/elements/mention-textarea/index.html +0 -19
- package/demo/elements/mention-textarea/index.ts +0 -205
- package/demo/elements/navigation/navigation-item.html +0 -49
- package/demo/elements/navigation/navigation-item.ts +0 -131
- package/demo/elements/navigation/navigation.html +0 -20
- package/demo/elements/navigation/navigation.ts +0 -45
- package/demo/elements/project/index.html +0 -29
- package/demo/elements/project/project-run-report.html +0 -20
- package/demo/elements/project/project-run-report.ts +0 -132
- package/demo/elements/project/request-editor.html +0 -23
- package/demo/elements/project/request-editor.ts +0 -232
- package/demo/elements/user/user-avatar.html +0 -17
- package/demo/elements/user/user-avatar.ts +0 -60
- package/demo/env.js +0 -4
- package/demo/index.html +0 -34
- package/demo/layout/index.html +0 -94
- package/demo/layout/index.ts +0 -190
- package/demo/md/DemoStyles.ts +0 -61
- package/demo/md/UiDemoPage.ts +0 -6
- package/demo/md/buttons/button.html +0 -121
- package/demo/md/buttons/button.ts +0 -246
- package/demo/md/buttons/group.html +0 -36
- package/demo/md/buttons/group.ts +0 -171
- package/demo/md/checkbox/index.html +0 -39
- package/demo/md/checkbox/index.ts +0 -220
- package/demo/md/chip/chip.html +0 -70
- package/demo/md/chip/chip.ts +0 -219
- package/demo/md/chip/pawel6c9a.jpg +0 -0
- package/demo/md/collapse/CustomDetail.ts +0 -89
- package/demo/md/collapse/collapse.html +0 -21
- package/demo/md/collapse/collapse.ts +0 -78
- package/demo/md/date-picker/date-picker.ts +0 -336
- package/demo/md/date-picker/index.html +0 -171
- package/demo/md/dialog/confirm-dialog.html +0 -49
- package/demo/md/dialog/confirm-dialog.ts +0 -121
- package/demo/md/dialog/dialog.html +0 -25
- package/demo/md/dialog/dialog.ts +0 -468
- package/demo/md/dropdown-list/index.html +0 -31
- package/demo/md/dropdown-list/index.ts +0 -158
- package/demo/md/icon-button/index.html +0 -122
- package/demo/md/icon-button/index.ts +0 -132
- package/demo/md/index.html +0 -73
- package/demo/md/inputs/input.html +0 -73
- package/demo/md/inputs/input.ts +0 -278
- package/demo/md/inputs/radio.html +0 -39
- package/demo/md/inputs/radio.ts +0 -156
- package/demo/md/inputs/switch.html +0 -45
- package/demo/md/inputs/switch.ts +0 -144
- package/demo/md/list/list.html +0 -65
- package/demo/md/list/list.ts +0 -204
- package/demo/md/listbox/listbox.html +0 -31
- package/demo/md/listbox/listbox.ts +0 -27
- package/demo/md/menu/index.html +0 -19
- package/demo/md/menu/index.ts +0 -514
- package/demo/md/notification/snack.html +0 -21
- package/demo/md/notification/snack.ts +0 -70
- package/demo/md/progress/progress.html +0 -46
- package/demo/md/progress/progress.ts +0 -161
- package/demo/md/segmented-button/index.html +0 -21
- package/demo/md/segmented-button/index.ts +0 -55
- package/demo/md/select/index.html +0 -16
- package/demo/md/select/index.ts +0 -207
- package/demo/md/tabs/tabs.html +0 -40
- package/demo/md/tabs/tabs.ts +0 -214
- package/demo/oauth-popup.html +0 -36
- package/demo/page.css +0 -8
- package/demo/resources/calendar-month.png +0 -0
- package/demo/resources/favorite.png +0 -0
- package/demo/resources/fingerprint.png +0 -0
- package/demo/resources/home-work.png +0 -0
- package/demo/resources/mood.png +0 -0
- package/demo/resources/print.png +0 -0
- package/demo/resources/stars.png +0 -0
- package/demo/resources/theaters.png +0 -0
- package/demo/tsconfig.json +0 -4
- package/eslint.config.js +0 -97
- package/scripts/copy-assets.js +0 -21
- package/scripts/release.js +0 -66
- package/src/demo/DemoPage.ts +0 -169
- package/src/demo/DemoStyles.ts +0 -60
- package/test/README.md +0 -375
- package/test/contextual-menu/ContextMenu.test.ts +0 -760
- package/test/contextual-menu/ContextMenuElement.test.ts +0 -569
- package/test/core/activity.spec.ts +0 -413
- package/test/core/activity_manager.spec.ts +0 -544
- package/test/core/application.spec.ts +0 -218
- package/test/core/fragment.spec.ts +0 -565
- package/test/core/fragment_manager.spec.ts +0 -404
- package/test/core/live_data.spec.ts +0 -558
- package/test/core/renderer.spec.ts +0 -113
- package/test/dom-assertions.test.ts +0 -182
- package/test/elements/MonacoSetup.ts +0 -65
- package/test/elements/authorization/basic-method.test.ts +0 -177
- package/test/elements/authorization/bearer-method.test.ts +0 -143
- package/test/elements/authorization/ntlm-method.test.ts +0 -219
- package/test/elements/authorization/oauth2-client-credentials-method.test.ts +0 -334
- package/test/elements/authorization/oauth2-code-method.test.ts +0 -320
- package/test/elements/authorization/oauth2-custom-grant-method.test.ts +0 -255
- package/test/elements/authorization/oauth2-device-code-method.test.ts +0 -371
- package/test/elements/authorization/oauth2-implicit-method.test.ts +0 -407
- package/test/elements/authorization/oauth2-jwt-method.test.ts +0 -217
- package/test/elements/authorization/oauth2-password-method.test.ts +0 -275
- package/test/elements/authorization/openid-method.test.ts +0 -591
- package/test/elements/autocomplete/autocomplete-input.spec.ts +0 -646
- package/test/elements/code-editor/code-editor.accessibility.test.ts +0 -298
- package/test/elements/code-editor/code-editor.test.ts +0 -574
- package/test/elements/currency/CurrencyPicker.accessibility.test.ts +0 -328
- package/test/elements/currency/CurrencyPicker.core.test.ts +0 -318
- package/test/elements/currency/CurrencyPicker.integration.test.ts +0 -482
- package/test/elements/currency/CurrencyPicker.test.ts +0 -486
- package/test/elements/data-table/DataTable.browser.test.ts +0 -649
- package/test/elements/har/HarUtils.test.ts +0 -45
- package/test/elements/har/HarViewerElement.test.ts +0 -687
- package/test/elements/har/test-data/har1.har +0 -3044
- package/test/elements/highlight/MarkedHighlightElement.test.ts +0 -452
- package/test/elements/highlight/PrismHighlightElement.test.ts +0 -79
- package/test/elements/highlight/PrismHighlighter.test.ts +0 -94
- package/test/elements/highlight/remoteSanitization.md +0 -1
- package/test/elements/highlight/test.md +0 -3
- package/test/elements/highlight/test1.md +0 -3
- package/test/elements/highlight/test2.md +0 -1
- package/test/elements/http/BodyFormdataEditorElement.test.ts +0 -482
- package/test/elements/http/BodyMultipartEditorElement.test.ts +0 -658
- package/test/elements/http/BodyRawEditorElement.test.ts +0 -90
- package/test/elements/http/CertificateAdd.test.ts +0 -457
- package/test/elements/http/HttpAssertions.test.ts +0 -994
- package/test/elements/http/HttpFlows.test.ts +0 -502
- package/test/elements/http/UrlEncodeUtils.test.ts +0 -202
- package/test/elements/layout/SplitItem.test.ts +0 -440
- package/test/elements/layout/SplitLayoutManager.test.ts +0 -1501
- package/test/elements/layout/SplitPanel.test.ts +0 -1109
- package/test/elements/mention-textarea/MentionTextArea.basic.test.ts +0 -114
- package/test/elements/mention-textarea/MentionTextArea.test.ts +0 -613
- package/test/elements/navigation/Navigation.test.ts +0 -120
- package/test/env.ts +0 -15
- package/test/events/EventTypes.test.ts +0 -363
- package/test/events/EventsTestHelpers.ts +0 -16
- package/test/helpers/TestUtils.ts +0 -243
- package/test/helpers/UiMock.ts +0 -185
- package/test/lib/Dom.test.ts +0 -231
- package/test/md/button/UiButton.test.ts +0 -347
- package/test/md/button/UiIconButton.test.ts +0 -155
- package/test/md/chip/UiChip.test.ts +0 -219
- package/test/md/collapse/UiCollapse.test.ts +0 -250
- package/test/md/collapse/flex-layout.test.ts +0 -105
- package/test/md/date-time/DateTime.test.ts +0 -348
- package/test/md/dialog/UiConfirmDialog.test.ts +0 -131
- package/test/md/dialog/UiDialog.test.ts +0 -759
- package/test/md/menu/Menu.test.ts +0 -855
- package/test/md/menu/MenuIntegration.test.ts +0 -426
- package/test/md/menu/MenuItem.test.ts +0 -652
- package/test/md/menu/SubMenu.test.ts +0 -410
- package/test/md/progress/UiCircularProgressElement.test.ts +0 -481
- package/test/md/progress/UiProgressElement.test.ts +0 -117
- package/test/md/progress/UiRangeElement.test.ts +0 -156
- package/test/md/select/Select.test.ts +0 -925
- package/test/plugins/takeScreenshotPlugin.js +0 -35
- package/test/setup.test.ts +0 -217
- package/test/setup.ts +0 -117
- package/test/tsconfig.json +0 -7
- package/web-dev-server.config.js +0 -21
- package/web-test-runner.config.js +0 -90
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
import { html, fixture, assert, oneEvent } from '@open-wc/testing'
|
|
2
|
-
import { spy } from 'sinon'
|
|
3
|
-
import {
|
|
4
|
-
EventTypes,
|
|
5
|
-
IOAuth2Authorization,
|
|
6
|
-
IRequestAuthorization,
|
|
7
|
-
RequestAuthorizationKind,
|
|
8
|
-
} from '@api-client/core/browser.js'
|
|
9
|
-
import OAuth2Authorization from '../../../src/elements/authorization/ui/OAuth2Authorization.js'
|
|
10
|
-
import Input from '../../../src/md/input/Input.js'
|
|
11
|
-
import CheckboxElement from '../../../src/md/checkbox/internals/CheckboxElement.js'
|
|
12
|
-
import '../../../src/define/authorization/oauth2-authorization.js'
|
|
13
|
-
|
|
14
|
-
describe('Authorization', () => {
|
|
15
|
-
describe('<oauth2-authorization>', () => {
|
|
16
|
-
describe('authorization_code', () => {
|
|
17
|
-
const baseConfig: IOAuth2Authorization = {
|
|
18
|
-
grantType: 'authorization_code',
|
|
19
|
-
redirectUri: 'https://redirect.com/',
|
|
20
|
-
pkce: true,
|
|
21
|
-
clientId: 'test-client-id',
|
|
22
|
-
clientSecret: 'test-secret-client',
|
|
23
|
-
authorizationUri: 'https://accounts.google.com/o/oauth2/v2/auth',
|
|
24
|
-
accessTokenUri: 'https://accounts.google.com/o/oauth2/v2/token',
|
|
25
|
-
scopes: ['email', 'profile'],
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async function basicFixture(opts: IOAuth2Authorization = {}): Promise<OAuth2Authorization> {
|
|
29
|
-
const auth: IRequestAuthorization = {
|
|
30
|
-
config: opts,
|
|
31
|
-
enabled: true,
|
|
32
|
-
kind: RequestAuthorizationKind,
|
|
33
|
-
type: 'oauth 2',
|
|
34
|
-
valid: true,
|
|
35
|
-
}
|
|
36
|
-
return fixture(html`<oauth2-authorization .authorization="${auth}"></oauth2-authorization>`)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async function baseUriFixture(baseUri: string, opts: IOAuth2Authorization): Promise<OAuth2Authorization> {
|
|
40
|
-
const auth: IRequestAuthorization = {
|
|
41
|
-
config: opts,
|
|
42
|
-
enabled: true,
|
|
43
|
-
kind: RequestAuthorizationKind,
|
|
44
|
-
type: 'oauth 2',
|
|
45
|
-
valid: true,
|
|
46
|
-
}
|
|
47
|
-
return fixture(
|
|
48
|
-
html`<oauth2-authorization .authorization="${auth}" .baseUri="${baseUri}"></oauth2-authorization>`
|
|
49
|
-
)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
describe('DOM rendering', () => {
|
|
53
|
-
let element: OAuth2Authorization
|
|
54
|
-
let form: HTMLFormElement
|
|
55
|
-
|
|
56
|
-
beforeEach(async () => {
|
|
57
|
-
element = await basicFixture({ ...baseConfig })
|
|
58
|
-
form = element.shadowRoot!.querySelector('form')!
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
it(`has the clientId input`, async () => {
|
|
62
|
-
const input = form.querySelector(`[name="clientId"]`) as Input
|
|
63
|
-
assert.ok(input, 'has the input')
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
it(`has the clientSecret input`, async () => {
|
|
67
|
-
const input = form.querySelector(`[name="clientSecret"]`) as Input
|
|
68
|
-
assert.ok(input, 'has the input')
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
it(`has the authorizationUri input`, async () => {
|
|
72
|
-
const input = form.querySelector(`[name="authorizationUri"]`) as Input
|
|
73
|
-
assert.ok(input, 'has the input')
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
it(`has the accessTokenUri input`, async () => {
|
|
77
|
-
const input = form.querySelector(`[name="accessTokenUri"]`) as Input
|
|
78
|
-
assert.ok(input, 'has the input')
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
it('client secret is required', async () => {
|
|
82
|
-
const input = form.querySelector('[name="clientSecret"]') as Input
|
|
83
|
-
assert.isTrue(input.required)
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
it('renders the redirect URI field', async () => {
|
|
87
|
-
const section = element.shadowRoot!.querySelector('[name="redirectUri"]')
|
|
88
|
-
assert.ok(section)
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
it('renders the PKCE checkbox', async () => {
|
|
92
|
-
const node = element.shadowRoot!.querySelector('[name="pkce"]')
|
|
93
|
-
assert.ok(node)
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
it('does not render the PKCE checkbox with noPkce', async () => {
|
|
97
|
-
element.noPkce = true
|
|
98
|
-
await element.updateComplete
|
|
99
|
-
const node = element.shadowRoot!.querySelector('[name="pkce"]')
|
|
100
|
-
assert.notOk(node)
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
it('checking the checkbox changes the pkce value of the element', async () => {
|
|
104
|
-
element.config.pkce = false
|
|
105
|
-
element.requestUpdate()
|
|
106
|
-
await element.updateComplete
|
|
107
|
-
const node = element.shadowRoot!.querySelector('[name="pkce"]') as CheckboxElement
|
|
108
|
-
assert.isFalse(node.checked, 'The checkbox is not selected')
|
|
109
|
-
node.click()
|
|
110
|
-
assert.isTrue(element.config.pkce)
|
|
111
|
-
})
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
describe('Data initialization', () => {
|
|
115
|
-
let element: OAuth2Authorization
|
|
116
|
-
beforeEach(async () => {
|
|
117
|
-
element = await basicFixture({ ...baseConfig })
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
it(`has the clientId input`, async () => {
|
|
121
|
-
const input = element.shadowRoot!.querySelector(`*[name="clientId"]`) as Input
|
|
122
|
-
assert.equal(input.value, baseConfig.clientId)
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
it(`has the clientSecret input`, async () => {
|
|
126
|
-
const input = element.shadowRoot!.querySelector(`*[name="clientSecret"]`) as Input
|
|
127
|
-
assert.equal(input.value, baseConfig.clientSecret)
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
it(`has the authorizationUri input`, async () => {
|
|
131
|
-
const input = element.shadowRoot!.querySelector(`*[name="authorizationUri"]`) as Input
|
|
132
|
-
assert.equal(input.value, baseConfig.authorizationUri)
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
it(`has the accessTokenUri input`, async () => {
|
|
136
|
-
const input = element.shadowRoot!.querySelector(`*[name="accessTokenUri"]`) as Input
|
|
137
|
-
assert.equal(input.value, baseConfig.accessTokenUri)
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
it('selects the PKCE checkbox', async () => {
|
|
141
|
-
const input = element.shadowRoot!.querySelector(`*[name="pkce"]`) as CheckboxElement
|
|
142
|
-
assert.isTrue(input.checked)
|
|
143
|
-
})
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
describe('Change notification', () => {
|
|
147
|
-
let element: OAuth2Authorization
|
|
148
|
-
beforeEach(async () => {
|
|
149
|
-
element = await basicFixture({ ...baseConfig })
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
it(`notifies when clientId changes`, async () => {
|
|
153
|
-
setTimeout(() => {
|
|
154
|
-
const input = element.shadowRoot!.querySelector(`[name="clientId"]`) as Input
|
|
155
|
-
input.value = 'changed'
|
|
156
|
-
input.dispatchEvent(new CustomEvent('change'))
|
|
157
|
-
})
|
|
158
|
-
const e = await oneEvent(element, 'change')
|
|
159
|
-
assert.ok(e)
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
it(`notifies when clientSecret changes`, async () => {
|
|
163
|
-
setTimeout(() => {
|
|
164
|
-
const input = element.shadowRoot!.querySelector(`[name="clientSecret"]`) as Input
|
|
165
|
-
input.value = 'changed'
|
|
166
|
-
input.dispatchEvent(new CustomEvent('change'))
|
|
167
|
-
})
|
|
168
|
-
const e = await oneEvent(element, 'change')
|
|
169
|
-
assert.ok(e)
|
|
170
|
-
})
|
|
171
|
-
|
|
172
|
-
it(`notifies when authorizationUri changes`, async () => {
|
|
173
|
-
setTimeout(() => {
|
|
174
|
-
const input = element.shadowRoot!.querySelector(`[name="authorizationUri"]`) as Input
|
|
175
|
-
input.value = 'changed'
|
|
176
|
-
input.dispatchEvent(new CustomEvent('change'))
|
|
177
|
-
})
|
|
178
|
-
const e = await oneEvent(element, 'change')
|
|
179
|
-
assert.ok(e)
|
|
180
|
-
})
|
|
181
|
-
|
|
182
|
-
it(`notifies when accessTokenUri changes`, async () => {
|
|
183
|
-
setTimeout(() => {
|
|
184
|
-
const input = element.shadowRoot!.querySelector(`[name="accessTokenUri"]`) as Input
|
|
185
|
-
input.value = 'changed'
|
|
186
|
-
input.dispatchEvent(new CustomEvent('change'))
|
|
187
|
-
})
|
|
188
|
-
const e = await oneEvent(element, 'change')
|
|
189
|
-
assert.ok(e)
|
|
190
|
-
})
|
|
191
|
-
})
|
|
192
|
-
|
|
193
|
-
describe('Data serialization', () => {
|
|
194
|
-
let element: OAuth2Authorization
|
|
195
|
-
beforeEach(async () => {
|
|
196
|
-
element = await basicFixture({ ...baseConfig })
|
|
197
|
-
})
|
|
198
|
-
|
|
199
|
-
it(`serializes the clientId`, async () => {
|
|
200
|
-
const result = element.serialize()
|
|
201
|
-
assert.equal(result.clientId, baseConfig.clientId)
|
|
202
|
-
})
|
|
203
|
-
|
|
204
|
-
it(`serializes the clientSecret`, async () => {
|
|
205
|
-
const result = element.serialize()
|
|
206
|
-
assert.equal(result.clientSecret, baseConfig.clientSecret)
|
|
207
|
-
})
|
|
208
|
-
|
|
209
|
-
it(`serializes the authorizationUri`, async () => {
|
|
210
|
-
const result = element.serialize()
|
|
211
|
-
assert.equal(result.authorizationUri, baseConfig.authorizationUri)
|
|
212
|
-
})
|
|
213
|
-
|
|
214
|
-
it(`serializes the accessTokenUri`, async () => {
|
|
215
|
-
const result = element.serialize()
|
|
216
|
-
assert.equal(result.accessTokenUri, baseConfig.accessTokenUri)
|
|
217
|
-
})
|
|
218
|
-
|
|
219
|
-
it(`serializes the scopes`, async () => {
|
|
220
|
-
const result = element.serialize()
|
|
221
|
-
assert.deepEqual(result.scopes, baseConfig.scopes)
|
|
222
|
-
})
|
|
223
|
-
|
|
224
|
-
it('serializes the pkce value', () => {
|
|
225
|
-
const result = element.serialize()
|
|
226
|
-
assert.isTrue(result.pkce)
|
|
227
|
-
})
|
|
228
|
-
})
|
|
229
|
-
|
|
230
|
-
describe('authorization event', () => {
|
|
231
|
-
let element: OAuth2Authorization
|
|
232
|
-
|
|
233
|
-
beforeEach(async () => {
|
|
234
|
-
element = await basicFixture({ ...baseConfig })
|
|
235
|
-
})
|
|
236
|
-
|
|
237
|
-
it(`sets the serialized values onto the event`, async () => {
|
|
238
|
-
const handler = spy()
|
|
239
|
-
element.addEventListener(EventTypes.Authorization.OAuth2.authorize, handler)
|
|
240
|
-
element.authorize()
|
|
241
|
-
const { detail } = handler.args[0][0] as CustomEvent<IOAuth2Authorization & { result?: unknown }>
|
|
242
|
-
delete detail.state
|
|
243
|
-
delete detail.result
|
|
244
|
-
assert.deepEqual(detail, element.serialize())
|
|
245
|
-
})
|
|
246
|
-
|
|
247
|
-
it(`sets a random state`, async () => {
|
|
248
|
-
const handler = spy()
|
|
249
|
-
element.addEventListener(EventTypes.Authorization.OAuth2.authorize, handler)
|
|
250
|
-
element.authorize()
|
|
251
|
-
const { detail } = handler.args[0][0] as CustomEvent<IOAuth2Authorization>
|
|
252
|
-
assert.typeOf(detail.state, 'string')
|
|
253
|
-
})
|
|
254
|
-
})
|
|
255
|
-
|
|
256
|
-
describe('#baseUri', () => {
|
|
257
|
-
const baseUri = 'https://api.domain.com/auth'
|
|
258
|
-
|
|
259
|
-
it('adds base URI to authorizationUri', async () => {
|
|
260
|
-
const params = { ...baseConfig }
|
|
261
|
-
params.authorizationUri = '/authorize'
|
|
262
|
-
const element = await baseUriFixture(baseUri, params)
|
|
263
|
-
const result = element.serialize()
|
|
264
|
-
assert.equal(result.authorizationUri, 'https://api.domain.com/auth/authorize')
|
|
265
|
-
})
|
|
266
|
-
|
|
267
|
-
it('adds base URI to accessTokenUri', async () => {
|
|
268
|
-
const params = { ...baseConfig }
|
|
269
|
-
params.accessTokenUri = '/authorize'
|
|
270
|
-
const element = await baseUriFixture(baseUri, params)
|
|
271
|
-
const result = element.serialize()
|
|
272
|
-
assert.equal(result.accessTokenUri, 'https://api.domain.com/auth/authorize')
|
|
273
|
-
})
|
|
274
|
-
|
|
275
|
-
it('adds base URI to redirectUri', async () => {
|
|
276
|
-
const params = { ...baseConfig }
|
|
277
|
-
params.redirectUri = '/redirect'
|
|
278
|
-
|
|
279
|
-
const element = await baseUriFixture(baseUri, params)
|
|
280
|
-
const result = element.serialize()
|
|
281
|
-
assert.equal(result.redirectUri, 'https://api.domain.com/auth/redirect')
|
|
282
|
-
})
|
|
283
|
-
|
|
284
|
-
it('ignores trailing slash', async () => {
|
|
285
|
-
const uri = `${baseUri}/`
|
|
286
|
-
const params = { ...baseConfig }
|
|
287
|
-
params.redirectUri = '/redirect'
|
|
288
|
-
|
|
289
|
-
const element = await baseUriFixture(uri, params)
|
|
290
|
-
const result = element.serialize()
|
|
291
|
-
assert.equal(result.redirectUri, 'https://api.domain.com/auth/redirect')
|
|
292
|
-
})
|
|
293
|
-
|
|
294
|
-
it('makes authorizationUri input text type', async () => {
|
|
295
|
-
const element = await baseUriFixture(baseUri, { ...baseConfig })
|
|
296
|
-
const node = element.shadowRoot!.querySelector('[name="authorizationUri"]') as Input
|
|
297
|
-
assert.equal(node.type, 'string')
|
|
298
|
-
})
|
|
299
|
-
|
|
300
|
-
it('makes accessTokenUri input text type', async () => {
|
|
301
|
-
const element = await baseUriFixture(baseUri, { ...baseConfig })
|
|
302
|
-
const node = element.shadowRoot!.querySelector('[name="accessTokenUri"]') as Input
|
|
303
|
-
assert.equal(node.type, 'string')
|
|
304
|
-
})
|
|
305
|
-
})
|
|
306
|
-
|
|
307
|
-
describe('a11y', () => {
|
|
308
|
-
let element: OAuth2Authorization
|
|
309
|
-
|
|
310
|
-
beforeEach(async () => {
|
|
311
|
-
element = await basicFixture({ ...baseConfig })
|
|
312
|
-
})
|
|
313
|
-
|
|
314
|
-
it('passes automated a11y tests', async () => {
|
|
315
|
-
await assert.isAccessible(element)
|
|
316
|
-
})
|
|
317
|
-
})
|
|
318
|
-
})
|
|
319
|
-
})
|
|
320
|
-
})
|
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
import { html, fixture, assert, oneEvent } from '@open-wc/testing'
|
|
2
|
-
import { spy } from 'sinon'
|
|
3
|
-
import {
|
|
4
|
-
EventTypes,
|
|
5
|
-
IOAuth2Authorization,
|
|
6
|
-
IRequestAuthorization,
|
|
7
|
-
RequestAuthorizationKind,
|
|
8
|
-
} from '@api-client/core/browser.js'
|
|
9
|
-
import OAuth2Authorization from '../../../src/elements/authorization/ui/OAuth2Authorization.js'
|
|
10
|
-
import Input from '../../../src/md/input/Input.js'
|
|
11
|
-
import '../../../src/define/authorization/oauth2-authorization.js'
|
|
12
|
-
|
|
13
|
-
describe('Authorization', () => {
|
|
14
|
-
describe('<oauth2-authorization>', () => {
|
|
15
|
-
describe('custom-credentials', () => {
|
|
16
|
-
const baseConfig: IOAuth2Authorization = {
|
|
17
|
-
grantType: 'custom-credentials',
|
|
18
|
-
clientId: 'test-client-id',
|
|
19
|
-
clientSecret: 'test-secret-client',
|
|
20
|
-
accessTokenUri: 'https://accounts.google.com/o/oauth2/v2/token',
|
|
21
|
-
scopes: ['email', 'profile'],
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async function basicFixture(opts: IOAuth2Authorization = {}): Promise<OAuth2Authorization> {
|
|
25
|
-
const auth: IRequestAuthorization = {
|
|
26
|
-
config: opts,
|
|
27
|
-
enabled: true,
|
|
28
|
-
kind: RequestAuthorizationKind,
|
|
29
|
-
type: 'oauth 2',
|
|
30
|
-
valid: true,
|
|
31
|
-
}
|
|
32
|
-
return fixture(html`<oauth2-authorization .authorization="${auth}"></oauth2-authorization>`)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async function baseUriFixture(baseUri: string, opts: IOAuth2Authorization): Promise<OAuth2Authorization> {
|
|
36
|
-
const auth: IRequestAuthorization = {
|
|
37
|
-
config: opts,
|
|
38
|
-
enabled: true,
|
|
39
|
-
kind: RequestAuthorizationKind,
|
|
40
|
-
type: 'oauth 2',
|
|
41
|
-
valid: true,
|
|
42
|
-
}
|
|
43
|
-
return fixture(
|
|
44
|
-
html`<oauth2-authorization .authorization="${auth}" .baseUri="${baseUri}"></oauth2-authorization>`
|
|
45
|
-
)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
describe('DOM rendering', () => {
|
|
49
|
-
let element: OAuth2Authorization
|
|
50
|
-
let form: HTMLFormElement
|
|
51
|
-
beforeEach(async () => {
|
|
52
|
-
element = await basicFixture({ ...baseConfig })
|
|
53
|
-
form = element.shadowRoot!.querySelector('form')!
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
it(`has the clientId input`, async () => {
|
|
57
|
-
const input = form.querySelector(`[name="clientId"]`) as Input
|
|
58
|
-
assert.ok(input, 'has the input')
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
it(`has the clientSecret input`, async () => {
|
|
62
|
-
const input = form.querySelector(`[name="clientSecret"]`) as Input
|
|
63
|
-
assert.ok(input, 'has the input')
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
it(`has the accessTokenUri input`, async () => {
|
|
67
|
-
const input = form.querySelector(`[name="accessTokenUri"]`) as Input
|
|
68
|
-
assert.ok(input, 'has the input')
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
it('client secret is not required', async () => {
|
|
72
|
-
const input = form.querySelector(`[name="clientSecret"]`) as Input
|
|
73
|
-
assert.notOk(input.required)
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
it('does not render the redirect URI field', async () => {
|
|
77
|
-
const section = element.shadowRoot!.querySelector('[name="redirectUri"]')
|
|
78
|
-
assert.notOk(section)
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
it('does not render the PKCE checkbox', async () => {
|
|
82
|
-
const node = element.shadowRoot!.querySelector('[name="pkce"]')
|
|
83
|
-
assert.notOk(node)
|
|
84
|
-
})
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
describe('Data initialization', () => {
|
|
88
|
-
let element: OAuth2Authorization
|
|
89
|
-
beforeEach(async () => {
|
|
90
|
-
element = await basicFixture({ ...baseConfig })
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
it(`has the clientId`, async () => {
|
|
94
|
-
const input = element.shadowRoot!.querySelector(`*[name="clientId"]`) as Input
|
|
95
|
-
assert.equal(input.value, baseConfig.clientId)
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
it(`has the clientSecret`, async () => {
|
|
99
|
-
const input = element.shadowRoot!.querySelector(`*[name="clientSecret"]`) as Input
|
|
100
|
-
assert.equal(input.value, baseConfig.clientSecret)
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
it(`has the accessTokenUri input`, async () => {
|
|
104
|
-
const input = element.shadowRoot!.querySelector(`*[name="accessTokenUri"]`) as Input
|
|
105
|
-
assert.equal(input.value, baseConfig.accessTokenUri)
|
|
106
|
-
})
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
describe('Change notification', () => {
|
|
110
|
-
let element: OAuth2Authorization
|
|
111
|
-
beforeEach(async () => {
|
|
112
|
-
element = await basicFixture({ ...baseConfig })
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
it(`notifies when clientId changes`, async () => {
|
|
116
|
-
setTimeout(() => {
|
|
117
|
-
const input = element.shadowRoot!.querySelector(`[name="clientId"]`) as Input
|
|
118
|
-
input.value = 'changed'
|
|
119
|
-
input.dispatchEvent(new CustomEvent('change'))
|
|
120
|
-
})
|
|
121
|
-
const e = await oneEvent(element, 'change')
|
|
122
|
-
assert.ok(e)
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
it(`notifies when clientSecret changes`, async () => {
|
|
126
|
-
setTimeout(() => {
|
|
127
|
-
const input = element.shadowRoot!.querySelector(`[name="clientSecret"]`) as Input
|
|
128
|
-
input.value = 'changed'
|
|
129
|
-
input.dispatchEvent(new CustomEvent('change'))
|
|
130
|
-
})
|
|
131
|
-
const e = await oneEvent(element, 'change')
|
|
132
|
-
assert.ok(e)
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
it(`notifies when accessTokenUri changes`, async () => {
|
|
136
|
-
setTimeout(() => {
|
|
137
|
-
const input = element.shadowRoot!.querySelector(`[name="accessTokenUri"]`) as Input
|
|
138
|
-
input.value = 'changed'
|
|
139
|
-
input.dispatchEvent(new CustomEvent('change'))
|
|
140
|
-
})
|
|
141
|
-
const e = await oneEvent(element, 'change')
|
|
142
|
-
assert.ok(e)
|
|
143
|
-
})
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
describe('Data serialization', () => {
|
|
147
|
-
let element: OAuth2Authorization
|
|
148
|
-
beforeEach(async () => {
|
|
149
|
-
element = await basicFixture({ ...baseConfig })
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
it(`serializes the clientId`, async () => {
|
|
153
|
-
const result = element.serialize()
|
|
154
|
-
assert.equal(result.clientId, baseConfig.clientId)
|
|
155
|
-
})
|
|
156
|
-
|
|
157
|
-
it(`serializes the clientSecret`, async () => {
|
|
158
|
-
const result = element.serialize()
|
|
159
|
-
assert.equal(result.clientSecret, baseConfig.clientSecret)
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
it(`serializes the accessTokenUri`, async () => {
|
|
163
|
-
const result = element.serialize()
|
|
164
|
-
assert.equal(result.accessTokenUri, baseConfig.accessTokenUri)
|
|
165
|
-
})
|
|
166
|
-
|
|
167
|
-
it(`serializes the scopes`, async () => {
|
|
168
|
-
const result = element.serialize()
|
|
169
|
-
assert.deepEqual(result.scopes, baseConfig.scopes)
|
|
170
|
-
})
|
|
171
|
-
})
|
|
172
|
-
|
|
173
|
-
describe('authorization event', () => {
|
|
174
|
-
let element: OAuth2Authorization
|
|
175
|
-
|
|
176
|
-
beforeEach(async () => {
|
|
177
|
-
element = await basicFixture({ ...baseConfig })
|
|
178
|
-
})
|
|
179
|
-
|
|
180
|
-
it(`sets the serialized values onto the event`, async () => {
|
|
181
|
-
const handler = spy()
|
|
182
|
-
element.addEventListener(EventTypes.Authorization.OAuth2.authorize, handler)
|
|
183
|
-
element.authorize()
|
|
184
|
-
const { detail } = handler.args[0][0] as CustomEvent<IOAuth2Authorization & { result?: unknown }>
|
|
185
|
-
delete detail.state
|
|
186
|
-
delete detail.result
|
|
187
|
-
assert.deepEqual(detail, element.serialize())
|
|
188
|
-
})
|
|
189
|
-
})
|
|
190
|
-
|
|
191
|
-
describe('#baseUri', () => {
|
|
192
|
-
const baseUri = 'https://api.domain.com/auth'
|
|
193
|
-
|
|
194
|
-
it('adds base URI to authorizationUri', async () => {
|
|
195
|
-
const params = { ...baseConfig }
|
|
196
|
-
params.authorizationUri = '/authorize'
|
|
197
|
-
const element = await baseUriFixture(baseUri, params)
|
|
198
|
-
const result = element.serialize()
|
|
199
|
-
assert.equal(result.authorizationUri, 'https://api.domain.com/auth/authorize')
|
|
200
|
-
})
|
|
201
|
-
|
|
202
|
-
it('adds base URI to accessTokenUri', async () => {
|
|
203
|
-
const params = { ...baseConfig }
|
|
204
|
-
params.accessTokenUri = '/authorize'
|
|
205
|
-
const element = await baseUriFixture(baseUri, params)
|
|
206
|
-
const result = element.serialize()
|
|
207
|
-
assert.equal(result.accessTokenUri, 'https://api.domain.com/auth/authorize')
|
|
208
|
-
})
|
|
209
|
-
|
|
210
|
-
it('adds base URI to redirectUri', async () => {
|
|
211
|
-
const params = { ...baseConfig }
|
|
212
|
-
params.redirectUri = '/redirect'
|
|
213
|
-
|
|
214
|
-
const element = await baseUriFixture(baseUri, params)
|
|
215
|
-
const result = element.serialize()
|
|
216
|
-
assert.equal(result.redirectUri, 'https://api.domain.com/auth/redirect')
|
|
217
|
-
})
|
|
218
|
-
|
|
219
|
-
it('ignores trailing slash', async () => {
|
|
220
|
-
const uri = `${baseUri}/`
|
|
221
|
-
const params = { ...baseConfig }
|
|
222
|
-
params.redirectUri = '/redirect'
|
|
223
|
-
|
|
224
|
-
const element = await baseUriFixture(uri, params)
|
|
225
|
-
const result = element.serialize()
|
|
226
|
-
assert.equal(result.redirectUri, 'https://api.domain.com/auth/redirect')
|
|
227
|
-
})
|
|
228
|
-
|
|
229
|
-
it('makes authorizationUri input text type', async () => {
|
|
230
|
-
const element = await baseUriFixture(baseUri, { ...baseConfig })
|
|
231
|
-
const node = element.shadowRoot!.querySelector('[name="authorizationUri"]') as Input
|
|
232
|
-
assert.equal(node.type, 'string')
|
|
233
|
-
})
|
|
234
|
-
|
|
235
|
-
it('makes accessTokenUri input text type', async () => {
|
|
236
|
-
const element = await baseUriFixture(baseUri, { ...baseConfig })
|
|
237
|
-
const node = element.shadowRoot!.querySelector('[name="accessTokenUri"]') as Input
|
|
238
|
-
assert.equal(node.type, 'string')
|
|
239
|
-
})
|
|
240
|
-
})
|
|
241
|
-
|
|
242
|
-
describe('a11y', () => {
|
|
243
|
-
let element: OAuth2Authorization
|
|
244
|
-
|
|
245
|
-
beforeEach(async () => {
|
|
246
|
-
element = await basicFixture({ ...baseConfig })
|
|
247
|
-
})
|
|
248
|
-
|
|
249
|
-
it('passes automated a11y tests', async () => {
|
|
250
|
-
await assert.isAccessible(element)
|
|
251
|
-
})
|
|
252
|
-
})
|
|
253
|
-
})
|
|
254
|
-
})
|
|
255
|
-
})
|