def test_user_update_encrypted_passwd(self): postgres.user_update( 'test_username', user='******', host='test_host', port='test_port', maintenance_db='test_maint', password='******', createdb=False, createroles=True, createuser=False, encrypted=True, inherit=True, login=True, rolepassword='******', replication=False, groups='test_groups', runas='foo' ) call_output = postgres._run_psql.call_args[0][0] self.assertTrue( re.match( '/usr/bin/pgsql --no-align --no-readline --no-password ' '--username test_user ' '--host test_host --port test_port --dbname test_maint ' '-c [\'"]{0,1}ALTER ROLE (\\\\)?"test_username(\\\\)?" WITH INHERIT NOCREATEDB ' 'CREATEROLE NOREPLICATION LOGIN ' 'ENCRYPTED PASSWORD ' '[\'"]{0,5}md531c27e68d3771c392b52102c01be1da1[\'"]{0,5}' '; GRANT (\\\\)?"test_groups(\\\\)?" TO (\\\\)?"test_username(\\\\)?"[\'"]{0,1}', call_output) )
def test_user_update_encrypted_passwd(self): postgres.user_update('test_username', user='******', host='test_host', port='test_port', maintenance_db='test_maint', password='******', createdb=False, createroles=True, createuser=False, encrypted=True, inherit=True, login=True, rolepassword='******', replication=False, groups='test_groups', runas='foo') # postgres._run_psql.call_args[0][0] will contain the list of CLI args. # The first 13 elements of this list are initial args used in all (or # virtually all) commands run through _run_psql(), so the actual SQL # query will be in the 14th argument. self.assertTrue( re.match( 'ALTER ROLE "test_username" WITH INHERIT NOCREATEDB ' 'CREATEROLE NOREPLICATION LOGIN ' 'ENCRYPTED PASSWORD ' '[\'"]{0,5}md531c27e68d3771c392b52102c01be1da1[\'"]{0,5}' '; GRANT "test_groups" TO "test_username"', postgres._run_psql.call_args[0][0][13]))
def test_user_update_encrypted_passwd(self): postgres.user_update('test_username', user='******', host='test_host', port='test_port', maintenance_db='test_maint', password='******', createdb=False, createroles=True, createuser=False, encrypted=True, inherit=True, login=True, rolepassword='******', replication=False, groups='test_groups', runas='foo') call_output = postgres._run_psql.call_args[0][0] self.assertTrue( re.match( '/usr/bin/pgsql --no-align --no-readline --no-password ' '--username test_user ' '--host test_host --port test_port --dbname test_maint ' '-c [\'"]{0,1}ALTER ROLE (\\\\)?"test_username(\\\\)?" WITH INHERIT NOCREATEDB ' 'CREATEROLE NOREPLICATION LOGIN ' 'ENCRYPTED PASSWORD ' '[\'"]{0,5}md531c27e68d3771c392b52102c01be1da1[\'"]{0,5}' '; GRANT (\\\\)?"test_groups(\\\\)?" TO (\\\\)?"test_username(\\\\)?"[\'"]{0,1}', call_output))
def test_user_update3(self): postgres.user_update( 'test_username', user='******', host='test_host', port='test_port', maintenance_db='test_maint', password='******', createdb=False, createroles=True, createuser=False, encrypted=False, inherit=True, login=True, rolepassword=False, replication=False, groups='test_groups', runas='foo' ) call_output = postgres._run_psql.call_args[0][0] self.assertTrue( re.match( '/usr/bin/pgsql --no-align --no-readline --no-password ' '--username test_user ' '--host test_host --port test_port --dbname test_maint ' '-c \'ALTER ROLE "test_username" WITH INHERIT NOCREATEDB ' 'CREATEROLE NOREPLICATION LOGIN NOPASSWORD;' ' GRANT "test_groups" TO "test_username"\'', call_output) )
def test_user_update3(self): postgres.user_update('test_username', user='******', host='test_host', port='test_port', maintenance_db='test_maint', password='******', createdb=False, createroles=True, createuser=False, encrypted=False, inherit=True, login=True, rolepassword=False, replication=False, groups='test_groups', runas='foo') call_output = postgres._run_psql.call_args[0][0] self.assertTrue( re.match( '/usr/bin/pgsql --no-align --no-readline --no-password ' '--username test_user ' '--host test_host --port test_port --dbname test_maint ' '-c \'ALTER ROLE "test_username" WITH INHERIT NOCREATEDB ' 'CREATEROLE NOREPLICATION LOGIN NOPASSWORD;' ' GRANT "test_groups" TO "test_username"\'', call_output))
def test_user_update_encrypted_passwd(self): postgres.user_update( 'test_username', user='******', host='test_host', port='test_port', maintenance_db='test_maint', password='******', createdb=False, createroles=True, createuser=False, encrypted=True, inherit=True, login=True, rolepassword='******', replication=False, groups='test_groups', runas='foo' ) # postgres._run_psql.call_args[0][0] will contain the list of CLI args. # The first 13 elements of this list are initial args used in all (or # virtually all) commands run through _run_psql(), so the actual SQL # query will be in the 14th argument. self.assertTrue( re.match( 'ALTER ROLE "test_username" WITH INHERIT NOCREATEDB ' 'CREATEROLE NOREPLICATION LOGIN ' 'ENCRYPTED PASSWORD ' '[\'"]{0,5}md531c27e68d3771c392b52102c01be1da1[\'"]{0,5}' '; GRANT "test_groups" TO "test_username"', postgres._run_psql.call_args[0][0][13] ) )
def test_user_update(self): postgres.user_update('test_username', user='******', host='test_host', port='test_port', maintenance_db='test_maint', password='******', createdb=False, createroles=False, createuser=False, encrypted=False, inherit=True, login=True, replication=False, rolepassword='******', groups='test_groups', runas='foo') self.assertTrue( re.match( '/usr/bin/pgsql --no-align --no-readline --username test_user ' '--host test_host --port test_port --dbname test_maint ' '-c [\'"]{0,1}ALTER ROLE test_username WITH INHERIT NOCREATEDB ' 'NOCREATEROLE NOSUPERUSER NOREPLICATION LOGIN ' 'UNENCRYPTED PASSWORD [\'"]{0,5}test_role_pass[\'"]{0,5};' ' GRANT test_groups TO test_username[\'"]{0,1}', postgres._run_psql.call_args[0][0]))
def test_user_update(self): postgres.user_update( 'test_username', user='******', host='test_host', port='test_port', maintenance_db='test_maint', password='******', createdb=False, createroles=False, createuser=False, encrypted=False, inherit=True, login=True, replication=False, rolepassword='******', groups='test_groups', runas='foo' ) self.assertTrue( re.match( '/usr/bin/pgsql --no-align --no-readline --no-password --username test_user ' '--host test_host --port test_port --dbname test_maint ' '-c [\'"]{0,1}ALTER ROLE test_username WITH INHERIT NOCREATEDB ' 'NOCREATEROLE NOREPLICATION LOGIN ' 'UNENCRYPTED PASSWORD [\'"]{0,5}test_role_pass[\'"]{0,5};' ' GRANT test_groups TO test_username[\'"]{0,1}', postgres._run_psql.call_args[0][0]) )
def test_user_update_encrypted_passwd(self): postgres.user_update( 'test_username', user='******', host='test_host', port='test_port', maintenance_db='test_maint', password='******', createdb=False, createroles=True, createuser=False, encrypted=True, inherit=True, login=True, rolepassword='******', replication=False, groups='test_groups', runas='foo' ) self.assertTrue( re.match( '/usr/bin/pgsql --no-align --no-readline --username test_user ' '--host test_host --port test_port --dbname test_maint ' '-c \'ALTER ROLE test_username WITH INHERIT NOCREATEDB ' 'CREATEROLE NOSUPERUSER NOREPLICATION LOGIN ' 'ENCRYPTED PASSWORD ' '\'"\'"\'md531c27e68d3771c392b52102c01be1da1\'"\'"\'' '; GRANT test_groups TO test_username\'', postgres._run_psql.call_args[0][0]) )