-
Notifications
You must be signed in to change notification settings - Fork 84
/
mod.rs
84 lines (77 loc) · 2.56 KB
/
mod.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
* Created on Wed Nov 29 2023
*
* This file is a part of Skytable
* Skytable (formerly known as TerrabaseDB or Skybase) is a free and open-source
* NoSQL database written by Sayan Nandan ("the Author") with the
* vision to provide flexibility in data modelling without compromising
* on performance, queryability or scalability.
*
* Copyright (c) 2023, Sayan Nandan <ohsayan@outlook.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
mod dcl_sec;
mod ddl_sec;
mod dml_sec;
use {
crate::engine::error::QueryError,
sky_macros::dbtest,
skytable::{
error::{ConnectionSetupError, Error},
query,
},
};
const INVALID_SYNTAX_ERR: u16 = QueryError::QLInvalidSyntax.value_u8() as u16;
const EXPECTED_STATEMENT_ERR: u16 = QueryError::QLExpectedStatement.value_u8() as u16;
const UNKNOWN_STMT_ERR: u16 = QueryError::QLUnknownStatement.value_u8() as u16;
#[dbtest]
fn deny_unknown_tokens() {
let mut db = db!();
for token in [
"model", "space", "where", "force", "into", "from", "with", "set", "add", "remove", "*",
",", "",
] {
assert_err_eq!(
db.query_parse::<()>(&query!(token)),
Error::ServerError(EXPECTED_STATEMENT_ERR),
"{token}",
);
}
}
#[dbtest(username = "root", password = "")]
fn ensure_empty_password_returns_hs_error_5() {
let db = db_connect!();
assert_err_eq!(
db,
Error::ConnectionSetupErr(ConnectionSetupError::HandshakeError(5))
);
}
#[dbtest(username = "", password = "1234567890")]
fn ensure_empty_username_returns_hs_error_5() {
let db = db_connect!();
assert_err_eq!(
db,
Error::ConnectionSetupErr(ConnectionSetupError::HandshakeError(5))
);
}
#[dbtest(username = "", password = "")]
fn ensure_empty_username_and_password_returns_hs_error_5() {
let db = db_connect!();
assert_err_eq!(
db,
Error::ConnectionSetupErr(ConnectionSetupError::HandshakeError(5))
);
}