Skip to content

Commit

Permalink
Merge pull request #168 from pondersource/use-include-bash
Browse files Browse the repository at this point in the history
Use include in bash scripts
  • Loading branch information
MahdiBaghbani authored Jan 22, 2025
2 parents be6e591 + 611b615 commit f560eed
Show file tree
Hide file tree
Showing 54 changed files with 2,686 additions and 5,768 deletions.
22 changes: 22 additions & 0 deletions cypress/ocm-test-suite/cypress/e2e/login/nextcloud-v28.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* @fileoverview
* Cypress test suite for testing the login functionality of Nextcloud.
* This suite contains tests to validate successful login functionality using valid credentials.
*
* @author Mohammad Mahdi Baghbani Pourvahid <[email protected]>
*/

describe('Nextcloud Login Tests', () => {
/**
* Test Case: Validates successful login to Nextcloud.
* This test logs into Nextcloud using valid credentials and checks for a successful login state.
*/
it('should successfully log into Nextcloud with valid credentials', () => {
// Define the Nextcloud instance URL and credentials from environment variables or use default values
const nextcloudUrl = Cypress.env('NEXTCLOUD1_URL') || 'https://nextcloud1.docker';
const username = Cypress.env('NEXTCLOUD1_USERNAME') || 'einstein';
const password = Cypress.env('NEXTCLOUD1_PASSWORD') || 'relativity';

cy.loginNextcloud(nextcloudUrl, username, password);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ describe('Seafile Login Tests', () => {
*/
it('should successfully log into Seafile with valid credentials', () => {
// Define the Seafile instance URL and credentials from environment variables or use default values
const seafileUrl = Cypress.env('SEAFILE1_URL') || 'https://seafile1.docker';
const seafileUrl = Cypress.env('SEAFILE1_URL') || 'http://seafile1.docker';
const username = Cypress.env('SEAFILE1_USERNAME') || '[email protected]';
const password = Cypress.env('SEAFILE1_PASSWORD') || 'xu';

cy.loginOcis(seafileUrl, username, password);
cy.loginSeafile(seafileUrl, username, password);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import {
createShareLinkV27,
ensureFileExistsV27,
renameFileV27,
} from '../utils/nextcloud-v27';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@ describe('Share link federated sharing functionality for ownCloud', () => {
cy.loginOwncloud('https://owncloud1.docker', 'marie', 'radioactivity')

renameFile('welcome.txt', 'oc1-to-nc1-share-link.txt')
createShareLink('oc1-to-nc1-share-link.txt').then(
(result) => {
cy.visit(result)

// save share url to file.
cy.writeFile('share-link-url.txt', result)
}
)
createShareLink('oc1-to-nc1-share-link.txt')
})

it('Receive federated share <file> from ownCloud v10 to Nextcloud v27', () => {
Expand All @@ -30,7 +23,7 @@ describe('Share link federated sharing functionality for ownCloud', () => {
cy.readFile('share-link-url.txt').then((result) => {

// extract token from url.
const token = result.replace('https://owncloud1.docker/index.php/s/','');
const token = result.replace('https://owncloud1.docker/s/','');

// put token into the link.
const url = `https://nextcloud1.docker/index.php/login?redirect_url=%252Findex.php%252Fapps%252Ffiles#remote=https%3A%2F%2Fowncloud1.docker&token=${token}&owner=marie&ownerDisplayName=marie&name=oc1-to-oc2-share-link.txt&protected=0`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,7 @@ describe('Share link federated sharing functionality for ownCloud', () => {
cy.loginOwncloud('https://owncloud1.docker', 'marie', 'radioactivity')

renameFile('welcome.txt', 'oc1-to-nc1-share-link.txt')
createShareLink('oc1-to-nc1-share-link.txt').then(
(result) => {
cy.visit(result)

// save share url to file.
cy.writeFile('share-link-url.txt', result)
}
)
createShareLink('oc1-to-nc1-share-link.txt')
})

it('Receive federated share <file> from ownCloud v10 to Nextcloud v28', () => {
Expand All @@ -22,7 +15,7 @@ describe('Share link federated sharing functionality for ownCloud', () => {
cy.readFile('share-link-url.txt').then((result) => {

// extract token from url.
const token = result.replace('https://owncloud1.docker/index.php/s/','');
const token = result.replace('https://owncloud1.docker/s/','');

// put token into the link.
const url = `https://nextcloud1.docker/index.php/login?redirect_url=%252Findex.php%252Fapps%252Ffiles#remote=https%3A%2F%2Fowncloud1.docker&token=${token}&owner=marie&ownerDisplayName=marie&name=oc1-to-oc2-share-link.txt&protected=0`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,7 @@ describe('Share link federated sharing functionality for ownCloud', () => {
cy.loginOwncloud('https://owncloud1.docker', 'marie', 'radioactivity')

renameFile('welcome.txt', 'oc1-to-oc2-share-link.txt')
createShareLink('oc1-to-oc2-share-link.txt').then(
(result) => {
cy.visit(result)

// save share url to file.
cy.writeFile('share-link-url.txt', result)
}
)
createShareLink('oc1-to-oc2-share-link.txt')
})

it('Receive federated share <file> from ownCloud v10 to ownCloud v10', () => {
Expand All @@ -26,10 +19,10 @@ describe('Share link federated sharing functionality for ownCloud', () => {
cy.readFile('share-link-url.txt').then((result) => {

// extract token from url.
const token = result.replace('https://owncloud1.docker/index.php/s/','');
const token = result.replace('https://owncloud1.docker/s/','');

// put token into the link.
const url = `https://owncloud2.docker/index.php/login?redirect_url=%252Findex.php%252Fapps%252Ffiles#remote=https%3A%2F%2Fowncloud1.docker&token=${token}&owner=marie&ownerDisplayName=marie&name=oc1-to-oc2-share-link.txt&protected=0`
const url = `https://owncloud2.docker/index.php/apps/files#remote=https%3A%2F%2Fowncloud1.docker&token=${token}&owner=marie&ownerDisplayName=marie&name=oc1-to-oc2-share-link.txt&protected=0`

// accept share from ownCloud 2.
cy.loginOwncloudCore(url, 'mahdi', 'baghbani')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ describe('Native federated sharing functionality for OcmStub', () => {
const senderUsername = Cypress.env('OCMSTUB1_USERNAME') || 'einstein';
const recipientUsername = Cypress.env('OCMSTUB2_USERNAME') || 'mahdi';
const expectedMessage = 'yes shareWith';
const sharedFileName = 'from-stub.txt';

// Expected details of the federated share
const expectedShareDetails = {
shareWith: `${recipientUsername}@${recipientUrl.replace(/^https?:\/\/|\/$/g, '')}`,
fileName: 'Test share from stub',
fileName: `${sharedFileName}`,
owner: `${senderUsername}@${senderUrl.replace(/^https?:\/\/|\/$/g, '')}`,
sender: `${senderUsername}@${senderUrl.replace(/^https?:\/\/|\/$/g, '')}`,
shareType: 'user',
Expand Down
8 changes: 5 additions & 3 deletions cypress/ocm-test-suite/cypress/e2e/utils/owncloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,13 @@ export function createShareLink(fileName) {
});

// Extract and return the public share link
return cy.get('#app-sidebar').within(() => {
return cy.get('.shareLink input')
cy.get('#app-sidebar').within(() => {
cy.get('.link-entry .linkText')
.invoke('val')
.then((link) => {
return link;
cy.visit(link)
// save share url to file.
cy.writeFile('share-link-url.txt', link)
});
});
}
Expand Down
11 changes: 3 additions & 8 deletions cypress/ocm-test-suite/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,10 @@ Cypress.Commands.add('loginNextcloud', (url, username, password) => {
Cypress.Commands.add('loginSeafile', (url, username, password) => {
cy.visit(url);

// Ensure the login page is visible
cy.get('#wrapper #log-in-panel #login-form', { timeout: 10000 }).should('be.visible');

// Fill in login credentials and submit
cy.get('#wrapper #log-in-panel #login-form').within(() => {
cy.get('input[name="login"]').type(username);
cy.get('input[name="password"]').type(password);
cy.get('button[type="submit"]').click();
});
cy.get('input[name="login"]').type(username);
cy.get('input[name="password"]').type(password);
cy.get('button[type="submit"]').click();
});

/**
Expand Down
10 changes: 5 additions & 5 deletions dev/ocm-test-suite/invite-link/nextcloud-nextcloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ MARIADB_ROOT_PASSWORD="eilohtho9oTahsuongeeTh7reedahPo1Ohwi3aek"
# Paths to required directories
TEMP_DIR="temp"
TLS_CA_DIR="docker/tls/certificate-authority"
TLS_CERTIFICATES_DIR="docker/tls/certificates"
TLS_CERT_DIR="docker/tls/certificates"

# 3rd party containerS
CYPRESS_REPO=cypress/included
Expand Down Expand Up @@ -248,7 +248,7 @@ create_nextcloud() {
-e DBHOST="marianextcloud${number}.docker" \
-e USER="${user}" \
-e PASS="${password}" \
-v "${ENV_ROOT}/${TLS_CERTIFICATES_DIR}:/certificates" \
-v "${ENV_ROOT}/${TLS_CERT_DIR}:/certificates" \
-v "${ENV_ROOT}/${TLS_CA_DIR}:/certificate-authority" \
-v "${ENV_ROOT}/${TEMP_DIR}/${init_script}":"/init.sh" \
-v "${ENV_ROOT}/docker/scripts/entrypoint.sh":"/entrypoint.sh" \
Expand Down Expand Up @@ -284,7 +284,7 @@ create_reva() {
run_docker_container --detach --network="${DOCKER_NETWORK}" \
--name="reva${platform}${number}.docker" \
-e HOST="reva${platform}${number}" \
-v "${ENV_ROOT}/${TLS_CERTIFICATES_DIR}:/certificates" \
-v "${ENV_ROOT}/${TLS_CERT_DIR}:/certificates" \
-v "${ENV_ROOT}/${TLS_CA_DIR}:/certificate-authority" \
-v "${ENV_ROOT}/${TEMP_DIR}/reva/configs:/configs/revad" \
-v "${ENV_ROOT}/${TEMP_DIR}/reva/run.sh":"/usr/bin/run.sh" \
Expand Down Expand Up @@ -338,8 +338,8 @@ parse_arguments() {
# -----------------------------------------------------------------------------------
validate_files() {
# Check if TLS certificate files exist
if [ ! -d "${ENV_ROOT}/${TLS_CERTIFICATES_DIR}" ]; then
error_exit "TLS certificates directory not found: ${ENV_ROOT}/${TLS_CERTIFICATES_DIR}"
if [ ! -d "${ENV_ROOT}/${TLS_CERT_DIR}" ]; then
error_exit "TLS certificates directory not found: ${ENV_ROOT}/${TLS_CERT_DIR}"
fi
if [ ! -d "${ENV_ROOT}/${TLS_CA_DIR}" ]; then
error_exit "TLS certificate authority directory not found: ${ENV_ROOT}/${TLS_CA_DIR}"
Expand Down
Loading

0 comments on commit f560eed

Please sign in to comment.