@open-xchange/appsuite-codeceptjs 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.defaults +47 -0
- package/README.md +40 -0
- package/chai.d.ts +5 -0
- package/customRerun.js +135 -0
- package/global.d.ts +5 -0
- package/index.js +187 -0
- package/package.json +39 -0
- package/src/actor.js +174 -0
- package/src/appsuiteHttpClient.js +155 -0
- package/src/chai.d.ts +6 -0
- package/src/chai.js +58 -0
- package/src/contexts/contexts.js +172 -0
- package/src/contexts/reseller.js +248 -0
- package/src/contexts.js +29 -0
- package/src/event.js +54 -0
- package/src/helper.js +817 -0
- package/src/pageobjects/calendar.js +226 -0
- package/src/pageobjects/contacts.js +148 -0
- package/src/pageobjects/drive.js +96 -0
- package/src/pageobjects/fragments/contact-autocomplete.js +45 -0
- package/src/pageobjects/fragments/contact-picker.js +50 -0
- package/src/pageobjects/fragments/dialogs.js +41 -0
- package/src/pageobjects/fragments/search.js +54 -0
- package/src/pageobjects/fragments/settings-mailfilter.js +90 -0
- package/src/pageobjects/fragments/settings.js +71 -0
- package/src/pageobjects/fragments/tinymce.js +41 -0
- package/src/pageobjects/fragments/topbar.js +43 -0
- package/src/pageobjects/fragments/viewer.js +67 -0
- package/src/pageobjects/mail.js +67 -0
- package/src/pageobjects/mobile/mobileCalendar.js +41 -0
- package/src/pageobjects/mobile/mobileContacts.js +40 -0
- package/src/pageobjects/mobile/mobileMail.js +51 -0
- package/src/pageobjects/tasks.js +58 -0
- package/src/plugins/emptyModule/index.js +21 -0
- package/src/plugins/settingsInit/index.js +35 -0
- package/src/plugins/testmetrics/index.js +135 -0
- package/src/soap/services/context.js +147 -0
- package/src/soap/services/oxaas.js +36 -0
- package/src/soap/services/resellerContext.js +65 -0
- package/src/soap/services/resellerUser.js +100 -0
- package/src/soap/services/user.js +114 -0
- package/src/soap/services/util.js +39 -0
- package/src/soap/soap.js +172 -0
- package/src/users/reseller.js +233 -0
- package/src/users/users.js +183 -0
- package/src/users.js +29 -0
- package/src/util.js +104 -0
- package/steps.d.ts +16 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Copyright (c) Open-Xchange GmbH, Germany <info@open-xchange.com>
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
*
|
|
5
|
+
* This code is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with OX App Suite. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
|
17
|
+
*
|
|
18
|
+
* Any use of the work other than as authorized under this license or copyright law is prohibited.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const { InfluxDB, Point } = require('@influxdata/influxdb-client')
|
|
22
|
+
const event = require('codeceptjs/lib/event')
|
|
23
|
+
const recorder = require('codeceptjs/lib/recorder')
|
|
24
|
+
const chalk = require('chalk')
|
|
25
|
+
const chalkTable = require('chalk-table')
|
|
26
|
+
|
|
27
|
+
function durationOf (test) {
|
|
28
|
+
return test.steps.reduce((sum, step) => sum + (step.endTime - step.startTime), 0)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = function setupTestMetricsPlugin ({ url, org, token, defaultTags }) {
|
|
32
|
+
const client = new InfluxDB({ url, token })
|
|
33
|
+
const performanceRecorder = token
|
|
34
|
+
? client.getWriteApi(org, 'ui-performance', 'ms', { defaultTags })
|
|
35
|
+
// no token, so just record and print collected data
|
|
36
|
+
: (function () {
|
|
37
|
+
const points = []
|
|
38
|
+
return {
|
|
39
|
+
writePoint (p) { points.push(p) },
|
|
40
|
+
flush () {
|
|
41
|
+
if (!points.length) return
|
|
42
|
+
const options = {
|
|
43
|
+
columns: [
|
|
44
|
+
{ field: 'measurement', name: chalk.cyan('Measurement') },
|
|
45
|
+
{ field: 'metric', name: chalk.cyan('Metric') },
|
|
46
|
+
{ field: 'duration', name: chalk.green('Duration') },
|
|
47
|
+
{ field: 'transferSize', name: chalk.green('Transfer size') },
|
|
48
|
+
{ field: 'decodedBodySize', name: chalk.green('Dec. body size') },
|
|
49
|
+
{ field: 'cached', name: chalk.yellow('Cached') },
|
|
50
|
+
{ field: 'tags', name: chalk.cyan('Tags') }
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
console.log(chalkTable(options, points.filter(p => p.name !== 'testrun').map(p => {
|
|
54
|
+
const metric = p.tags.metric
|
|
55
|
+
delete p.tags.metric
|
|
56
|
+
const cached = p.tags.cached
|
|
57
|
+
delete p.tags.cached
|
|
58
|
+
const row = {
|
|
59
|
+
measurement: p.name,
|
|
60
|
+
tags: JSON.stringify(p.tags),
|
|
61
|
+
cached,
|
|
62
|
+
metric
|
|
63
|
+
}
|
|
64
|
+
for (const field of Object.keys(p.fields)) {
|
|
65
|
+
row[field] = p.fields[field]
|
|
66
|
+
}
|
|
67
|
+
return row
|
|
68
|
+
})))
|
|
69
|
+
points.splice(0, points.length)
|
|
70
|
+
},
|
|
71
|
+
dispose () {
|
|
72
|
+
return points.length
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
})()
|
|
76
|
+
|
|
77
|
+
const testRecorder = !!token && client.getWriteApi(org, 'e2e', 'ms', { defaultTags })
|
|
78
|
+
|
|
79
|
+
event.dispatcher.on(event.suite.after, function recordSendMetrics () {
|
|
80
|
+
recorder.add('send metrics data', async function sendMetrics () {
|
|
81
|
+
try {
|
|
82
|
+
await performanceRecorder.flush()
|
|
83
|
+
if (testRecorder) await testRecorder.flush()
|
|
84
|
+
} catch (error) {
|
|
85
|
+
console.log(error)
|
|
86
|
+
console.warn('Could not send metrics data')
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
event.dispatcher.on(event.all.after, function disposeInfluxClient () {
|
|
91
|
+
const unwrittenPoints = performanceRecorder.dispose() + testRecorder ? testRecorder.dispose() : 0
|
|
92
|
+
if (unwrittenPoints) console.warn(`Quit with ${unwrittenPoints} unwritten metrics points in queue.`)
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
event.dispatcher.on(event.test.after, function recordTestMetrics (test) {
|
|
96
|
+
if (!testRecorder) return
|
|
97
|
+
const point = new Point('run')
|
|
98
|
+
.tag('feature', test.parent.title)
|
|
99
|
+
.tag('scenario', test.title)
|
|
100
|
+
.tag('state', test.state)
|
|
101
|
+
|
|
102
|
+
if (process.env.CI) {
|
|
103
|
+
point.tag('deployment', process.env.REPORT_PROJECT || process.env.CI_COMMIT_REF_SLUG)
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
point.timestamp(Date.now())
|
|
107
|
+
point.intField('duration', durationOf(test))
|
|
108
|
+
|
|
109
|
+
testRecorder.writePoint(point)
|
|
110
|
+
} catch (error) {
|
|
111
|
+
console.log(error)
|
|
112
|
+
console.warn('Could not write test metrics')
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
addPerformanceMeasurement (measurement, fields, { tags = {}, timestamp = Date.now() } = {}) {
|
|
118
|
+
const p = new Point(measurement)
|
|
119
|
+
for (const tag in tags) {
|
|
120
|
+
p.tag(tag, tags[tag])
|
|
121
|
+
}
|
|
122
|
+
p.timestamp(timestamp)
|
|
123
|
+
for (const field of fields) {
|
|
124
|
+
try {
|
|
125
|
+
p[field.type](field.name, field.value)
|
|
126
|
+
} catch (e) {
|
|
127
|
+
console.log(e)
|
|
128
|
+
console.warn(`${field.type} is not a valid field type`)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
performanceRecorder.writePoint(p)
|
|
132
|
+
},
|
|
133
|
+
metricsClientName: defaultTags.client
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Copyright (c) Open-Xchange GmbH, Germany <info@open-xchange.com>
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
*
|
|
5
|
+
* This code is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with OX App Suite. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
|
17
|
+
*
|
|
18
|
+
* Any use of the work other than as authorized under this license or copyright law is prohibited.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const { createClientAsync, logSoapError } = require('../soap.js')
|
|
22
|
+
const { getFilestorageId } = require('./util.js')
|
|
23
|
+
|
|
24
|
+
const OXContextService = createClientAsync('OXContextService').then(client => client)
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* This function retrieves the default context from the OXContextService.
|
|
28
|
+
* @returns {Promise<Object>} The first result from the listAsync method call.
|
|
29
|
+
*/
|
|
30
|
+
async function getDefault () {
|
|
31
|
+
return (await (await OXContextService).listAsync({ search_pattern: 'defaultcontext' }))[0]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* This function removes the context with the specified ID.
|
|
36
|
+
* @param {number} id The ID of the context to remove.
|
|
37
|
+
* @returns {Promise<Boolean>} Returns true if it could remove the context and false if it could not
|
|
38
|
+
*/
|
|
39
|
+
async function remove (id) {
|
|
40
|
+
return !!await (await OXContextService).deleteAsync({ ctx: { id } }).then(() => true).catch(logSoapError)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* This function creates a new context.
|
|
45
|
+
* @param {Object} ctx The context to create.
|
|
46
|
+
* @returns {Promise<Object>} The created context.
|
|
47
|
+
*/
|
|
48
|
+
async function create (ctx = {}) {
|
|
49
|
+
return await (await OXContextService)
|
|
50
|
+
.createAsync({
|
|
51
|
+
ctx: {
|
|
52
|
+
id: process.env.CONTEXT_ID || Math.floor(Date.now() / 1000),
|
|
53
|
+
maxQuota: 1000,
|
|
54
|
+
filestoreId: String(await getFilestorageId()),
|
|
55
|
+
...ctx
|
|
56
|
+
},
|
|
57
|
+
admin_user: {
|
|
58
|
+
name: 'oxadmin',
|
|
59
|
+
password: 'secret',
|
|
60
|
+
display_name: 'context admin',
|
|
61
|
+
sur_name: 'admin',
|
|
62
|
+
given_name: 'context',
|
|
63
|
+
email1: `oxadmin@${process.env.MX_DOMAIN}`,
|
|
64
|
+
primaryEmail: `oxadmin@${process.env.MX_DOMAIN}`
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
.then(async context => {
|
|
68
|
+
await changeModuleAccessByName(context.id, 'all')
|
|
69
|
+
return context
|
|
70
|
+
})
|
|
71
|
+
// .catch(logSoapError)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* This function changes the module access of the specified context.
|
|
76
|
+
* @param {number} id The ID of the context.
|
|
77
|
+
* @param {string} access_combination_name The name of the access combination to set.
|
|
78
|
+
* @returns {Promise<void>}
|
|
79
|
+
*/
|
|
80
|
+
// eslint-disable-next-line camelcase
|
|
81
|
+
async function changeModuleAccessByName (id, access_combination_name) {
|
|
82
|
+
// eslint-disable-next-line camelcase
|
|
83
|
+
return await (await OXContextService).changeModuleAccessByNameAsync({ ctx: { id }, access_combination_name })
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* This function changes the capabilities of the specified context.
|
|
88
|
+
* @param {number} id The ID of the context.
|
|
89
|
+
* @param {string} capsToAdd The capabilities to add.
|
|
90
|
+
* @param {string} capsToRemove The capabilities to remove.
|
|
91
|
+
* @returns {Promise<void>}
|
|
92
|
+
*/
|
|
93
|
+
async function changeCapabilities (id, capsToAdd, capsToRemove) {
|
|
94
|
+
const data = {}
|
|
95
|
+
if (capsToAdd) data.capsToAdd = capsToAdd
|
|
96
|
+
if (capsToRemove) data.capsToRemove = capsToRemove
|
|
97
|
+
return await (await OXContextService).changeCapabilitiesAsync({ ctx: { id }, ...data })
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* This function retrieves the module access of the specified context.
|
|
102
|
+
* @param {number} id The ID of the context.
|
|
103
|
+
* @returns {Promise<Object>} The module access of the specified context.
|
|
104
|
+
*/
|
|
105
|
+
async function getModuleAccess (id) {
|
|
106
|
+
return await (await OXContextService).getModuleAccessAsync({ ctx: { id } })
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* This function changes the module access of the specified context.
|
|
110
|
+
* @param {number} id The ID of the context.
|
|
111
|
+
* @param {Object} moduleAccess The module access to set.
|
|
112
|
+
* @returns {Promise<void>}
|
|
113
|
+
*/
|
|
114
|
+
async function changeModuleAccess (id, moduleAccess) {
|
|
115
|
+
const currentAccess = await getModuleAccess(id)
|
|
116
|
+
return await (await OXContextService).changeModuleAccessAsync({ ctx: { id }, access: { ...currentAccess, ...moduleAccess } })
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* This function retrieves the context with the specified ID.
|
|
121
|
+
* @param {number} id The ID of the context to retrieve.
|
|
122
|
+
* @returns {Promise<Object>} The context with the specified ID.
|
|
123
|
+
*/
|
|
124
|
+
async function get (id) {
|
|
125
|
+
return await (await OXContextService).getDataAsync({ ctx: { id } })
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* This function changes the context with the specified ID.
|
|
130
|
+
* @param {Object} ctx The context to change.
|
|
131
|
+
* @returns {Promise<void>}
|
|
132
|
+
*/
|
|
133
|
+
async function change (ctx) {
|
|
134
|
+
return await (await OXContextService).changeAsync({ ctx })
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
module.exports = {
|
|
138
|
+
getDefault,
|
|
139
|
+
remove,
|
|
140
|
+
create,
|
|
141
|
+
changeModuleAccessByName,
|
|
142
|
+
changeCapabilities,
|
|
143
|
+
getModuleAccess,
|
|
144
|
+
changeModuleAccess,
|
|
145
|
+
get,
|
|
146
|
+
change
|
|
147
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Copyright (c) Open-Xchange GmbH, Germany <info@open-xchange.com>
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
*
|
|
5
|
+
* This code is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with OX App Suite. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
|
17
|
+
*
|
|
18
|
+
* Any use of the work other than as authorized under this license or copyright law is prohibited.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const { createClientAsync } = require('../soap.js')
|
|
22
|
+
|
|
23
|
+
const OXaaSService = createClientAsync('OXaaSService').then(client => client)
|
|
24
|
+
|
|
25
|
+
async function setMailQuota (data) {
|
|
26
|
+
return await (await OXaaSService).setMailQuotaAsync(data)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function createSharedDomain (data) {
|
|
30
|
+
return await (await OXaaSService).createSharedDomain(data)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
module.exports = {
|
|
34
|
+
setMailQuota,
|
|
35
|
+
createSharedDomain
|
|
36
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Copyright (c) Open-Xchange GmbH, Germany <info@open-xchange.com>
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
*
|
|
5
|
+
* This code is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with OX App Suite. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
|
17
|
+
*
|
|
18
|
+
* Any use of the work other than as authorized under this license or copyright law is prohibited.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const { createClientAsync, logSoapError } = require('../soap.js')
|
|
22
|
+
|
|
23
|
+
const OXResellerContextService = createClientAsync('OXResellerContextService').then(client => client)
|
|
24
|
+
|
|
25
|
+
async function create (data) {
|
|
26
|
+
return await (await OXResellerContextService).createAsync(data)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function remove (contextId) {
|
|
30
|
+
return !!await (await OXResellerContextService).deleteAsync({
|
|
31
|
+
ctx: { id: contextId }
|
|
32
|
+
}).then(() => true).catch(logSoapError)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function change (ctx) {
|
|
36
|
+
return await (await OXResellerContextService).changeAsync({ ctx })
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function get (id) {
|
|
40
|
+
return await (await OXResellerContextService).getDataAsync({ ctx: { id } })
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function getModuleAccess (id) {
|
|
44
|
+
return await (await OXResellerContextService).getModuleAccessAsync({ ctx: id })
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function changeModuleAccess (id, access) {
|
|
48
|
+
const currentAccess = await getModuleAccess(id)
|
|
49
|
+
|
|
50
|
+
return await (await OXResellerContextService).changeModuleAccessAsync({ ctx: { id }, access: { ...currentAccess, ...access } })
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function listAll (data) {
|
|
54
|
+
return await (await OXResellerContextService).listAllAsync(data)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
module.exports = {
|
|
58
|
+
create,
|
|
59
|
+
remove,
|
|
60
|
+
change,
|
|
61
|
+
get,
|
|
62
|
+
getModuleAccess,
|
|
63
|
+
changeModuleAccess,
|
|
64
|
+
listAll
|
|
65
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Copyright (c) Open-Xchange GmbH, Germany <info@open-xchange.com>
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
*
|
|
5
|
+
* This code is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with OX App Suite. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
|
17
|
+
*
|
|
18
|
+
* Any use of the work other than as authorized under this license or copyright law is prohibited.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const { createClientAsync, logSoapError } = require('../soap.js')
|
|
22
|
+
|
|
23
|
+
const OXResellerUserService = createClientAsync('OXResellerUserService').then(client => client)
|
|
24
|
+
|
|
25
|
+
async function remove (contextId, userId) {
|
|
26
|
+
return !!await (await OXResellerUserService).deleteAsync({
|
|
27
|
+
ctx: { id: contextId },
|
|
28
|
+
user: { id: userId }
|
|
29
|
+
}).then(() => true).catch(logSoapError)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* This function changes the context with the specified ID.
|
|
34
|
+
* @param {Object} context The context of the user to be changed.
|
|
35
|
+
* @param {Object} usrdata The user to change.
|
|
36
|
+
* @returns {Promise<void>}
|
|
37
|
+
*/
|
|
38
|
+
async function change (context, usrdata) {
|
|
39
|
+
return await (await OXResellerUserService).changeAsync({
|
|
40
|
+
ctx: { id: context.id },
|
|
41
|
+
usrdata,
|
|
42
|
+
auth: { login: context.admin.name, password: context.admin.password }
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function get (data) {
|
|
47
|
+
return await (await OXResellerUserService).getDataAsync(data)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function getModuleAccess (context, userId) {
|
|
51
|
+
return await (await OXResellerUserService).getModuleAccessAsync({
|
|
52
|
+
ctx: { id: context.id },
|
|
53
|
+
user: { id: userId },
|
|
54
|
+
auth: { login: context.admin.name, password: context.admin.password }
|
|
55
|
+
}).then(
|
|
56
|
+
(res) => res
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function changeByModuleAccess (context, userId, currentAccess, moduleAccess) {
|
|
61
|
+
return await (await OXResellerUserService).changeByModuleAccessAsync({
|
|
62
|
+
ctx: { id: context.id },
|
|
63
|
+
moduleAccess: Object.assign({}, currentAccess, moduleAccess),
|
|
64
|
+
user: { id: userId },
|
|
65
|
+
auth: { login: context.admin.name, password: context.admin.password }
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async function changeByModuleAccessName (context, userId, accessCombinationName) {
|
|
70
|
+
return await (await OXResellerUserService).changeByModuleAccessNameAsync({
|
|
71
|
+
ctx: { id: context.id },
|
|
72
|
+
access_combination_name: accessCombinationName,
|
|
73
|
+
user: { id: userId },
|
|
74
|
+
auth: { login: context.admin.name, password: context.admin.password }
|
|
75
|
+
}).catch(error => console.error('Module access change error: ', error))
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function createByModuleAccessName (context, usrdata) {
|
|
79
|
+
return await (await OXResellerUserService).createByModuleAccessNameAsync({
|
|
80
|
+
ctx: { id: context.id },
|
|
81
|
+
usrdata,
|
|
82
|
+
access_combination_name: 'all',
|
|
83
|
+
auth: { login: context.admin.name, password: context.admin.password }
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async function listAll (data) {
|
|
88
|
+
return await (await OXResellerUserService).listAllAsync(data)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
module.exports = {
|
|
92
|
+
remove,
|
|
93
|
+
change,
|
|
94
|
+
get,
|
|
95
|
+
getModuleAccess,
|
|
96
|
+
changeByModuleAccess,
|
|
97
|
+
changeByModuleAccessName,
|
|
98
|
+
createByModuleAccessName,
|
|
99
|
+
listAll
|
|
100
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Copyright (c) Open-Xchange GmbH, Germany <info@open-xchange.com>
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
*
|
|
5
|
+
* This code is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with OX App Suite. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
|
17
|
+
*
|
|
18
|
+
* Any use of the work other than as authorized under this license or copyright law is prohibited.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const { createClientAsync, logSoapError } = require('../soap.js')
|
|
22
|
+
|
|
23
|
+
const OXUserService = createClientAsync('OXUserService').then(client => client)
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* This function removes the user with the specified context and user ID.
|
|
27
|
+
* @param {Object} context The context of the user to be removed.
|
|
28
|
+
* @param {number} userId The ID of the user to be removed.
|
|
29
|
+
* @returns {Promise<Boolean>} Returns true if it could remove the user and false if it could not
|
|
30
|
+
*/
|
|
31
|
+
async function remove (context, userId) {
|
|
32
|
+
return !!await (await OXUserService).deleteAsync({
|
|
33
|
+
ctx: { id: context.id },
|
|
34
|
+
user: { id: userId },
|
|
35
|
+
auth: context.admin
|
|
36
|
+
}).then(() => true).catch(logSoapError)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* This function creates a new user.
|
|
41
|
+
* @param {Object} context The context of the user to be created.
|
|
42
|
+
* @param {Object} usrdata The user to create.
|
|
43
|
+
* @returns {Promise<Object>} The created user.
|
|
44
|
+
*/
|
|
45
|
+
async function create (context, usrdata) {
|
|
46
|
+
return await (await OXUserService).createAsync({
|
|
47
|
+
ctx: { id: context.id },
|
|
48
|
+
usrdata,
|
|
49
|
+
auth: context.admin
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* This function changes the context with the specified ID.
|
|
55
|
+
* @param {Object} context The context of the user to be changed.
|
|
56
|
+
* @param {Object} usrdata The user to change.
|
|
57
|
+
* @returns {Promise<void>}
|
|
58
|
+
*/
|
|
59
|
+
async function change (context, usrdata) {
|
|
60
|
+
return await (await OXUserService).changeAsync({
|
|
61
|
+
ctx: { id: context.id },
|
|
62
|
+
usrdata,
|
|
63
|
+
auth: context.admin
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function changeByModuleAccess (context, userId, currentAccess, moduleAccess) {
|
|
68
|
+
return await (await OXUserService).changeByModuleAccessAsync({
|
|
69
|
+
ctx: { id: context.id },
|
|
70
|
+
moduleAccess: Object.assign({}, currentAccess, moduleAccess),
|
|
71
|
+
user: { id: userId },
|
|
72
|
+
auth: context.admin
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function changeByModuleAccessName (context, userId, accessCombinationName) {
|
|
77
|
+
return await (await OXUserService).changeByModuleAccessNameAsync({
|
|
78
|
+
ctx: { id: context.id },
|
|
79
|
+
access_combination_name: accessCombinationName,
|
|
80
|
+
user: { id: userId },
|
|
81
|
+
auth: context.admin
|
|
82
|
+
}).catch(error => console.error('Module access change error:', error))
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function getModuleAccess (context, userId) {
|
|
86
|
+
return await (await OXUserService).getModuleAccessAsync({
|
|
87
|
+
ctx: { id: context.id },
|
|
88
|
+
user: { id: userId },
|
|
89
|
+
auth: context.admin
|
|
90
|
+
}).then(
|
|
91
|
+
(res) => res
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async function changeCapabilities (context, userId, capsToAdd, capsToRemove) {
|
|
96
|
+
const data = {
|
|
97
|
+
ctx: { id: context.id },
|
|
98
|
+
user: { id: userId },
|
|
99
|
+
auth: context.admin
|
|
100
|
+
}
|
|
101
|
+
if (capsToAdd) data.capsToAdd = capsToAdd
|
|
102
|
+
if (capsToRemove) data.capsToRemove = capsToRemove
|
|
103
|
+
return await (await OXUserService).changeCapabilitiesAsync(data)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
module.exports = {
|
|
107
|
+
create,
|
|
108
|
+
change,
|
|
109
|
+
changeByModuleAccess,
|
|
110
|
+
changeByModuleAccessName,
|
|
111
|
+
changeCapabilities,
|
|
112
|
+
getModuleAccess,
|
|
113
|
+
remove
|
|
114
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Copyright (c) Open-Xchange GmbH, Germany <info@open-xchange.com>
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
*
|
|
5
|
+
* This code is free software: you can redistribute it and/or modify
|
|
6
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
* (at your option) any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with OX App Suite. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>.
|
|
17
|
+
*
|
|
18
|
+
* Any use of the work other than as authorized under this license or copyright law is prohibited.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
const { createClientAsync } = require('../soap.js')
|
|
22
|
+
|
|
23
|
+
const OXUtilService = createClientAsync('OXUtilService').then(client => client)
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* This function retrieves the ID of the first filestorage.
|
|
27
|
+
* @returns {Promise<number>} The ID of the first filestorage.
|
|
28
|
+
*/
|
|
29
|
+
let fileStoreId
|
|
30
|
+
|
|
31
|
+
async function getFilestorageId () {
|
|
32
|
+
if (fileStoreId) return fileStoreId
|
|
33
|
+
fileStoreId = (await (await OXUtilService).listFilestoreAsync())[0]?.id
|
|
34
|
+
return fileStoreId
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = {
|
|
38
|
+
getFilestorageId
|
|
39
|
+
}
|