File tree 3 files changed +21
-1
lines changed
3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,11 @@ host all md5_user 127.0.0.1/32 md5
4
4
host all pass_user ::1/128 password
5
5
host all md5_user ::1/128 md5
6
6
7
+ hostssl all ssl_user 127.0.0.1/32 trust
8
+ hostssl all ssl_user ::1/128 trust
9
+ host all ssl_user 127.0.0.1/32 reject
10
+ host all ssl_user ::1/128 reject
11
+
7
12
# IPv4 local connections:
8
13
host all postgres 127.0.0.1/32 trust
9
14
# IPv6 local connections:
Original file line number Diff line number Diff line change 1
1
CREATE ROLE pass_user PASSWORD ' password' LOGIN;
2
2
CREATE ROLE md5_user PASSWORD ' password' LOGIN;
3
+ CREATE ROLE ssl_user LOGIN;
3
4
CREATE EXTENSION hstore;
4
5
CREATE EXTENSION citext;
Original file line number Diff line number Diff line change @@ -199,6 +199,20 @@ fn unix_socket() {
199
199
l. run ( done) . unwrap ( ) ;
200
200
}
201
201
202
+ #[ test]
203
+ fn ssl_user_ssl_required ( ) {
204
+ let mut l = Core :: new ( ) . unwrap ( ) ;
205
+ let handle = l. handle ( ) ;
206
+
207
+ let done = Connection :: connect ( "postgres://ssl_user@localhost/postgres" , TlsMode :: None , & handle) ;
208
+
209
+ match l. run ( done) {
210
+ Err ( ConnectError :: Db ( e) ) => assert ! ( e. code == SqlState :: InvalidAuthorizationSpecification ) ,
211
+ Err ( e) => panic ! ( "unexpected error {}" , e) ,
212
+ Ok ( _) => panic ! ( "unexpected success" ) ,
213
+ }
214
+ }
215
+
202
216
#[ cfg( feature = "with-openssl" ) ]
203
217
#[ test]
204
218
fn openssl_required ( ) {
@@ -210,7 +224,7 @@ fn openssl_required() {
210
224
let negotiator = OpenSsl :: from ( builder. build ( ) ) ;
211
225
212
226
let mut l = Core :: new ( ) . unwrap ( ) ;
213
- let done = Connection :: connect ( "postgres://postgres @localhost" ,
227
+ let done = Connection :: connect ( "postgres://ssl_user @localhost/postgres " ,
214
228
TlsMode :: Require ( Box :: new ( negotiator) ) ,
215
229
& l. handle ( ) )
216
230
. then ( |c| c. unwrap ( ) . prepare ( "SELECT 1" ) )
You can’t perform that action at this time.
0 commit comments