Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
picodata
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
picodata
Commits
5469da31
Commit
5469da31
authored
1 year ago
by
Georgy Moshkin
Browse files
Options
Downloads
Patches
Plain Diff
fix: picodata connect --auth-type=ldap
parent
212776a0
No related branches found
No related tags found
1 merge request
!847
Gmoshkin/connect ldap
Pipeline
#32189
failed
1 year ago
Stage: build-base-image
Stage: test
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
docker-build-base/Dockerfile
+6
-0
6 additions, 0 deletions
docker-build-base/Dockerfile
src/cli/connect.rs
+1
-0
1 addition, 0 deletions
src/cli/connect.rs
test/int/test_cli_connect.py
+110
-0
110 additions, 0 deletions
test/int/test_cli_connect.py
with
117 additions
and
0 deletions
docker-build-base/Dockerfile
+
6
−
0
View file @
5469da31
...
@@ -43,3 +43,9 @@ RUN curl -SLO https://deb.nodesource.com/nsolid_setup_deb.sh && \
...
@@ -43,3 +43,9 @@ RUN curl -SLO https://deb.nodesource.com/nsolid_setup_deb.sh && \
apt-get
install
nodejs
&&
\
apt-get
install
nodejs
&&
\
corepack
enable
&&
\
corepack
enable
&&
\
apt-get clean all
apt-get clean all
# install glauth for ldap tests
RUN
set
-e
;
\
cd
/bin
;
\
curl
-L
-o
glauth https://github.com/glauth/glauth/releases/download/v2.3.0/glauth-linux-amd64
;
\
chmod
+x glauth
;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/cli/connect.rs
+
1
−
0
View file @
5469da31
...
@@ -121,6 +121,7 @@ fn sql_repl(args: args::Connect) -> Result<(), ReplError> {
...
@@ -121,6 +121,7 @@ fn sql_repl(args: args::Connect) -> Result<(), ReplError> {
let
mut
config
=
Config
::
default
();
let
mut
config
=
Config
::
default
();
config
.creds
=
Some
((
user
,
password
));
config
.creds
=
Some
((
user
,
password
));
config
.auth_method
=
args
.auth_method
;
let
client
=
::
tarantool
::
fiber
::
block_on
(
Client
::
connect_with_config
(
let
client
=
::
tarantool
::
fiber
::
block_on
(
Client
::
connect_with_config
(
&
address
.host
,
&
address
.host
,
...
...
This diff is collapsed.
Click to expand it.
test/int/test_cli_connect.py
+
110
−
0
View file @
5469da31
import
pexpect
# type: ignore
import
pexpect
# type: ignore
import
pytest
import
pytest
import
sys
import
sys
import
subprocess
import
hashlib
import
socket
import
time
from
conftest
import
Cluster
,
Instance
,
eprint
from
conftest
import
Cluster
,
Instance
,
eprint
from
dataclasses
import
dataclass
@pytest.fixture
@pytest.fixture
...
@@ -175,6 +180,111 @@ def test_connect_auth_type_md5(i1: Instance):
...
@@ -175,6 +180,111 @@ def test_connect_auth_type_md5(i1: Instance):
cli
.
expect_exact
(
"
picosql :)
"
)
cli
.
expect_exact
(
"
picosql :)
"
)
@dataclass
class
LDAPServerState
:
host
:
str
port
:
int
process
:
subprocess
.
Popen
def
configure_ldap_server
(
username
,
password
,
data_dir
)
->
LDAPServerState
:
# Check `glauth` executable is available
subprocess
.
Popen
([
"
glauth
"
,
"
--version
"
])
LDAP_SERVER_HOST
=
"
127.0.0.1
"
LDAP_SERVER_PORT
=
1389
ldap_cfg_path
=
f
"
{
data_dir
}
/ldap.cfg
"
with
open
(
ldap_cfg_path
,
"
x
"
)
as
f
:
password_sha256
=
hashlib
.
sha256
(
password
.
encode
(
"
utf8
"
)).
hexdigest
()
f
.
write
(
f
"""
[ldap]
enabled = true
listen =
"
{
LDAP_SERVER_HOST
}
:
{
LDAP_SERVER_PORT
}
"
[ldaps]
enabled = false
[backend]
datastore =
"
config
"
baseDN =
"
dc=example,dc=org
"
[[users]]
name =
"
{
username
}
"
uidnumber = 5001
primarygroup = 5501
passsha256 =
"
{
password_sha256
}
"
[[users.capabilities]]
action =
"
search
"
object =
"
*
"
[[groups]]
name =
"
ldapgroup
"
gidnumber = 5501
"""
)
process
=
subprocess
.
Popen
([
"
glauth
"
,
"
-c
"
,
ldap_cfg_path
])
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
deadline
=
time
.
time
()
+
3
while
deadline
>
time
.
time
():
try
:
sock
.
connect
((
LDAP_SERVER_HOST
,
LDAP_SERVER_PORT
))
break
except
ConnectionRefusedError
:
time
.
sleep
(
0.1
)
return
LDAPServerState
(
host
=
LDAP_SERVER_HOST
,
port
=
LDAP_SERVER_PORT
,
process
=
process
)
def
test_connect_auth_type_ldap
(
cluster
:
Cluster
):
username
=
"
ldapuser
"
password
=
"
ldappass
"
ldap_server
=
configure_ldap_server
(
username
,
password
,
cluster
.
data_dir
)
try
:
#
# Configure the instance
#
i1
=
cluster
.
add_instance
(
wait_online
=
False
)
i1
.
env
[
"
TT_LDAP_URL
"
]
=
f
"
ldap://
{
ldap_server
.
host
}
:
{
ldap_server
.
port
}
"
i1
.
env
[
"
TT_LDAP_DN_FMT
"
]
=
"
cn=$USER,dc=example,dc=org
"
i1
.
start
()
i1
.
wait_online
()
i1
.
sql
(
f
"""
CREATE USER
"
{
username
}
"
PASSWORD
'
{
password
}
'
USING ldap
"""
)
#
# Try connecting
#
cli
=
pexpect
.
spawn
(
command
=
i1
.
binary_path
,
args
=
[
"
connect
"
,
f
"
{
i1
.
host
}
:
{
i1
.
port
}
"
,
"
-u
"
,
username
,
"
-a
"
,
"
ldap
"
],
encoding
=
"
utf-8
"
,
timeout
=
1
,
)
cli
.
logfile
=
sys
.
stdout
cli
.
expect_exact
(
f
"
Enter password for
{
username
}
:
"
)
cli
.
sendline
(
password
)
cli
.
expect_exact
(
"
picosql :)
"
)
finally
:
ldap_server
.
process
.
kill
()
def
test_connect_auth_type_unknown
(
binary_path
:
str
):
def
test_connect_auth_type_unknown
(
binary_path
:
str
):
cli
=
pexpect
.
spawn
(
cli
=
pexpect
.
spawn
(
command
=
binary_path
,
command
=
binary_path
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment