Files
nc-talk-ai/tests/unit/Service/CredentialServiceTest.php
Pascal Kienast 0739d3da6a Initial open-source release of Talk AI
Talk AI is a multi-bot AI assistant manager for Nextcloud Talk:
per-bot prompts and models, agentic tool calling (MCP + built-in
tools), RAG over Nextcloud files, room-document search, vision and
speech-to-text attachments, persistent bot wikis, approval workflows,
rate limiting, and multi-provider LLM support (any OpenAI-compatible
endpoint).

Developed within EDUC - the European Digital UniverCity
(https://educalliance.eu), where it runs as the 'EDUC AI' assistant on
the alliance-wide Nextcloud portal. This public repository is the
upstream point of truth; deployment-specific tools plug in via the
tool-provider extension point (docs/TOOL_PROVIDERS.md).

License: AGPL-3.0-or-later.
2026-07-08 21:13:13 +02:00

52 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace OCA\EducAI\Tests\Unit\Service;
use OCA\EducAI\Service\CredentialService;
use OCP\Security\ICrypto;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
class CredentialServiceTest extends TestCase {
public function testDecryptThrowsWhenEncryptedValueCannotBeDecrypted(): void {
$crypto = new class implements ICrypto {
public function encrypt($data): string {
return 'encrypted';
}
public function decrypt($data): string {
throw new \RuntimeException('bad ciphertext');
}
};
$logger = $this->createMock(LoggerInterface::class);
$logger->expects($this->never())
->method('error');
$service = new CredentialService($crypto, $logger);
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('bad ciphertext');
$service->decrypt('$ENCRYPTED$invalid');
}
public function testDecryptStillReturnsLegacyPlaintext(): void {
$crypto = new class implements ICrypto {
public function encrypt($data): string {
return 'encrypted';
}
public function decrypt($data): string {
throw new \RuntimeException('decrypt should not be called');
}
};
$service = new CredentialService($crypto, $this->createMock(LoggerInterface::class));
$this->assertSame('legacy-secret', $service->decrypt('legacy-secret'));
}
}