Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Commit

Permalink
Enable update of DC configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
nicodh committed Nov 1, 2019
1 parent 6c301b3 commit fcdb623
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
4 changes: 0 additions & 4 deletions lib/deltachat.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ class DeltaChat extends EventEmitter {
cb && cb()
}

if (this.isConfigured()) {
return process.nextTick(ready)
}

if (typeof opts.addr !== 'string') {
throw new Error('Missing .addr')
}
Expand Down
37 changes: 36 additions & 1 deletion test/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ if (typeof process.env.DC_MAIL_PW !== 'string') {

const ADDR = process.env.DC_ADDR
const SERVER = ADDR.split('@')[1]
const STARTTLS_FLAGS = '65792' // IMAP_SOCKET_STARTTLS & SMTP_SOCKET_STARTTLS
const SSL_FLAGS = '131584' // IMAP_SOCKET_SSL & SMTP_SOCKET_SSL

function configureDefaultDC (dc) {
dc.configure({
Expand All @@ -30,6 +32,8 @@ function configureDefaultDC (dc) {
send_user: ADDR,
send_pw: process.env.DC_MAIL_PW,

server_flags: STARTTLS_FLAGS,

displayname: 'Delta One',
selfstatus: 'From Delta One with <3',
selfavatar: path.join(__dirname, 'fixtures', 'avatar.png'),
Expand All @@ -39,14 +43,37 @@ function configureDefaultDC (dc) {
})
}

function updateConfigurationDC (dc) {
dc.configure({
addr: ADDR,

mail_server: SERVER,
mail_user: ADDR,
mail_pw: process.env.DC_MAIL_PW,

send_server: SERVER,
send_user: ADDR,
send_pw: process.env.DC_MAIL_PW,

server_flags: SSL_FLAGS,

displayname: 'Delta Two',
selfstatus: 'From Delta One with <3',
selfavatar: path.join(__dirname, 'fixtures', 'avatar.png'),

e2ee_enabled: true,
save_mime_headers: true
})
}

// TODO 1. to 4. below would cover dc.open() completely
// 1. test dc.open() where mkdirp fails (e.g. with no permissions)
// 2. test failing dc._open() (what would make it fail in core?)
// 3. test setting up context with e2ee_enabled set to false + close
// 4. test opening an already configured account (re-open above)

test('setUp dc context', t => {
t.plan(17)
t.plan(21)
const cwd = tempy.directory()
dc = new DeltaChat()
dc.once('ready', () => {
Expand All @@ -57,6 +84,7 @@ test('setUp dc context', t => {
t.is(dc.getConfig('send_user'), ADDR, 'sendUser correct')
t.is(dc.getConfig('displayname'), 'Delta One', 'displayName correct')
t.is(dc.getConfig('selfstatus'), 'From Delta One with <3', 'selfStatus correct')
t.is(dc.getConfig('server_flags'), STARTTLS_FLAGS, 'server flags correct')
// TODO comment back in once fixed in core
// t.is(
// dc.getConfig('selfavatar'),
Expand All @@ -76,6 +104,13 @@ test('setUp dc context', t => {
path.join(cwd, 'db.sqlite-blobs'),
'correct blobdir'
)
t.is(dc.isConfigured(), true, 'is configured')

dc.once('ready', () => {
t.is(dc.getConfig('displayname'), 'Delta Two', 'updated displayName correct')
t.is(dc.getConfig('server_flags'), SSL_FLAGS, 'updated server flags correct')
})
updateConfigurationDC(dc)
})
dc.once('DC_EVENT_CONFIGURE_PROGRESS', data => {
t.pass('DC_EVENT_CONFIGURE_PROGRESS called at least once')
Expand Down

0 comments on commit fcdb623

Please sign in to comment.