Skip to content

Commit

Permalink
Bump SDK and fix more acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalwengerter committed Apr 21, 2022
1 parent 357e90e commit e3160b0
Show file tree
Hide file tree
Showing 10 changed files with 293 additions and 88 deletions.
32 changes: 9 additions & 23 deletions packages/web-app-files/src/components/SideBar/Shares/FileLinks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ import { cloneStateObject } from '../../../helpers/store'
import CreateForm from './PublicLinks/CreateForm.vue'
import DetailsAndEdit from './PublicLinks/DetailsAndEdit.vue'
import NameAndCopy from './PublicLinks/NameAndCopy.vue'
import { ShareTypes, LinkShareRoles, SharePermissions } from '../../../helpers/share'
import { ShareTypes, LinkShareRoles } from '../../../helpers/share'
import { useStore, useCapabilitySpacesEnabled } from 'web-pkg/src/composables'
import { clientService } from 'web-pkg/src/services'
import { dirname } from 'path'
Expand Down Expand Up @@ -187,28 +187,16 @@ export default defineComponent({
},
passwordEnforced() {
const password = this.capabilities.files_sharing.public.password.enforced_for
if (password.read_only === '1') {
return (
this.selectedRole.hasPermission(SharePermissions.read) &&
!this.selectedRole.hasPermission(SharePermissions.create)
)
}
if (password.upload_only === '1') {
return (
!this.selectedRole.hasPermission(SharePermissions.read) &&
this.selectedRole.hasPermission(SharePermissions.create)
)
}
if (password.read_write === '1') {
return (
this.selectedRole.hasPermission(SharePermissions.read) &&
this.selectedRole.hasPermission(SharePermissions.create)
)
let passwordEnforcedFor = {
read_only: false,
upload_only: false,
read_write: false
}
return false
if (this.capabilities.files_sharing.public.password.enforced_for) {
passwordEnforcedFor = this.capabilities.files_sharing.public.password.enforced_for
}
return passwordEnforcedFor
},
canCreatePublicLinks() {
Expand Down Expand Up @@ -361,8 +349,6 @@ export default defineComponent({
.toFormat("yyyy-MM-dd'T'HH:mm:ssZZZ")
}
console.log(link)
return {
expireDate,
password: link.password,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
<script>
import { DateTime } from 'luxon'
import RoleItem from '../Shared/RoleItem.vue'
import { SharePermissions } from '../../../../helpers/share'
export default {
components: {
Expand All @@ -144,8 +145,9 @@ export default {
required: false
},
passwordEnforced: {
type: Boolean,
default: false
type: Object,
default: () => {},
required: false
}
},
data() {
Expand Down Expand Up @@ -173,7 +175,7 @@ export default {
return this.$gettext('Name')
},
passwordLabel() {
if (this.passwordEnforced) {
if (this.passwordEnforcedForRole) {
return this.$gettext('Password (required)')
}
Expand All @@ -183,11 +185,32 @@ export default {
return this.$gettext('Role')
},
passwordEnforcedForRole() {
const currentRole = this.availableRoleOptions.find((role) => {
return this.link.role.label === role.role.label
})
const canRead = currentRole.role.hasPermission(SharePermissions.read)
const canCreate = currentRole.role.hasPermission(SharePermissions.create)
if (this.passwordEnforced.read_only === true) {
return canRead && !canCreate
}
if (this.passwordEnforced.upload_only === true) {
return !canRead && canCreate
}
if (this.passwordEnforced.read_write === true) {
return canRead && canCreate
}
return false
},
isValid() {
const passwordValid = !(this.passwordEnforced && !this.link.password)
const passwordValid = !(this.passwordEnforcedForRole && !this.link.password)
// needs to check expiration date min/max!
const expireDateValid = !(this.expirationDate.enforced && !this.link.expiration)
return passwordValid || expireDateValid
return passwordValid && expireDateValid
},
relativeExpirationDate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ import { mapActions } from 'vuex'
import Mixins from '../../../../mixins'
import { createLocationSpaces, isLocationSpacesActive } from '../../../../router'
import { DateTime } from 'luxon'
import { linkRoleDescriptions, LinkShareRoles } from '../../../../helpers/share'
import { linkRoleDescriptions, LinkShareRoles, SharePermissions } from '../../../../helpers/share'
export default {
name: 'DetailsAndEdit',
Expand Down Expand Up @@ -164,8 +164,9 @@ export default {
default: false
},
passwordEnforced: {
type: Boolean,
default: false
type: Object,
default: () => {},
required: false
}
},
data() {
Expand Down Expand Up @@ -241,7 +242,7 @@ export default {
method: this.showPasswordModal
})
if (!this.passwordEnforced) {
if (!this.passwordEnforcedForRole) {
result.push({
id: 'remove-password',
title: this.$gettext('Remove password'),
Expand All @@ -254,7 +255,8 @@ export default {
})
})
}
} else {
}
if (!this.passwordEnforcedForRole && !this.link.password) {
result.push({
id: 'add-password',
title: this.$gettext('Add password'),
Expand Down Expand Up @@ -323,6 +325,26 @@ export default {
)
},
passwordEnforcedForRole() {
const currentRole = this.availableRoleOptions.find((role) => {
return parseInt(this.link.permissions) === role.role.bitmask(false)
})
const canRead = currentRole.role.hasPermission(SharePermissions.read)
const canCreate = currentRole.role.hasPermission(SharePermissions.create)
if (this.passwordEnforced.read_only === true) {
return canRead && !canCreate
}
if (this.passwordEnforced.upload_only === true) {
return !canRead && canCreate
}
if (this.passwordEnforced.read_write === true) {
return canRead && canCreate
}
return false
},
passwortProtectionTooltip() {
return this.$gettext('This link is password-protected')
}
Expand All @@ -339,7 +361,7 @@ export default {
},
methods: {
...mapActions(['createModal', 'hideModal']),
...mapActions(['createModal', 'hideModal', 'setModalInputErrorMessage']),
updateLink({
link = this.link,
dropRef = this.$refs.editPublicLinkDropdown,
Expand Down Expand Up @@ -376,18 +398,27 @@ export default {
this.createModal(modal)
},
checkPasswordNotEmpty(password) {
if (password === '') {
return this.setModalInputErrorMessage(this.$gettext("Password can't be empty"))
}
return this.setModalInputErrorMessage(null)
},
showPasswordModal() {
// needs to check if password is enforced to prevent from "remove through edit with empty input field"
const modal = {
variation: 'passive',
title: this.link.password ? this.$gettext('Edit password') : this.$gettext('Add password'),
cancelText: this.$gettext('Cancel'),
confirmText: this.link.password ? this.$gettext('Apply') : this.$gettext('Set'),
hasInput: true,
inputDescription: this.$gettext("Password can't be empty"),
inputType: 'password',
inputLabel: this.$gettext('Password'),
onCancel: this.hideModal,
onConfirm: (password) =>
onInput: (password) => this.checkPasswordNotEmpty(password),
onConfirm: (password) => {
this.updateLink({
link: {
...this.link,
Expand All @@ -397,6 +428,7 @@ export default {
this.hideModal()
}
})
}
}
this.createModal(modal)
Expand Down
4 changes: 2 additions & 2 deletions packages/web-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"marked": "^4.0.12",
"oidc-client": "1.11.5",
"owncloud-design-system": "^13.1.0-rc.4",
"owncloud-sdk": "~3.0.0-alpha.4",
"owncloud-sdk": "~3.0.0-alpha.5",
"p-queue": "^6.1.1",
"popper-max-size-modifier": "^0.2.0",
"portal-vue": "^2.1.7",
Expand Down Expand Up @@ -51,7 +51,7 @@
"vuex-persist": "3.1.3",
"vuex-router-sync": "^5.0.0",
"web-pkg": "*",
"webdav": "4.8.0",
"webdav": "4.9.0",
"webfontloader": "^1.6.28",
"xml-js": "^1.6.11"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ Feature: Edit public link shares
| name | Public-link |
| permissions | <initial-permissions> |
And user "Alice" has logged in using the webUI
When the user tries to edit the public link named "Public-link" of folder "simple-folder" changing following
| role | <role> |
When the user tries to edit the public link named "Public-link" of folder "simple-folder" changing the role to "<role>"
Then the user should see an error message on the public link share dialog saying "Passwords are enforced for link shares"
And user "Alice" should have a share with these details in the server:
| field | value |
Expand All @@ -32,6 +31,7 @@ Feature: Edit public link shares
| read | Editor | shareapi_enforce_links_password_read_write_delete |
| read, create | Uploader | shareapi_enforce_links_password_write_only |


@issue-ocis-1328
Scenario Outline: user tries to delete the password of an existing public link role while enforce password for that role is enforced
Given the setting "<setting-name>" of app "core" has been set to "yes" in the server
Expand All @@ -42,9 +42,8 @@ Feature: Edit public link shares
| permissions | <initial-permissions> |
| password | 123 |
And user "Alice" has logged in using the webUI
When the user tries to edit the public link named "Public-link" of folder "simple-folder" changing following
| password | |
Then the user should see an error message on the public link share dialog saying "Passwords are enforced for link shares"
When the user tries to edit the public link named "Public-link" of folder "simple-folder" changing the password to ""
Then the user should see an error message on the public link edit modal dialog saying "Password can't be empty"
And user "Alice" should have a share with these details in the server:
| field | value |
| share_type | public_link |
Expand Down Expand Up @@ -96,6 +95,7 @@ Feature: Edit public link shares






Scenario: user edits a name of an already existing public link
Expand All @@ -107,11 +107,11 @@ Feature: Edit public link shares
| name | Public-link |
| permissions | read |
| password | pass123 |
When the user edits the public link named "Public-link" of folder "simple-folder" changing following
| name | simple-folder Share |
When the user renames the public link named "Public-link" of folder "simple-folder" to "simple-folder Share"
And the public uses the webUI to access the last public link created by user "Alice" with password "pass123" in a new session
Then file "lorem.txt" should be listed on the webUI


Scenario: user edits the password of an already existing public link
Given user "Alice" has created folder "simple-folder" in the server
And user "Alice" has created file "simple-folder/lorem.txt" in the server
Expand All @@ -121,11 +121,11 @@ Feature: Edit public link shares
| permissions | read, update, create, delete |
| password | pass123 |
And user "Alice" has logged in using the webUI
When the user edits the public link named "Public-link" of folder "simple-folder" changing following
| password | qwertyui |
When the user tries to edit the public link named "Public-link" of folder "simple-folder" changing the password to "qwertyui"
And the public uses the webUI to access the last public link created by user "Alice" with password "qwertyui" in a new session
Then file "lorem.txt" should be listed on the webUI


@issue-3830
Scenario: user edits the password of an already existing public link and tries to access with old password
Given user "Alice" has created folder "simple-folder" in the server
Expand All @@ -136,11 +136,11 @@ Feature: Edit public link shares
| permissions | read, update, create, delete |
| password | pass123 |
And user "Alice" has logged in using the webUI
When the user tries to edit the public link named "Public-link" of folder "simple-folder" changing following
| password | qwertyui |
When the user tries to edit the public link named "Public-link" of folder "simple-folder" changing the password to "qwertyui"
And the public uses the webUI to access the last public link created by user "Alice" with password "pass123" in a new session
Then the public should not get access to the publicly shared file


@issue-ocis-reva-292
Scenario: user edits the permission of an already existing public link from read-write to read
Given user "Alice" has created folder "simple-folder" in the server
Expand All @@ -150,12 +150,12 @@ Feature: Edit public link shares
| name | Public-link |
| permissions | read, update, create, delete |
And user "Alice" has logged in using the webUI
When the user edits the public link named "Public-link" of folder "simple-folder" changing following
| role | Viewer |
When the user tries to edit the public link named "Public-link" of folder "simple-folder" changing the role to "Viewer"
And the public uses the webUI to access the last public link created by user "Alice" in a new session
Then file "lorem.txt" should be listed on the webUI
And it should not be possible to delete file "lorem.txt" using the webUI


@issue-ocis-reva-292 @disablePreviews
Scenario: user edits the permission of an already existing public link from read to read-write
Given user "Alice" has created folder "simple-folder" in the server
Expand Down Expand Up @@ -196,21 +196,20 @@ Feature: Edit public link shares
| name | Public-link |
| permissions | read, update, create, delete |
And user "Alice" has logged in using the webUI
When the user edits the public link named "Public-link" of folder "simple-folder" changing following
| role | Contributor |
When the user tries to edit the public link named "Public-link" of folder "simple-folder" changing the role to "Contributor"
And the public uses the webUI to access the last public link created by user "Alice" in a new session
And the user uploads file "lorem.txt" using the webUI
Then file "simple.txt" should be listed on the webUI
And file "lorem.txt" should be listed on the webUI



Scenario: assign password to already created public share
Given user "Alice" has created file "lorem.txt" in the server
And user "Alice" has created a public link with following settings in the server
| path | lorem.txt |
| name | Public-link |
| path | lorem.txt |
| name | Public-link |
And user "Alice" has logged in using the webUI
When the user edits the public link named "Public-link" of file "lorem.txt" changing following
| password | pass123 |
When the user tries to edit the public link named "Public-link" of folder "lorem.txt" adding a password "pass123"
And the public uses the webUI to access the last public link created by user "Alice" with password "pass123" in a new session
Then file "lorem.txt" should be listed on the webUI
Loading

0 comments on commit e3160b0

Please sign in to comment.