This file is indexed.

/usr/lib/python3/dist-packages/postgresql/test/test_iri.py is in python3-postgresql 1.1.0-1build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
##
# .test.test_iri
##
import unittest
import postgresql.iri as pg_iri

value_errors = (
	# Invalid scheme.
	'http://user@host/index.html',
)

iri_samples = (
	'host/dbname/path?param=val#frag',
	'#frag',
	'?param=val',
	'?param=val#frag',
	'user@',
	':pass@',
	'u:p@h',
	'u:p@h:1',
	'pq://user:password@host:port/database?setting=value#public,private',
	'pq://fæm.com:123/õéf/á?param=val',
	'pq://l»»@fæm.com:123/õéf/á?param=val',
	'pq://fæᎱᏋm.com/õéf/á?param=val',
	'pq://fæᎱᏋm.com/õéf/á?param=val&[setting]=value',
)

sample_structured_parameters = [
	{
		'host' : 'hostname',
		'port' : '1234',
		'database' : 'foo_db',
	},
	{
		'user' : 'username',
		'database' : 'database_name',
		'settings' : {'foo':'bar','feh':'bl%,23'},
	},
	{
		'user' : 'username',
		'database' : 'database_name',
	},
	{
		'database' : 'database_name',
	},
	{
		'user' : 'user_name',
	},
	{
		'host' : 'hostname',
	},
	{
		'user' : 'username',
		'password' : 'pass',
		'host' : '',
		'port' : '4321',
		'database' : 'database_name',
		'path' : ['path'],
	},
	{
		'user' : 'user',
		'password' : 'secret',
		'host' : '',
		'port' : 'ssh',
		'database' : 'database_name',
		'settings' : {
			'set1' : 'val1',
			'set2' : 'val2',
		},
	},
	{
		'user' : 'user',
		'password' : 'secret',
		'host' : '',
		'port' : 'ssh',
		'database' : 'database_name',
		'settings' : {
			'set1' : 'val1',
			'set2' : 'val2',
		},
		'connect_timeout' : '10',
		'sslmode' : 'prefer',
	},
]

class test_iri(unittest.TestCase):
	def testPresentPasswordObscure(self):
		"password is present in IRI, and obscure it"
		s = 'pq://user:pass@host:port/dbname'
		o = 'pq://user:***@host:port/dbname'
		p = pg_iri.parse(s)
		ps = pg_iri.serialize(p, obscure_password = True)
		self.assertEqual(ps, o)

	def testPresentPasswordObscure(self):
		"password is *not* present in IRI, and do nothing"
		s = 'pq://user@host:port/dbname'
		o = 'pq://user@host:port/dbname'
		p = pg_iri.parse(s)
		ps = pg_iri.serialize(p, obscure_password = True)
		self.assertEqual(ps, o)

	def testValueErrors(self):
		for x in value_errors:
			self.assertRaises(ValueError,
				pg_iri.parse, x
			)

	def testParseSerialize(self):
		scheme = 'pq://'
		for x in iri_samples:
			px = pg_iri.parse(x)
			spx = pg_iri.serialize(px)
			pspx = pg_iri.parse(spx)
			self.assertTrue(
				pspx == px,
				"parse-serialize incongruity, %r -> %r -> %r : %r != %r" %(
					x, px, spx, pspx, px
				)
			)
			spspx = pg_iri.serialize(pspx)
			self.assertTrue(
				spx == spspx,
				"parse-serialize incongruity, %r -> %r -> %r -> %r : %r != %r" %(
					x, px, spx, pspx, spspx, spx
				)
			)

	def testSerializeParse(self):
		for x in sample_structured_parameters:
			xs = pg_iri.serialize(x)
			uxs = pg_iri.parse(xs)
			self.assertTrue(
				x == uxs,
				"serialize-parse incongruity, %r -> %r -> %r" %(
					x, xs, uxs,
				)
			)

if __name__ == '__main__':
	unittest.main()