-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50293 from nextcloud/fix/harden-admin-settings
fix(theming): Harden admin theming settings
- Loading branch information
Showing
6 changed files
with
204 additions
and
17 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
/*! | ||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
import { User } from '@nextcloud/cypress' | ||
|
||
const admin = new User('admin', 'admin') | ||
|
||
describe('Admin theming: Setting custom project URLs', function() { | ||
this.beforeEach(() => { | ||
// Just in case previous test failed | ||
cy.resetAdminTheming() | ||
cy.login(admin) | ||
cy.visit('/settings/admin/theming') | ||
cy.intercept('POST', '**/apps/theming/ajax/updateStylesheet').as('updateTheming') | ||
}) | ||
|
||
it('Setting the web link', () => { | ||
cy.findByRole('textbox', { name: /web link/i }) | ||
.and('have.attr', 'type', 'url') | ||
.as('input') | ||
.scrollIntoView() | ||
cy.get('@input') | ||
.should('be.visible') | ||
.type('{selectAll}http://example.com/path?query#fragment{enter}') | ||
|
||
cy.wait('@updateTheming') | ||
|
||
cy.logout() | ||
|
||
cy.visit('/') | ||
cy.contains('a', 'Nextcloud') | ||
.should('be.visible') | ||
.and('have.attr', 'href', 'http://example.com/path?query#fragment') | ||
}) | ||
|
||
it('Setting the legal notice link', () => { | ||
cy.findByRole('textbox', { name: /legal notice link/i }) | ||
.should('exist') | ||
.and('have.attr', 'type', 'url') | ||
.as('input') | ||
.scrollIntoView() | ||
cy.get('@input') | ||
.type('http://example.com/path?query#fragment{enter}') | ||
|
||
cy.wait('@updateTheming') | ||
|
||
cy.logout() | ||
|
||
cy.visit('/') | ||
cy.contains('a', /legal notice/i) | ||
.should('be.visible') | ||
.and('have.attr', 'href', 'http://example.com/path?query#fragment') | ||
}) | ||
|
||
it('Setting the privacy policy link', () => { | ||
cy.findByRole('textbox', { name: /privacy policy link/i }) | ||
.should('exist') | ||
.as('input') | ||
.scrollIntoView() | ||
cy.get('@input') | ||
.should('have.attr', 'type', 'url') | ||
.type('http://privacy.local/path?query#fragment{enter}') | ||
|
||
cy.wait('@updateTheming') | ||
|
||
cy.logout() | ||
|
||
cy.visit('/') | ||
cy.contains('a', /privacy policy/i) | ||
.should('be.visible') | ||
.and('have.attr', 'href', 'http://privacy.local/path?query#fragment') | ||
}) | ||
|
||
}) | ||
|
||
describe('Admin theming: Web link corner cases', function() { | ||
this.beforeEach(() => { | ||
// Just in case previous test failed | ||
cy.resetAdminTheming() | ||
cy.login(admin) | ||
cy.visit('/settings/admin/theming') | ||
cy.intercept('POST', '**/apps/theming/ajax/updateStylesheet').as('updateTheming') | ||
}) | ||
|
||
it('Already URL encoded', () => { | ||
cy.findByRole('textbox', { name: /web link/i }) | ||
.and('have.attr', 'type', 'url') | ||
.as('input') | ||
.scrollIntoView() | ||
cy.get('@input') | ||
.should('be.visible') | ||
.type('{selectAll}http://example.com/%22path%20with%20space%22{enter}') | ||
|
||
cy.wait('@updateTheming') | ||
|
||
cy.logout() | ||
|
||
cy.visit('/') | ||
cy.contains('a', 'Nextcloud') | ||
.should('be.visible') | ||
.and('have.attr', 'href', 'http://example.com/%22path%20with%20space%22') | ||
}) | ||
|
||
it('URL with double quotes', () => { | ||
cy.findByRole('textbox', { name: /web link/i }) | ||
.and('have.attr', 'type', 'url') | ||
.as('input') | ||
.scrollIntoView() | ||
cy.get('@input') | ||
.should('be.visible') | ||
.type('{selectAll}http://example.com/"path"{enter}') | ||
|
||
cy.wait('@updateTheming') | ||
|
||
cy.logout() | ||
|
||
cy.visit('/') | ||
cy.contains('a', 'Nextcloud') | ||
.should('be.visible') | ||
.and('have.attr', 'href', 'http://example.com/%22path%22') | ||
}) | ||
|
||
it('URL with double quotes and already encoded', () => { | ||
cy.findByRole('textbox', { name: /web link/i }) | ||
.and('have.attr', 'type', 'url') | ||
.as('input') | ||
.scrollIntoView() | ||
cy.get('@input') | ||
.should('be.visible') | ||
.type('{selectAll}http://example.com/"the%20path"{enter}') | ||
|
||
cy.wait('@updateTheming') | ||
|
||
cy.logout() | ||
|
||
cy.visit('/') | ||
cy.contains('a', 'Nextcloud') | ||
.should('be.visible') | ||
.and('have.attr', 'href', 'http://example.com/%22the%20path%22') | ||
}) | ||
|
||
}) |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.