surrealdb / surrealdb.net

SurrealDB SDK for .NET
https://surrealdb.com
Apache License 2.0
95 stars 19 forks source link

Bug: Building Connection string fails on namespace auth when reading data. #152

Open AdaptGit opened 2 days ago

AdaptGit commented 2 days ago

Describe the bug

Building a connection string fails when reading, inserting or creating only when using a namespace auth. this use to work in the version 0.5.1. however doesn't work in the latest.

further to this the same connection details can be used to login via the sign in method and this works to read data.

Steps to reproduce

to reproduce this bug create a connection string to database with a namespace authentication method and read some data. This will result in there was a problem with the database and a problem with authentication, this authentication can be used on a sign method check test case below:

` var surrealDbClient = new SurrealDbClient(SurrealDbOptions .Create() .WithEndpoint("ws://127.0.0.1:8000/rpc") .WithNamespace("Name") .WithDatabase("db") .WithUsername("Name_space") .WithPassword("root") .Build() ); var db = new SurrealDbClient("ws://127.0.0.1:8000/rpc"); await db.Connect(); await db.Use("Namespace", "db"); var namespaceAuth = new NamespaceAuth { Namespace = "Name", Username = "Name_space", Password = "root" }; await db.SignIn(namespaceAuth);

        var getResult = await db.RawQuery("Select * from 1");
        Assert.IsFalse(getResult.HasErrors);

        var result = await surrealDbClient.RawQuery("Select * from 1");
        Assert.IsFalse(result.HasErrors);

`

Screenshot 2024-11-23 at 10 34 59 AM Screenshot 2024-11-23 at 10 35 46 AM

Expected behaviour

this should work like the signin method, allowing access to the database and to read the data.

SurrealDB version

Running 2.1.0 for macos on aarch64

Package version(s)

<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
<PackageReference Include="NUnit.Analyzers" Version="3.6.1" />
<PackageReference Include="coverlet.collector" Version="3.2.0" />
<PackageReference Include="SurrealDb.Net" Version="0.6.0" />

Contact Details

No response

Is there an existing issue for this?

  • [X] I have searched the existing issues

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct
Odonno commented 1 day ago

I am not sure to see where the issue lies here.

Some reviews about the code example you provided:

From what I can see in your error output, it is the SignIn method call using the surrealDbClient client that fails. It means that root authentication fails.

Are you sure this is the intended purpose?

AdaptGit commented 21 hours ago

Hi @Odonno

I wrote this to show the difference between both connection methods and results. (probably should of explained it better in the code.)

further to this i'm able to connect via surrealist using namespace auth.

let me know if i need to provide any extra details if required