summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/001_create_database.pp4
-rw-r--r--tests/010_create_user.pp7
-rw-r--r--tests/012_change_password.pp6
-rw-r--r--tests/100_create_user_grant.pp9
-rw-r--r--tests/101_remove_user_privilege.pp8
-rw-r--r--tests/102_add_user_privilege.pp8
-rw-r--r--tests/103_change_user_grant.pp8
-rw-r--r--tests/104_mix_user_grants.pp8
-rw-r--r--tests/150_create_db_grant.pp9
-rw-r--r--tests/151_remove_db_privilege.pp8
-rw-r--r--tests/152_add_db_privilege.pp8
-rw-r--r--tests/153_change_db_priv.pp8
-rw-r--r--tests/154_mix_db_grants.pp8
-rw-r--r--tests/200_give_all_user_privs.pp8
-rw-r--r--tests/201_give_all_db_privs.pp8
-rw-r--r--tests/996_remove_db_grant.pp5
-rw-r--r--tests/997_remove_user_grant.pp5
-rw-r--r--tests/998_remove_user.pp3
-rw-r--r--tests/999_remove_database.pp3
-rw-r--r--tests/README6
-rwxr-xr-xtests/run_tests13
21 files changed, 150 insertions, 0 deletions
diff --git a/tests/001_create_database.pp b/tests/001_create_database.pp
new file mode 100644
index 0000000..4e489cc
--- /dev/null
+++ b/tests/001_create_database.pp
@@ -0,0 +1,4 @@
+
+err("Will create 'test_db'")
+mysql_database { "test_db": ensure => present }
+
diff --git a/tests/010_create_user.pp b/tests/010_create_user.pp
new file mode 100644
index 0000000..a45ed5b
--- /dev/null
+++ b/tests/010_create_user.pp
@@ -0,0 +1,7 @@
+
+err("Will create user 'test_user@%' with password 'blah'")
+
+mysql_user{ "test_user@%":
+ password_hash => mysql_password("blah"),
+ ensure => present
+}
diff --git a/tests/012_change_password.pp b/tests/012_change_password.pp
new file mode 100644
index 0000000..7bf7f02
--- /dev/null
+++ b/tests/012_change_password.pp
@@ -0,0 +1,6 @@
+
+err("Changing password for user 'test_user@%'")
+mysql_user{ "test_user@%":
+ password_hash => mysql_password("foo"),
+ ensure => present
+}
diff --git a/tests/100_create_user_grant.pp b/tests/100_create_user_grant.pp
new file mode 100644
index 0000000..1d3dca8
--- /dev/null
+++ b/tests/100_create_user_grant.pp
@@ -0,0 +1,9 @@
+err("Grant SELECT, INSERT and UPDATE to test_user@%")
+
+mysql_grant {
+ "test_user@%":
+ privileges => [ "select_priv", 'insert_priv', 'update_priv' ],
+ tag => test;
+}
+
+
diff --git a/tests/101_remove_user_privilege.pp b/tests/101_remove_user_privilege.pp
new file mode 100644
index 0000000..6b7029e
--- /dev/null
+++ b/tests/101_remove_user_privilege.pp
@@ -0,0 +1,8 @@
+err("Revoke UPDATE from test_user@%")
+
+mysql_grant {
+ "test_user@%":
+ privileges => [ "select_priv", 'insert_priv' ],
+}
+
+
diff --git a/tests/102_add_user_privilege.pp b/tests/102_add_user_privilege.pp
new file mode 100644
index 0000000..849cd3a
--- /dev/null
+++ b/tests/102_add_user_privilege.pp
@@ -0,0 +1,8 @@
+err("Grant DELETE to test_user@%")
+
+mysql_grant {
+ "test_user@%":
+ privileges => [ "select_priv", 'insert_priv', 'delete_priv' ],
+}
+
+
diff --git a/tests/103_change_user_grant.pp b/tests/103_change_user_grant.pp
new file mode 100644
index 0000000..fa860a3
--- /dev/null
+++ b/tests/103_change_user_grant.pp
@@ -0,0 +1,8 @@
+err("Replace DELETE with UPDATE grant for test_user@%")
+
+mysql_grant {
+ "test_user@%":
+ privileges => [ "select_priv", 'insert_priv', 'update_priv' ],
+}
+
+
diff --git a/tests/104_mix_user_grants.pp b/tests/104_mix_user_grants.pp
new file mode 100644
index 0000000..d0dc512
--- /dev/null
+++ b/tests/104_mix_user_grants.pp
@@ -0,0 +1,8 @@
+err("Change the order of the defined privileges")
+
+mysql_grant {
+ "test_user@%":
+ privileges => [ "update_priv", 'insert_priv', 'select_priv' ],
+}
+
+
diff --git a/tests/150_create_db_grant.pp b/tests/150_create_db_grant.pp
new file mode 100644
index 0000000..597993d
--- /dev/null
+++ b/tests/150_create_db_grant.pp
@@ -0,0 +1,9 @@
+err("Create a db grant")
+
+mysql_grant {
+ "test_user@%test_db":
+ privileges => [ "select_priv", 'insert_priv', 'update_priv' ],
+ tag => test;
+}
+
+
diff --git a/tests/151_remove_db_privilege.pp b/tests/151_remove_db_privilege.pp
new file mode 100644
index 0000000..da3246f
--- /dev/null
+++ b/tests/151_remove_db_privilege.pp
@@ -0,0 +1,8 @@
+err("Revoke UPDATE from test_user@%test_db")
+
+mysql_grant {
+ "test_user@%test_db":
+ privileges => [ "select_priv", 'insert_priv'],
+}
+
+
diff --git a/tests/152_add_db_privilege.pp b/tests/152_add_db_privilege.pp
new file mode 100644
index 0000000..6dd00d1
--- /dev/null
+++ b/tests/152_add_db_privilege.pp
@@ -0,0 +1,8 @@
+err("Grant DELETE to test_user@%test_db")
+
+mysql_grant {
+ "test_user@%test_db":
+ privileges => [ "select_priv", 'insert_priv', 'delete_priv'],
+}
+
+
diff --git a/tests/153_change_db_priv.pp b/tests/153_change_db_priv.pp
new file mode 100644
index 0000000..f72dab8
--- /dev/null
+++ b/tests/153_change_db_priv.pp
@@ -0,0 +1,8 @@
+err("Change DELETE to UPDATE privilege for test_user@%test_db")
+
+mysql_grant {
+ "test_user@%test_db":
+ privileges => [ "select_priv", 'insert_priv', 'update_priv'],
+}
+
+
diff --git a/tests/154_mix_db_grants.pp b/tests/154_mix_db_grants.pp
new file mode 100644
index 0000000..408308f
--- /dev/null
+++ b/tests/154_mix_db_grants.pp
@@ -0,0 +1,8 @@
+err("Change privilege order")
+
+mysql_grant {
+ "test_user@%test_db":
+ privileges => [ "update_priv", 'insert_priv', 'select_priv'],
+}
+
+
diff --git a/tests/200_give_all_user_privs.pp b/tests/200_give_all_user_privs.pp
new file mode 100644
index 0000000..cb59c8d
--- /dev/null
+++ b/tests/200_give_all_user_privs.pp
@@ -0,0 +1,8 @@
+err("Grant ALL to test_user@%")
+
+mysql_grant {
+ "test_user@%":
+ privileges => all
+}
+
+
diff --git a/tests/201_give_all_db_privs.pp b/tests/201_give_all_db_privs.pp
new file mode 100644
index 0000000..745048f
--- /dev/null
+++ b/tests/201_give_all_db_privs.pp
@@ -0,0 +1,8 @@
+err("Grant ALL to test_user@%/test_db")
+
+mysql_grant {
+ "test_user@%/test_db":
+ privileges => all
+}
+
+
diff --git a/tests/996_remove_db_grant.pp b/tests/996_remove_db_grant.pp
new file mode 100644
index 0000000..a93c2a3
--- /dev/null
+++ b/tests/996_remove_db_grant.pp
@@ -0,0 +1,5 @@
+err("Remove the db grant")
+
+mysql_grant { "test_user@%test_db": privileges => [ ] }
+
+
diff --git a/tests/997_remove_user_grant.pp b/tests/997_remove_user_grant.pp
new file mode 100644
index 0000000..fcdc490
--- /dev/null
+++ b/tests/997_remove_user_grant.pp
@@ -0,0 +1,5 @@
+err("Removing the user grant")
+
+mysql_grant { "test_user@%": privileges => [] }
+
+
diff --git a/tests/998_remove_user.pp b/tests/998_remove_user.pp
new file mode 100644
index 0000000..649e739
--- /dev/null
+++ b/tests/998_remove_user.pp
@@ -0,0 +1,3 @@
+
+err("Removing user 'test_user@%'")
+mysql_user{ "test_user@%": ensure => absent }
diff --git a/tests/999_remove_database.pp b/tests/999_remove_database.pp
new file mode 100644
index 0000000..8a5df3e
--- /dev/null
+++ b/tests/999_remove_database.pp
@@ -0,0 +1,3 @@
+err("Will remove 'test_db'")
+mysql_database { "test_db": ensure => absent }
+
diff --git a/tests/README b/tests/README
new file mode 100644
index 0000000..7ef1421
--- /dev/null
+++ b/tests/README
@@ -0,0 +1,6 @@
+Execute these testfile in asciibetical order to check the functioning of the
+types and providers.
+
+They try to create databases, users, grants, check for their existance, change
+attributes, and remove them again.
+
diff --git a/tests/run_tests b/tests/run_tests
new file mode 100755
index 0000000..1ae6c42
--- /dev/null
+++ b/tests/run_tests
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+export RUBYLIB=${RUBYLIB:-../plugins}
+OPTIONS="$*"
+OPTIONS="${OPTIONS:---trace}"
+
+find -iname \*.pp | sort | while read current; do
+ echo "Running $current"
+ puppet $OPTIONS $current
+ echo "Running $current again"
+ puppet $OPTIONS $current
+ echo
+done