-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53fde0c
commit ba6247c
Showing
8 changed files
with
126 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Enhancement: Make login url configurable | ||
|
||
We've added a new configuration option loginUrl to web, this is helpful if you use an external IdP and the login | ||
is out of web/OCIS context. | ||
|
||
https://github.com/owncloud/ocis/pull/7317 | ||
https://github.com/owncloud/web/issues/9707 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/web-runtime/tests/unit/pages/__snapshots__/accessDenied.spec.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`access denied page renders component 1`] = ` | ||
<div class="oc-height-viewport oc-flex oc-flex-column oc-flex-center oc-flex-middle"> | ||
<div class="oc-login-card"> | ||
<img alt="" aria-hidden="true" class="oc-login-logo"> | ||
<div class="oc-login-card-body oc-width-medium"> | ||
<h2 class="oc-login-card-title">Not logged in</h2> | ||
<p>This could be because of a routine safety log out, or because your account is either inactive or not yet authorized for use. Please try logging in after a while or seek help from your Administrator.</p> | ||
<!--v-if--> | ||
</div> | ||
<div class="oc-login-card-footer oc-pt-rm"> | ||
<p></p> | ||
</div> | ||
</div> | ||
<a attrs="[object Object]" class="oc-button oc-rounded oc-button-l oc-button-justify-content-center oc-button-gap-m oc-button-primary oc-button-primary-filled oc-mt-m oc-width-medium" id="exitAnchor" name="login">Log in again</a> | ||
</div> | ||
`; |
66 changes: 66 additions & 0 deletions
66
packages/web-runtime/tests/unit/pages/accessDenied.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import accessDenied from '../../../src/pages/accessDenied.vue' | ||
import { | ||
createStore, | ||
defaultComponentMocks, | ||
defaultPlugins, | ||
mount, | ||
defaultStoreMockOptions | ||
} from 'web-test-helpers' | ||
import { mock } from 'jest-mock-extended' | ||
|
||
const selectors = { | ||
logInAgainButton: '#exitAnchor' | ||
} | ||
|
||
import { ConfigurationManager, useConfigurationManager } from 'web-pkg/src' | ||
|
||
jest.mock('web-pkg/src/composables/configuration/useConfigurationManager') | ||
|
||
describe('access denied page', () => { | ||
it('renders component', () => { | ||
const { wrapper } = getWrapper() | ||
expect(wrapper.html()).toMatchSnapshot() | ||
}) | ||
describe('"Log in again" button', () => { | ||
it('navigates to "loginUrl" if set in config', () => { | ||
const loginUrl = 'https://myidp.int/login' | ||
const { wrapper } = getWrapper({ loginUrl }) | ||
|
||
const logInAgainButton = wrapper.find(selectors.logInAgainButton) | ||
const loginAgainUrl = new URL(logInAgainButton.attributes().href) | ||
loginAgainUrl.search = '' | ||
|
||
expect(logInAgainButton.exists()).toBeTruthy() | ||
expect(loginAgainUrl.toString()).toEqual(loginUrl) | ||
}) | ||
}) | ||
}) | ||
|
||
function getWrapper({ loginUrl = '' } = {}) { | ||
const mocks = { | ||
...defaultComponentMocks() | ||
} | ||
const storeOptions = { ...defaultStoreMockOptions } | ||
|
||
jest.mocked(useConfigurationManager).mockImplementation(() => | ||
mock<ConfigurationManager>({ | ||
options: { | ||
loginUrl | ||
} | ||
} as any) | ||
) | ||
|
||
const store = createStore(storeOptions) | ||
|
||
return { | ||
storeOptions, | ||
mocks, | ||
wrapper: mount(accessDenied, { | ||
global: { | ||
plugins: [...defaultPlugins(), store], | ||
mocks, | ||
provide: mocks | ||
} | ||
}) | ||
} | ||
} |