import testsuite.BaseTestCase;

import java.sql.Connection;
import java.sql.DriverManager;

import com.mysql.jdbc.Driver;
import com.mysql.jdbc.ConnectionImpl;
import java.sql.SQLException;

public class bug37570 extends BaseTestCase {
	
	public bug37570(String name) {
		super(name);
	}

	public static void main(String[] args) {
		junit.textui.TestRunner.run(bug37570.class);
	}

	public void testBug37570() throws Exception {
		try {
			String unicodePassword = "абв"; // Cyrillic string
			String user = "bug37570";
			this.stmt.executeUpdate("SET NAMES utf8");
			this.stmt.executeUpdate("grant usage on *.* to '" + user + "'@'127.0.0.1' identified by 'foo'");
			this.stmt.executeUpdate("update mysql.user set password=PASSWORD('"+ unicodePassword +"') where user = '" + user + "'");
			this.stmt.executeUpdate("flush privileges");
			
			try {
				((ConnectionImpl)this.conn).changeUser(user, unicodePassword);
			} catch (SQLException sqle) {
				assertTrue("Connection with non-latin1 password failed", false);
			}
		} finally {
	    	closeMemberJDBCResources();
		}
	}
	
}