Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0e31950cb411
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 03212a7f0324
Choose a head ref
  • 3 commits
  • 1 file changed
  • 1 contributor

Commits on Dec 28, 2019

  1. nixosTests.mysql: add missing () to start_all()

    Because mysql.wait_for_unit() starts the vm as well, we didn't notice
    that.
    flokli committed Dec 28, 2019
    Copy the full SHA
    7d64f7a View commit details
  2. nixosTests.mysql: add additional test{db,user}2

    Test that other users are not able to access the mysql database, and
    unix socket auth actually works.
    flokli committed Dec 28, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    bf7841a View commit details

Commits on Jan 2, 2020

  1. Merge pull request #76606 from flokli/mysql-tests

    nixosTests.mysql: add more tests
    flokli authored Jan 2, 2020
    Copy the full SHA
    03212a7 View commit details
Showing with 16 additions and 2 deletions.
  1. +16 −2 nixos/tests/mysql.nix
18 changes: 16 additions & 2 deletions nixos/tests/mysql.nix
Original file line number Diff line number Diff line change
@@ -27,27 +27,33 @@ import ./make-test-python.nix ({ pkgs, ...} : {

{
users.users.testuser = { };
users.users.testuser2 = { };
services.mysql.enable = true;
services.mysql.initialScript = pkgs.writeText "mariadb-init.sql" ''
ALTER USER root@localhost IDENTIFIED WITH unix_socket;
DELETE FROM mysql.user WHERE password = ''' AND plugin = ''';
DELETE FROM mysql.user WHERE user = ''';
FLUSH PRIVILEGES;
'';
services.mysql.ensureDatabases = [ "testdb" ];
services.mysql.ensureDatabases = [ "testdb" "testdb2" ];
services.mysql.ensureUsers = [{
name = "testuser";
ensurePermissions = {
"testdb.*" = "ALL PRIVILEGES";
};
} {
name = "testuser2";
ensurePermissions = {
"testdb2.*" = "ALL PRIVILEGES";
};
}];
services.mysql.package = pkgs.mariadb;
};

};

testScript = ''
start_all
start_all()
mysql.wait_for_unit("mysql")
mysql.succeed("echo 'use empty_testdb;' | mysql -u root")
@@ -62,6 +68,14 @@ import ./make-test-python.nix ({ pkgs, ...} : {
mariadb.succeed(
"echo 'use testdb; insert into tests values (42);' | sudo -u testuser mysql -u testuser"
)
# Ensure testuser2 is not able to insert into testdb as mysql testuser2
mariadb.fail(
"echo 'use testdb; insert into tests values (23);' | sudo -u testuser2 mysql -u testuser2"
)
# Ensure testuser2 is not able to authenticate as mysql testuser
mariadb.fail(
"echo 'use testdb; insert into tests values (23);' | sudo -u testuser2 mysql -u testuser"
)
mariadb.succeed(
"echo 'use testdb; select test_id from tests;' | sudo -u testuser mysql -u testuser -N | grep 42"
)