public void CanChangeConnectionSettingsOnClientPermission()
        {
            MySqlConnection       dummyconn      = new MySqlConnection();
            PermissionSet         permissionsSet = new PermissionSet(PermissionState.None);
            MySqlClientPermission permission     = new MySqlClientPermission(PermissionState.None);

            // Allow only server localhost, any database, only with root user
            permission.Add("server=localhost;", "database=; user id=root;", KeyRestrictionBehavior.PreventUsage);
            permissionsSet.AddPermission(permission);
            permissionsSet.PermitOnly();
            dummyconn.ConnectionString = "server=localhost; user id=test;includesecurityasserts=true;";
            dummyconn.Open();
            if (dummyconn.State == ConnectionState.Open)
            {
                dummyconn.Close();
            }
        }
        public void CanDenyConnectionAfterPermitOnlyPermission()
        {
            PermissionSet permissionset = new PermissionSet(PermissionState.None);

            MySqlClientPermission permission = new MySqlClientPermission(PermissionState.None);

            MySqlConnectionStringBuilder strConn = new MySqlConnectionStringBuilder(conn.ConnectionString);

            //// Allow connections only to specified database no additional optional parameters
            permission.Add("server=localhost;User Id=root; database=" + strConn.Database + ";", "", KeyRestrictionBehavior.PreventUsage);
            permission.PermitOnly();
            permissionset.AddPermission(permission);
            permissionset.Demand();

            // this connection should NOT be allowed
            MySqlConnection dummyconn = new MySqlConnection();

            dummyconn.ConnectionString = "server=localhost;User Id=root;database=test;includesecurityasserts=true;";
            dummyconn.Open();
            if (dummyconn.State == ConnectionState.Open)
            {
                dummyconn.Close();
            }
        }