Use a decent SMTP docker image to test against

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
Christoph Wurst 2017-08-02 08:15:41 +02:00
Родитель 6b23904459
Коммит 3616fc0b93
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: CC42AC2A7F0E56D8
3 изменённых файлов: 31 добавлений и 22 удалений

Просмотреть файл

@ -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/

Просмотреть файл

@ -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);
}