mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-19 10:25:27 +00:00
test: migration from Python to JavaScript
This commit is contained in:
@@ -264,6 +264,31 @@ class WebDAV {
|
||||
})
|
||||
}
|
||||
|
||||
proppatchWebdav(resource, properties) {
|
||||
const formattedProperties = Object.keys(properties).map(p => {
|
||||
return { [`i:${p}`]: properties[p] }
|
||||
})
|
||||
return davRequest({
|
||||
url: this.serverUrl + resource,
|
||||
init: {
|
||||
method: 'PROPPATCH',
|
||||
headers: this.headers,
|
||||
namespace: DAVNamespaceShorthandMap[DAVNamespace.DAV],
|
||||
body: {
|
||||
propertyupdate: {
|
||||
_attributes: {
|
||||
...getDAVAttribute([DAVNamespace.DAV]),
|
||||
'xmlns:i': 'urn:inverse:params:xml:ns:inverse-dav'
|
||||
},
|
||||
set: {
|
||||
prop: formattedProperties
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
currentUserPrivilegeSet(resource) {
|
||||
return propfind({
|
||||
url: this.serverUrl + resource,
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
import config from '../lib/config'
|
||||
import WebDAV from '../lib/WebDAV'
|
||||
|
||||
describe('default classification', function() {
|
||||
const webdav = new WebDAV(config.username, config.password)
|
||||
|
||||
const _setClassification = async function(component, classification = '') {
|
||||
const resource = `/SOGo/dav/${config.username}/Calendar/`
|
||||
const properties = { [`${component}-default-classification`]: classification }
|
||||
|
||||
const results = await webdav.proppatchWebdav(resource, properties)
|
||||
expect(results.length)
|
||||
.withContext(`Set ${component} classification to ${classification}`)
|
||||
.toBe(1)
|
||||
|
||||
return results[0].status
|
||||
}
|
||||
|
||||
// HTTPDefaultClassificationTest
|
||||
|
||||
it('expected failure when setting a classification with an invalid property', async function() {
|
||||
let status
|
||||
|
||||
status = await _setClassification('123456', 'PUBLIC')
|
||||
expect(status)
|
||||
.withContext('Setting an invalid classification property')
|
||||
.toBe(403)
|
||||
|
||||
status = await _setClassification('events', '')
|
||||
expect(status)
|
||||
.withContext('Setting an empty classification')
|
||||
.toBe(403)
|
||||
|
||||
status = await _setClassification('events', 'pouet')
|
||||
expect(status)
|
||||
.withContext('Setting an invalid classification')
|
||||
.toBe(403)
|
||||
})
|
||||
|
||||
it('setting a valid classification', async function() {
|
||||
for (let component of ['events', 'tasks']) {
|
||||
for (let classification of ['PUBLIC', 'PRIVATE', 'CONFIDENTIAL']) {
|
||||
const status = await _setClassification(component, classification)
|
||||
expect(status)
|
||||
.withContext(`Set ${component} classification to ${classification}`)
|
||||
.toBe(207)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user