MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / test_authentication

Function test_authentication

graphlite/tests/security_role_user_tests.rs:242–273  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

240
241#[test]
242fn test_authentication() {
243 let fixture = TestFixture::empty().expect("Failed to create test fixture");
244
245 // Create a test user
246 let if_not_exists_result =
247 fixture.query("CREATE USER IF NOT EXISTS 'authtest' PASSWORD 'testpass123'");
248 if if_not_exists_result.is_err() {
249 fixture.assert_query_succeeds("CREATE USER 'authtest' PASSWORD 'testpass123'");
250 }
251
252 // Test authentication procedure
253 let auth_result = fixture.query("CALL gql.authenticate_user('authtest', 'testpass123')");
254 if let Ok(result) = auth_result {
255 // Verify the result structure
256 assert!(
257 !result.rows.is_empty(),
258 "Authentication should return user info"
259 );
260
261 // Test invalid password
262 fixture.assert_query_fails(
263 "CALL gql.authenticate_user('authtest', 'wrongpass')",
264 "Authentication failed",
265 );
266
267 // Test non-existent user
268 fixture.assert_query_fails(
269 "CALL gql.authenticate_user('nonexistent', 'anypass')",
270 "Authentication failed",
271 );
272 }
273}
274
275#[test]
276fn test_security_edge_cases() {

Callers

nothing calls this directly

Calls 3

queryMethod · 0.45
assert_query_succeedsMethod · 0.45
assert_query_failsMethod · 0.45

Tested by

no test coverage detected