Skip to content

Commit

Permalink
Merge pull request #133 from pondersource/fix-ocis-reva-test
Browse files Browse the repository at this point in the history
[OCM][Test Suite] Fix oCIS to OC/NC invite flow and sharing
  • Loading branch information
MahdiBaghbani authored Aug 13, 2024
2 parents 96cb52e + 275e469 commit 5e5d51e
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 84 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import {
verifyFederatedContactV27,
createInviteTokenV27,
createScienceMeshShareV27,
renameFileV27
} from '../utils/nextcloud-v27'

import {
openScienceMeshAppV5,
createLegacyInviteLinkV5,
acceptInviteLinkV5,
verifyFederatedContactV5,
acceptShareV5,
verifyShareV5
} from '../utils/ocis-5'

describe('Invite link federated sharing via ScienceMesh functionality for oCIS', () => {
it('Send invitation from Nextcloud v27 to oCIS v5', () => {

cy.loginOcis('https://ocis1.docker', 'einstein', 'relativity')

openScienceMeshAppV5()
cy.loginNextcloud('https://nextcloud1.docker', 'marie', 'radioactivity')
cy.visit('https://nextcloud1.docker/index.php/apps/sciencemesh/contacts')

createLegacyInviteLinkV5('nextcloud1.docker', 'ocis1.docker').then(
createInviteTokenV27('revanextcloud1.docker').then(
(result) => {
// save invite link to file.
cy.writeFile('invite-link-nc-ocis.txt', result)
Expand All @@ -28,17 +27,14 @@ describe('Invite link federated sharing via ScienceMesh functionality for oCIS',

it('Accept invitation from Nextcloud v27 to oCIS v5', () => {

// load invite link from file.
cy.readFile('invite-link-nc-ocis.txt').then((url) => {
// load invite token from file.
cy.readFile('invite-link-nc-ocis.txt').then((token) => {

// accept invitation from Nextcloud 1.
cy.loginNextcloudCore(url, 'marie', 'radioactivity')
cy.loginOcis('https://ocis1.docker', 'einstein', 'relativity')

cy.get('input[id="accept-button"]', { timeout: 10000 })
.click()
acceptInviteLinkV5(token)

// validate 'Albert Einstein' is shown as a contact.
verifyFederatedContactV27('nextcloud1.docker', 'Albert Einstein', 'ocis1.docker')
verifyFederatedContactV5('marie', 'revanextcloud1.docker')
})
})

Expand All @@ -47,7 +43,7 @@ describe('Invite link federated sharing via ScienceMesh functionality for oCIS',
cy.loginNextcloud('https://nextcloud1.docker', 'marie', 'radioactivity')

renameFileV27('welcome.txt', 'invite-link-nc-ocis.txt')
createScienceMeshShareV27('nextcloud1.docker', 'Albert Einstein', 'ocis1.docker', 'invite-link-nc-ocis.txt')
createScienceMeshShareV27('nextcloud1.docker', 'Albert Einstein', 'https://ocis1.docker', 'invite-link-nc-ocis.txt')
})

it('Receive ScienceMesh share <file> from Nextcloud v27 to oCIS v5', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,71 +1,39 @@
import { createInviteToken, createScienceMeshShare, renameFile } from '../utils/owncloud'
import {
openScienceMeshAppV5,
createLegacyInviteLinkV5,
createInviteToken,
createScienceMeshShare,
renameFile
} from '../utils/owncloud'
import {
acceptInviteLinkV5,
verifyFederatedContactV5,
acceptShareV5,
verifyShareV5
} from '../utils/ocis-5'

describe('Invite link federated sharing via ScienceMesh functionality for ownCloud', () => {
// Temporary diablle this scenario beacuase of: https://github.com/pondersource/dev-stock/issues/129#issuecomment-2254133337
// until that issue resolves, try to initiate invites from oCIS.
// it('Send invitation from ownCloud v10 to oCIS v5', () => {

// cy.loginOwncloud('https://owncloud1.docker', 'marie', 'radioactivity')
// cy.visit('https://owncloud1.docker/index.php/apps/sciencemesh/')

// createInviteToken('revaowncloud1.docker').then(
// (result) => {
// // save invite link to file.
// cy.writeFile('invite-link-oc-ocis.txt', result)
// }
// )
// })

// it('Accept invitation from ownCloud v10 to oCIS v5', () => {

// // load invite token from file.
// cy.readFile('invite-link-oc-ocis.txt').then((token) => {

// cy.loginOcis('https://ocis1.docker', 'einstein', 'relativity')

// acceptInviteLinkV5(token)
it('Send invitation from ownCloud v10 to oCIS v5', () => {

// verifyFederatedContactV5('marie', 'revaowncloud1.docker')
// })
// })

it('Send invitation from oCIS v5 to ownCloud v10', () => {

cy.loginOcis('https://ocis1.docker', 'einstein', 'relativity')

openScienceMeshAppV5()
cy.loginOwncloud('https://owncloud1.docker', 'marie', 'radioactivity')
cy.visit('https://owncloud1.docker/index.php/apps/sciencemesh/')

createLegacyInviteLinkV5('owncloud1.docker', 'ocis1.docker').then(
createInviteToken('revaowncloud1.docker').then(
(result) => {
// save invite link to file.
cy.writeFile('invite-link-ocis-oc.txt', result)
cy.writeFile('invite-link-oc-ocis.txt', result)
}
)
})

it('Accept invitation from oCIS v5 to ownCloud v10', () => {

// load invite link from file.
cy.readFile('invite-link-ocis-oc.txt').then((url) => {
it('Accept invitation from ownCloud v10 to oCIS v5', () => {

// accept invitation from ownCloud 1.
cy.loginOwncloudCore(url, 'marie', 'radioactivity')
// load invite token from file.
cy.readFile('invite-link-oc-ocis.txt').then((token) => {

cy.get('input[id="accept-button"]', { timeout: 10000 })
.click()
cy.loginOcis('https://ocis1.docker', 'einstein', 'relativity')

// validate 'Albert Einstein' is shown as a contact.
cy.visit('https://owncloud1.docker/index.php/apps/sciencemesh/contacts')
acceptInviteLinkV5(token)

cy.get('table[id="contact-table"]')
.find('p[class="displayname"]')
.should("have.text", "Albert Einstein");
verifyFederatedContactV5('marie', 'revaowncloud1.docker')
})
})

Expand Down
29 changes: 27 additions & 2 deletions cypress/ocm-test-suite/cypress/e2e/utils/nextcloud-v27.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,25 @@ export function createShareLinkV27(fileName) {
})
}

export function createInviteTokenV27(senderDomain) {

cy.get('button[id="token-generator"]').should('be.visible').click()

return cy.get('input[class="generated-token-link"]')
.invoke('val')
.then(
sometext => {
// extract token from url.
const token = sometext.replace('https://meshdir.docker/meshdir?token=', '');

return token.replace(`&providerDomain=${senderDomain}`, '')
}
);
}

export function createInviteLinkV27(targetDomain) {

cy.get('button[id="token-generator"]').click()
cy.get('button[id="token-generator"]').should('be.visible').click()

return cy.get('input[class="generated-token-link"]')
.invoke('val')
Expand Down Expand Up @@ -95,7 +111,16 @@ export function getScienceMeshContactIdFromDisplayNameV27(domain, displayName, c
.invoke('text')
.then(
usernameWithDomain => {
return usernameWithDomain
// get the index of the last @
var lastIndex = usernameWithDomain.lastIndexOf('@');
var username = usernameWithDomain.substr(0, lastIndex)
var domain = usernameWithDomain.substr(lastIndex + 1)

// remove https:// or http:// from domain (reva likes to show username@https://domain sometimes)
// I'm too afraid to explain the regex here let's just say its from here: https://stackoverflow.com/a/8206299/8549230
domain = domain.replace(/^\/\/|^.*?:(\/\/)?/, '');

return username + '@' + domain
}
)
}
Expand Down
4 changes: 2 additions & 2 deletions cypress/ocm-test-suite/cypress/e2e/utils/ocis-5.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ export function acceptInviteLinkV5(token) {
})

getScienceMeshAcceptInvitePartV5('label', 'institution').within(() => {
cy.get('div[class="vs__actions"').click()
cy.get('div[class="vs__actions"').should('be.visible').click()

cy.get('ul[role="listbox"]').find('li').first().click()
cy.get('ul[role="listbox"]').find('li').first().should('be.visible').click()
})

getScienceMeshAcceptInvitePartV5('span', 'accept').click()
Expand Down
14 changes: 9 additions & 5 deletions cypress/ocm-test-suite/cypress/e2e/utils/owncloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export function createShare(fileName, username, domain) {
// ensure selecting remote, instead of email or group.
cy.get('*[class^=ui-autocomplete]')
.contains('span[class="autocomplete-item-typeInfo"]', 'Federated')
.should('be.visible')
.click()
}

Expand All @@ -35,6 +36,7 @@ export function createShareGroup(fileName, group) {
// ensure selecting remote, instead of email or group.
cy.get('*[class^=ui-autocomplete]')
.contains('span[class="autocomplete-item-typeInfo"]', 'Group')
.should('be.visible')
.click()
}

Expand All @@ -48,6 +50,7 @@ export function createShareLink(fileName) {
.should('be.visible')
.find('*[class^="oc-dialog-buttonrow"]')
.find('button[class="primary"]')
.should('be.visible')
.click()

return cy.get('*[data-original-title^="Copy to clipboard"]')
Expand All @@ -64,7 +67,7 @@ export function createShareLink(fileName) {

export function createInviteToken(senderDomain) {

cy.get('button[id="token-generator"]').click()
cy.get('button[id="token-generator"]').should('be.visible').click()

return cy.get('input[class="generated-token-link"]')
.invoke('val')
Expand All @@ -80,7 +83,7 @@ export function createInviteToken(senderDomain) {

export function createInviteLink(targetDomain) {

cy.get('button[id="token-generator"]').click()
cy.get('button[id="token-generator"]').should('be.visible').click()

return cy.get('input[class="generated-token-link"]')
.invoke('val')
Expand Down Expand Up @@ -129,16 +132,17 @@ export function openSharingPanel(fileName) {

cy.get('#app-sidebar')
.get('[data-tabid="shareTabView"]')
.should('be.visible')
.click()
}

export function triggerActionInFileMenu (fileName, actionId) {
triggerActionForFile(fileName,'menu')
getRowForFile(fileName).find('*[class^="filename"]').find('*[class^="fileActionsMenu"]').find(`[data-action="${CSS.escape(actionId)}"]`).should('exist').click()
getRowForFile(fileName).find('*[class^="filename"]').find('*[class^="fileActionsMenu"]').find(`[data-action="${CSS.escape(actionId)}"]`).should('be.visible').click()
}

export const triggerActionForFile = (filename, actionId) => getActionsForFile(filename).find(`[data-action="${CSS.escape(actionId)}"]`).should('exist').click()
export const triggerActionForFile = (filename, actionId) => getActionsForFile(filename).find(`[data-action="${CSS.escape(actionId)}"]`).should('be.visible').as('action-btn').click()

export const getActionsForFile = (filename) => getRowForFile(filename).find('*[class^="filename"]').find('*[class^="name"]').find('*[class^="fileactions"]')
export const getActionsForFile = (filename) => getRowForFile(filename).find('*[class^="filename"]').find('*[class^="name"]').find('*[class^="fileactions"]').should('be.visible')

export const getRowForFile = (filename) => cy.get(`[data-file="${CSS.escape(filename)}"]`)
4 changes: 2 additions & 2 deletions dev/ocm-test-suite/invite-link/nextcloud-ocis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance1--webdav--ho

changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--domain--|" "revanextcloud1.docker"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--homepage--|" "revanextcloud1.docker"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--ocm--|" "revanextcloud1.docker/ocm/"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--ocm--path--|" "revanextcloud1.docker"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--ocm--|" "revanextcloud1.docker"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--ocm--path--|" "revanextcloud1.docker/ocm/"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--ocm--host--|" "revanextcloud1.docker"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--webdav--|" "nextcloud1.docker"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--webdav--path--|" "nextcloud1.docker/remote.php/webdav/"
Expand Down
4 changes: 2 additions & 2 deletions dev/ocm-test-suite/invite-link/ocis-nextcloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance1--webdav--ho

changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--domain--|" "revanextcloud1.docker"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--homepage--|" "revanextcloud1.docker"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--ocm--|" "revanextcloud1.docker/ocm/"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--ocm--path--|" "revanextcloud1.docker"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--ocm--|" "revanextcloud1.docker"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--ocm--path--|" "revanextcloud1.docker/ocm/"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--ocm--host--|" "revanextcloud1.docker"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--webdav--|" "nextcloud1.docker"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--webdav--path--|" "nextcloud1.docker/remote.php/webdav/"
Expand Down
4 changes: 2 additions & 2 deletions dev/ocm-test-suite/invite-link/ocis-owncloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance1--webdav--ho

changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--domain--|" "revaowncloud1.docker"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--homepage--|" "revaowncloud1.docker"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--ocm--|" "revaowncloud1.docker/ocm/"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--ocm--path--|" "revaowncloud1.docker"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--ocm--|" "revaowncloud1.docker"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--ocm--path--|" "revaowncloud1.docker/ocm/"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--ocm--host--|" "revaowncloud1.docker"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--webdav--|" "owncloud1.docker"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--webdav--path--|" "owncloud1.docker/remote.php/webdav/"
Expand Down
4 changes: 2 additions & 2 deletions dev/ocm-test-suite/invite-link/owncloud-ocis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance1--webdav--ho

changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--domain--|" "revaowncloud1.docker"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--homepage--|" "revaowncloud1.docker"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--ocm--|" "revaowncloud1.docker/ocm/"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--ocm--path--|" "revaowncloud1.docker"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--ocm--|" "revaowncloud1.docker"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--ocm--path--|" "revaowncloud1.docker/ocm/"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--ocm--host--|" "revaowncloud1.docker"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--webdav--|" "owncloud1.docker"
changeInFile "${ENV_ROOT}/temp/ocis/ocmproviders.json" "|--instance2--webdav--path--|" "owncloud1.docker/remote.php/webdav/"
Expand Down
2 changes: 1 addition & 1 deletion docker/configs/revad/sciencemesh.toml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ refresh = 900
[grpc.services.ocmproviderauthorizer.drivers.json]
# this is used by the docker-based test deployment, not in production
providers = "/etc/revad/providers.testnet.json"
verify_request_hostname = true
verify_request_hostname = false

[grpc.services.userprovider]
driver = "nextcloud"
Expand Down

0 comments on commit 5e5d51e

Please sign in to comment.