Ejemplo n.º 1
0
 def test_user_create(self):
     postgres.user_create('testuser',
                          user='******',
                          host='testhost',
                          port='testport',
                          maintenance_db='maint_test',
                          password='******',
                          login=True,
                          createdb=False,
                          createroles=False,
                          createuser=False,
                          encrypted=False,
                          superuser=False,
                          replication=False,
                          rolepassword='******',
                          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.
     call = postgres._run_psql.call_args[0][0][13]
     self.assertTrue(re.match('CREATE ROLE "testuser"', call))
     for i in ('INHERIT NOCREATEDB NOCREATEROLE '
               'NOSUPERUSER NOREPLICATION LOGIN UNENCRYPTED PASSWORD'
               ).split():
         self.assertTrue(i in call, '{0} not in {1}'.format(i, call))
Ejemplo n.º 2
0
    def test_user_create(self):
        postgres.user_create('testuser',
                             user='******',
                             host='testhost',
                             port='testport',
                             maintenance_db='maint_test',
                             password='******',
                             login=True,
                             createdb=False,
                             createroles=False,
                             createuser=False,
                             encrypted=False,
                             superuser=False,
                             replication=False,
                             rolepassword='******',
                             groups='test_groups',
                             runas='foo')
        call = postgres._run_psql.call_args[0][0]
        self.assertTrue(
            re.match(
                '/usr/bin/pgsql --no-align --no-readline --no-password '
                '--username testuser'
                ' --host testhost --port testport'
                ' --dbname maint_test -c (\'|\")CREATE ROLE (\\\\)?"testuser(\\\\)?"',
                call))

        for i in ('INHERIT NOCREATEDB NOCREATEROLE '
                  'NOSUPERUSER NOREPLICATION LOGIN UNENCRYPTED PASSWORD'
                  ).split():
            self.assertTrue(i in call, '{0} not in {1}'.format(i, call))
Ejemplo n.º 3
0
    def test_user_create(self):
        postgres.user_create(
            'testuser',
            user='******',
            host='testhost',
            port='testport',
            maintenance_db='maint_test',
            password='******',
            login=True,
            createdb=False,
            createroles=False,
            createuser=False,
            encrypted=False,
            superuser=False,
            replication=False,
            rolepassword='******',
            groups='test_groups',
            runas='foo'
        )
        call = postgres._run_psql.call_args[0][0]
        self.assertTrue(re.match(
            '/usr/bin/pgsql --no-align --no-readline --no-password '
            '--username testuser'
            ' --host testhost --port testport'
            ' --dbname maint_test -c (\'|\")CREATE ROLE (\\\\)?"testuser(\\\\)?"',
            call))

        for i in (
            'INHERIT NOCREATEDB NOCREATEROLE '
            'NOSUPERUSER NOREPLICATION LOGIN UNENCRYPTED PASSWORD'
        ).split():
            self.assertTrue(i in call, '{0} not in {1}'.format(i, call))
Ejemplo n.º 4
0
 def test_user_create(self):
     postgres.user_create(
         'testuser',
         user='******',
         host='testhost',
         port='testport',
         maintenance_db='maint_test',
         password='******',
         login=True,
         createdb=False,
         createroles=False,
         createuser=False,
         encrypted=False,
         superuser=False,
         replication=False,
         rolepassword='******',
         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.
     call = postgres._run_psql.call_args[0][0][13]
     self.assertTrue(re.match('CREATE ROLE "testuser"', call))
     for i in (
         'INHERIT NOCREATEDB NOCREATEROLE '
         'NOSUPERUSER NOREPLICATION LOGIN UNENCRYPTED PASSWORD'
     ).split():
         self.assertTrue(i in call, '{0} not in {1}'.format(i, call))