test stuff
This commit is contained in:
13
test/bs.sql
Normal file
13
test/bs.sql
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
create user 'testuser'@'%' identified via pam using 'mariadb';
|
||||||
|
create database testdb;
|
||||||
|
grant all privileges on testdb.* to 'testuser'@'%';
|
||||||
|
flush privileges;
|
||||||
|
|
||||||
|
use testdb;
|
||||||
|
create table testtable (
|
||||||
|
id int primary key auto_increment,
|
||||||
|
bla varchar(32)
|
||||||
|
);
|
||||||
|
insert into testtable (bla) values('bla1');
|
||||||
|
insert into testtable (bla) values('bla2');
|
||||||
|
insert into testtable (bla) values('bla3');
|
14
test/dotnet/DatabaseTest.csproj
Normal file
14
test/dotnet/DatabaseTest.csproj
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||||
|
<ApplicationIcon />
|
||||||
|
<StartupObject>DatabaseTest.Program</StartupObject>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="MySqlConnector" Version="0.56" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
46
test/dotnet/Program.cs
Normal file
46
test/dotnet/Program.cs
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
using MySql.Data.MySqlClient;
|
||||||
|
using System;
|
||||||
|
using System.Data;
|
||||||
|
|
||||||
|
namespace DatabaseTest
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
private const string SERVER_ADDRESS = "127.0.0.1";
|
||||||
|
private const string SERVER_PORT = "3306";
|
||||||
|
private const string DATABASE_NAME = "testdb";
|
||||||
|
private const string USERNAME = "testuser";
|
||||||
|
private const string PASSWORD = "test123";
|
||||||
|
|
||||||
|
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
string connectionStr = $"Server={SERVER_ADDRESS};Port={SERVER_PORT};Database={DATABASE_NAME};Uid={USERNAME};Pwd={PASSWORD}";
|
||||||
|
|
||||||
|
MySqlConnection con = new MySqlConnection();
|
||||||
|
con.ConnectionString = connectionStr;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
con.Open();
|
||||||
|
|
||||||
|
MySqlCommand cmd = con.CreateCommand();
|
||||||
|
cmd.CommandText = "SELECT * FROM testtable";
|
||||||
|
var reader = cmd.ExecuteReader();
|
||||||
|
DataTable dt = new DataTable();
|
||||||
|
dt.Load(reader);
|
||||||
|
|
||||||
|
con.Close();
|
||||||
|
}
|
||||||
|
catch (MySqlException sqlEx)
|
||||||
|
{
|
||||||
|
Console.WriteLine(sqlEx.Message);
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine(sqlEx.InnerException?.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("Press any key to close.");
|
||||||
|
Console.ReadKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
21
test/startEnv.sh
Executable file
21
test/startEnv.sh
Executable file
@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Starting LDAP server"
|
||||||
|
docker run --name ldapserver --rm -d -p 389:389 osixia/openldap:1.2.5
|
||||||
|
|
||||||
|
echo "Wait until it settled"
|
||||||
|
sleep 10
|
||||||
|
|
||||||
|
echo "Load LDAP server"
|
||||||
|
cat bs.ldif | docker exec -i ldapserver ldapadd -x -H ldap://localhost -D "cn=admin,dc=example,dc=org" -w admin
|
||||||
|
|
||||||
|
|
||||||
|
echo "Start database server"
|
||||||
|
docker run -d --rm -e MYSQL_ROOT_PASSWORD=test123 -p 3306:3306 --name mariadb --link ldapserver registry.gitlab.com/wolutator/mariadb-with-ldap-pam:TEST-0.2-10.4
|
||||||
|
|
||||||
|
echo "Wait until it settled"
|
||||||
|
sleep 60
|
||||||
|
|
||||||
|
echo "Load database server"
|
||||||
|
cat bs.sql | docker exec -i mariadb mysql -h 127.0.0.1 -u root --password=test123 mysql
|
||||||
|
|
0
test/startLdapServer.sh
Normal file → Executable file
0
test/startLdapServer.sh
Normal file → Executable file
Reference in New Issue
Block a user