mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-18 18:05:36 +00:00
test: migration from Python to JavaScript
This commit is contained in:
@@ -10,7 +10,7 @@ class ManageSieve {
|
||||
this.params = {
|
||||
host: config.sieve_server,
|
||||
port: config.sieve_port,
|
||||
shellPrompt: /\bOK "/,
|
||||
shellPrompt: /\bOK/,
|
||||
timeout: 1500
|
||||
}
|
||||
this.connection = new Telnet()
|
||||
@@ -23,7 +23,7 @@ class ManageSieve {
|
||||
|
||||
if (!this.ready) {
|
||||
await this.connection.connect(this.params)
|
||||
response = await this.connection.send('CAPABILITY', { waitfor: /\b(OK|NO) "/ })
|
||||
response = await this.connection.send('CAPABILITY', { waitfor: /\b(OK|NO)/ })
|
||||
// console.debug(`ManageSieve.connect => ${response}`)
|
||||
parsedResponse = this.parseResponse(response)
|
||||
if (!parsedResponse['OK']) {
|
||||
@@ -43,7 +43,7 @@ class ManageSieve {
|
||||
|
||||
buff = Buffer.from(`${this.login}\0${this.authname}\0${this.password}`)
|
||||
base64 = buff.toString('base64')
|
||||
response = await this.connection.send(`AUTHENTICATE "PLAIN" {${base64.length}+}\n${base64}`, { waitfor: /\b(OK|NO) "/ })
|
||||
response = await this.connection.send(`AUTHENTICATE "PLAIN" {${base64.length}+}\n${base64}`, { waitfor: /\b(OK|NO)/ })
|
||||
// console.debug(`ManageSieve.authenticate => ${response}`)
|
||||
parsedResponse = this.parseResponse(response)
|
||||
if (!parsedResponse['OK']) {
|
||||
@@ -56,7 +56,7 @@ class ManageSieve {
|
||||
|
||||
await this.connect()
|
||||
|
||||
response = await this.connection.send(`LISTSCRIPTS`, { waitfor: /\b(OK|NO) "/ })
|
||||
response = await this.connection.send(`LISTSCRIPTS`, { waitfor: /\b(OK|NO)/ })
|
||||
parsedResponse = this.parseResponse(response)
|
||||
// console.debug(`ManageSieve.listScripts => ${JSON.stringify(parsedResponse, undefined, 2)}`)
|
||||
if (!parsedResponse['OK']) {
|
||||
@@ -70,7 +70,7 @@ class ManageSieve {
|
||||
|
||||
await this.connect()
|
||||
|
||||
response = await this.connection.send(`GETSCRIPT "${scriptname}"`, { waitfor: /\b(OK|NO) "/ })
|
||||
response = await this.connection.send(`GETSCRIPT "${scriptname}"`, { waitfor: /\b(OK|NO)/ })
|
||||
// console.debug(`ManageSieve.getScript(${scriptname}) => |${response}|`)
|
||||
const lengthMatch = response.match(/{([0-9]+)}\r?\n/)
|
||||
if (lengthMatch) {
|
||||
|
||||
@@ -107,17 +107,13 @@ describe('PreventInvitations', function() {
|
||||
})
|
||||
|
||||
beforeEach(async function() {
|
||||
const calendarPrefs = prefs.get('Calendar')
|
||||
if (!calendarPrefs.PreventInvitationsWhitelist)
|
||||
calendarPrefs.PreventInvitationsWhitelist = {}
|
||||
await prefs.set('PreventInvitationsWhitelist', {})
|
||||
if (!calendarPrefs.PreventInvitations)
|
||||
calendarPrefs.PreventInvitations = 0
|
||||
await prefs.set('PreventInvitations', 0)
|
||||
await prefs.setOrCreate('PreventInvitationsWhitelist', {}, ['settings', 'Calendar'])
|
||||
await prefs.setOrCreate('PreventInvitations', 0, ['settings', 'Calendar'])
|
||||
await prefs.save()
|
||||
})
|
||||
|
||||
afterAll(async function() {
|
||||
await prefs.set('PreventInvitationsWhitelist', {})
|
||||
await prefs.setNoSave('PreventInvitationsWhitelist', {})
|
||||
await prefs.set('PreventInvitations', 0)
|
||||
// delete all created events from all users' calendar
|
||||
for (const ics of icsList) {
|
||||
@@ -129,7 +125,6 @@ describe('PreventInvitations', function() {
|
||||
|
||||
it(`Disable, accept the invitation`, async function() {
|
||||
// First accept the invitation
|
||||
await prefs.set('PreventInvitations', 0)
|
||||
const settings = await prefs.getSettings()
|
||||
const { Calendar: { PreventInvitations } = {} } = settings
|
||||
expect(PreventInvitations)
|
||||
|
||||
Reference in New Issue
Block a user