Closed kekefreedog closed 1 year ago
That's, strange, I'm using authentication with database path and it's working oO, I need to investigate first before merging your PR đŸ¤•
I can't merge your code as it breaks the code:
"E:\Program Files (x86)\php8\8.1\php.exe" E:\wamp\www\phpfastcache\tests\Mongodb.test.php
[Begin Test: Mongodb driver]
[PHPFASTCACHE: CORE v9.1.2#c2dfc471 | API v4.2.0]
[PHP v8.1.7 with: apcu, bcmath, calendar, Core, couchbase, ctype, curl, date, dom, fileinfo, filter, gd, gettext, grpc, hash, iconv, json, libxml, mbstring, memcached, mongodb, mysqlnd, openssl, pcre, PDO, pdo_mysql, pdo_sqlite, Phar, readline, redis, Reflection, session, SimpleXML, SPL, standard, tokenizer, xml, xmlreader, xmlwriter, zip, zlib]
---
"mongodb://travis:test@127.0.0.1:27017"
[SKIP] A driver could not be initialized due to network/authentication issue: (MongoDB\Driver\Exception\AuthenticationException) Mongodb failed to connect with the following error message: "Authentication failed." line 120 in E:\wamp\www\phpfastcache\vendor\mongodb\mongodb\src\Command\ListCollections.php
Test results: 0 assertions failed, 1 assertion skipped and 0 assertions passed out of a total of 1 assertion.
Test duration: 0.159s
Process finished with exit code 2
Removing the path actually break the code. Can you provide me more information about you Phpfastcache configuration and composer.lock ?
Current working code in tests/Mongodb.test.php as per official Mongodb Doc
<?php
/**
*
* This file is part of Phpfastcache.
*
* @license MIT License (MIT)
*
* For full copyright and license information, please see the docs/CREDITS.txt and LICENCE files.
*
* @author Georges.L (Geolim4) <contact@geolim4.com>
* @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors
*/
use Phpfastcache\CacheManager;
use Phpfastcache\Drivers\Mongodb\Config;
use Phpfastcache\Exceptions\PhpfastcacheDriverCheckException;
use Phpfastcache\Tests\Helper\TestHelper;
chdir(__DIR__);
require_once __DIR__ . '/../vendor/autoload.php';
$testHelper = new TestHelper('Mongodb driver');
$config = new Config();
$config->setItemDetailedDate(true)
->setDatabaseName('pfc_test')
->setCollectionName('pfc_' . str_pad('0', 3, random_int(1, 100)))
->setUsername('travis')
->setPassword('test');
$cacheInstance = CacheManager::getInstance('Mongodb', $config);
$testHelper->runCRUDTests($cacheInstance);
$testHelper->terminateTest();
Hello Georges.L,
Thank you for your qui response. I'm using Mongo into docker container, I will try to change port and host and test again.
We keep in touch !
Hello @kekefreedog is your issue solved in an other way ?
Problem
When I use mongodb driver with bellow config I have error log :
Authentification failed
Solution
Proposed changes
I discover the issue was link to buildConnectionURI, the method return
mongodb://admin:password@127.0.0.1/myapp
, whereas I'm waiting this :mongodb://user:password@164.152.09.84:27017
(this second option works for me)Types of changes
What types of changes does your code introduce to Phpfastcache?
Agreement
I have read the CONTRIBUTING and CODING GUIDELINE docs
Error log
The full log message :