Use a decent SMTP docker image to test against
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
Родитель
6b23904459
Коммит
3616fc0b93
|
@ -52,6 +52,7 @@ before_install:
|
|||
- composer self-update
|
||||
- make install-composer-deps
|
||||
- make start-imap-docker
|
||||
- make start-smtp-docker
|
||||
- cd ..
|
||||
- git clone https://github.com/nextcloud/server.git --recursive --depth 1 -b $CORE_BRANCH core
|
||||
- mv mail core/apps/
|
||||
|
|
14
Makefile
14
Makefile
|
@ -39,12 +39,20 @@ dev-setup: install-composer-deps install-npm-deps-dev
|
|||
|
||||
start-imap-docker:
|
||||
docker pull $(docker_image)
|
||||
docker run --name="ocimaptest" -d \
|
||||
-p 2525:25 -p 587:587 -p 993:993 \
|
||||
docker run --name="ncimaptest" -d \
|
||||
-p 993:993 \
|
||||
-e POSTFIX_HOSTNAME=mail.domain.tld $(docker_image)
|
||||
|
||||
start-smtp-docker:
|
||||
docker pull catatnight/postfix
|
||||
docker run --name="ncsmtptest" -d \
|
||||
-e maildomain=domain.tld \
|
||||
-e smtp_user=user@domain.tld:mypassword \
|
||||
-p 2525:25 \
|
||||
catatnight/postfix
|
||||
|
||||
add-imap-account:
|
||||
docker exec -it ocimaptest /opt/bin/useradd $(mail_user) $(mail_pwd)
|
||||
docker exec -it ncimaptest /opt/bin/useradd $(mail_user) $(mail_pwd)
|
||||
|
||||
update-composer: composer.phar
|
||||
rm -f composer.lock
|
||||
|
|
|
@ -32,35 +32,35 @@ use PHPUnit_Framework_TestCase;
|
|||
|
||||
class MailTransmissionIntegrationTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
/** @var ICrypto */
|
||||
private $crypo;
|
||||
|
||||
/** @var Account */
|
||||
private $account;
|
||||
|
||||
/** @var IMailTransmission */
|
||||
private $transmission;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->crypo = OC::$server->getCrypto();
|
||||
$crypo = OC::$server->getCrypto();
|
||||
$this->account = new Account(MailAccount::fromParams([
|
||||
'email' => 'user@domain.tld',
|
||||
'inboundHost' => 'localhost',
|
||||
'inboundPort' => '993',
|
||||
'inboundSslMode' => 'ssl',
|
||||
'inboundUser' => 'user@domain.tld',
|
||||
'inboundPassword' => $crypo->encrypt('mypassword'),
|
||||
'outboundHost' => 'localhost',
|
||||
'outboundPort' => '2525',
|
||||
'outboundSslMode' => 'none',
|
||||
'outboundUser' => 'user@domain.tld',
|
||||
'outboundPassword' => $crypo->encrypt('mypassword'),
|
||||
]));
|
||||
$this->transmission = OC::$server->query(IMailTransmission::class);
|
||||
}
|
||||
|
||||
public function testSendMail() {
|
||||
$account = new Account(MailAccount::fromParams([
|
||||
'email' => 'user@domain.tld',
|
||||
'inboundHost' => 'localhost',
|
||||
'inboundPort' => '993',
|
||||
'inboundSslMode' => 'none',
|
||||
'inboundUser' => 'user@domain.tld',
|
||||
'inboundPassword' => $this->crypo->encrypt('mypassword'),
|
||||
'outboundHost' => 'smtp.mailtrap.io',
|
||||
'outboundPort' => '25',
|
||||
'outboundSslMode' => 'none',
|
||||
'outboundUser' => 'xxx',
|
||||
'outboundPassword' => $this->crypo->encrypt('xxx'),
|
||||
]));
|
||||
$message = NewMessageData::fromRequest($account, 'recipient@domain.com', null, null, 'greetings', 'hello there', []);
|
||||
$reply = new RepliedMessageData($account, null, null);
|
||||
$message = NewMessageData::fromRequest($this->account, 'recipient@domain.com', null, null, 'greetings', 'hello there', []);
|
||||
$reply = new RepliedMessageData($this->account, null, null);
|
||||
$this->transmission->sendMessage($message, $reply);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче