@@ -625,16 +625,17 @@ describe("hyperdrive commands", () => {
625625 ` ) ;
626626 } ) ;
627627
628- it ( "should create a hyperdrive with mtls config" , async ( ) => {
628+ it ( "should successfully create a hyperdrive with mtls config and sslmode=verify-full " , async ( ) => {
629629 const reqProm = mockHyperdriveCreate ( ) ;
630630 await runWrangler (
631- "hyperdrive create test123 --host=example.com --database=neondb --user=test --password=password --port=1234 --ca-certificate-id=12345 --mtls-certificate-id=1234"
631+ "hyperdrive create test123 --host=example.com --database=neondb --user=test --password=password --port=1234 --ca-certificate-id=12345 --mtls-certificate-id=1234 --sslmode=verify-full "
632632 ) ;
633633 await expect ( reqProm ) . resolves . toMatchInlineSnapshot ( `
634634 Object {
635635 "mtls": Object {
636636 "ca_certificate_id": "12345",
637637 "mtls_certificate_id": "1234",
638+ "sslmode": "verify-full",
638639 },
639640 "name": "test123",
640641 "origin": Object {
@@ -663,20 +664,94 @@ describe("hyperdrive commands", () => {
663664 ` ) ;
664665 } ) ;
665666
667+ it ( "should successfully create a hyperdrive with mtls config and sslmode=require" , async ( ) => {
668+ await runWrangler (
669+ "hyperdrive create test123 --host=example.com --database=neondb --user=test --password=password --port=1234 --mtls-certificate-id=1234 --sslmode=require"
670+ ) ;
671+ expect ( std . out ) . toMatchInlineSnapshot ( `
672+ "🚧 Creating 'test123'
673+ ✅ Created new Hyperdrive PostgreSQL config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
674+ 📋 To start using your config from a Worker, add the following binding configuration to your Wrangler configuration file:
675+
676+ {
677+ \\"hyperdrive\\": [
678+ {
679+ \\"binding\\": \\"HYPERDRIVE\\",
680+ \\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\"
681+ }
682+ ]
683+ }"
684+ ` ) ;
685+ } ) ;
686+
687+ it ( "should error on create hyperdrive with mtls config sslmode=require and CA flag set" , async ( ) => {
688+ await expect ( ( ) =>
689+ runWrangler (
690+ "hyperdrive create test123 --host=example.com --database=neondb --user=test --password=password --port=1234 --ca-certificate-id=1234 --sslmode=require"
691+ )
692+ ) . rejects . toThrow ( ) ;
693+ expect ( std . err ) . toMatchInlineSnapshot ( `
694+ "[31mX [41;31m[[41;97mERROR[41;31m][0m [1mCA not allowed when sslmode = 'require' is set[0m
695+
696+ "
697+ ` ) ;
698+ } ) ;
699+
700+ it ( "should error on create hyperdrive with mtls config sslmode=verify-ca missing CA" , async ( ) => {
701+ await expect ( ( ) =>
702+ runWrangler (
703+ "hyperdrive create test123 --host=example.com --database=neondb --user=test --password=password --port=1234 --mtls-certificate-id=1234 --sslmode=verify-ca"
704+ )
705+ ) . rejects . toThrow ( ) ;
706+ expect ( std . err ) . toMatchInlineSnapshot ( `
707+ "[31mX [41;31m[[41;97mERROR[41;31m][0m [1mCA required when sslmode = 'verify-ca' or 'verify-full' is set[0m
708+
709+ "
710+ ` ) ;
711+ } ) ;
712+
713+ it ( "should error on create hyperdrive with mtls config sslmode=verify-full missing CA" , async ( ) => {
714+ await expect ( ( ) =>
715+ runWrangler (
716+ "hyperdrive create test123 --host=example.com --database=neondb --user=test --password=password --port=1234 --mtls-certificate-id=1234 --sslmode=verify-full"
717+ )
718+ ) . rejects . toThrow ( ) ;
719+ expect ( std . err ) . toMatchInlineSnapshot ( `
720+ "[31mX [41;31m[[41;97mERROR[41;31m][0m [1mCA required when sslmode = 'verify-ca' or 'verify-full' is set[0m
721+
722+ "
723+ ` ) ;
724+ } ) ;
725+
726+ it ( "should error on create hyperdrive with mtls config sslmode=random" , async ( ) => {
727+ await expect ( ( ) =>
728+ runWrangler (
729+ "hyperdrive create test123 --host=example.com --database=neondb --user=test --password=password --port=1234 --mtls-certificate-id=1234 --sslmode=random"
730+ )
731+ ) . rejects . toThrow ( ) ;
732+ expect ( std . err ) . toMatchInlineSnapshot ( `
733+ "[31mX [41;31m[[41;97mERROR[41;31m][0m [1mInvalid values:[0m
734+
735+ Argument: sslmode, Given: \\"random\\", Choices: \\"require\\", \\"verify-ca\\", \\"verify-full\\"
736+
737+ "
738+ ` ) ;
739+ } ) ;
740+
666741 it ( "should handle listing configs" , async ( ) => {
667742 mockHyperdriveGetListOrDelete ( ) ;
668743 await runWrangler ( "hyperdrive list" ) ;
669744 expect ( std . out ) . toMatchInlineSnapshot ( `
670745 "📋 Listing Hyperdrive configs
671- ┌──────────────────────────────────────┬─────────────┬─────────┬────────────────┬──────┬────────────┬───────────┬──────────┬───────────────────────────────────────────────────────────┐
672- │ id │ name │ user │ host │ port │ scheme │ database │ caching │ mtls │
673- ├──────────────────────────────────────┼─────────────┼─────────┼────────────────┼──────┼────────────┼───────────┼──────────┼───────────────────────────────────────────────────────────┤
674- │ xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx │ test123 │ test │ example.com │ 5432 │ PostgreSQL │ neondb │ enabled │ │
675- ├──────────────────────────────────────┼─────────────┼─────────┼────────────────┼──────┼────────────┼───────────┼──────────┼───────────────────────────────────────────────────────────┤
676- │ yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy │ new-db │ dbuser │ www.google.com │ 3211 │ PostgreSQL │ mydb │ disabled │ │
677- ├──────────────────────────────────────┼─────────────┼─────────┼────────────────┼──────┼────────────┼───────────┼──────────┼───────────────────────────────────────────────────────────┤
678- │ zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz │ new-db-mtls │ pg-mtls │ www.mtls.com │ 3212 │ │ mydb-mtls │ enabled │ {\\"ca_certificate_id\\":\\"1234\\",\\"mtls_certificate_id\\":\\"1234\\"} │
679- └──────────────────────────────────────┴─────────────┴─────────┴────────────────┴──────┴────────────┴───────────┴──────────┴───────────────────────────────────────────────────────────┘"
746+ ┌──────────────────────────────────────┬─────────────┬─────────┬────────────────┬──────┬────────────┬───────────┬──────────┬─────────────────────────────────────────────────────────────────────────────────── ┐
747+ │ id │ name │ user │ host │ port │ scheme │ database │ caching │ mtls │
748+ ├──────────────────────────────────────┼─────────────┼─────────┼────────────────┼──────┼────────────┼───────────┼──────────┼─────────────────────────────────────────────────────────────────────────────────── ┤
749+ │ xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx │ test123 │ test │ example.com │ 5432 │ PostgreSQL │ neondb │ enabled │ │
750+ ├──────────────────────────────────────┼─────────────┼─────────┼────────────────┼──────┼────────────┼───────────┼──────────┼─────────────────────────────────────────────────────────────────────────────────── ┤
751+ │ yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy │ new-db │ dbuser │ www.google.com │ 3211 │ PostgreSQL │ mydb │ disabled │ │
752+ ├──────────────────────────────────────┼─────────────┼─────────┼────────────────┼──────┼────────────┼───────────┼──────────┼─────────────────────────────────────────────────────────────────────────────────── ┤
753+ │ zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz │ new-db-mtls │ pg-mtls │ www.mtls.com │ 3212 │ │ mydb-mtls │ enabled │ {\\"ca_certificate_id\\":\\"1234\\",\\"mtls_certificate_id\\":\\"1234\\",\\"sslmode\\":\\"verify-full\\" } │
754+ └──────────────────────────────────────┴─────────────┴─────────┴────────────────┴──────┴────────────┴───────────┴──────────┴─────────────────────────────────────────────────────────────────────────────────── ┘"
680755 ` ) ;
681756 } ) ;
682757
@@ -985,13 +1060,14 @@ describe("hyperdrive commands", () => {
9851060 it ( "should handle updating a hyperdrive config's mtls configuration" , async ( ) => {
9861061 const reqProm = mockHyperdriveUpdate ( ) ;
9871062 await runWrangler (
988- "hyperdrive update xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --ca-certificate-id=2345 --mtls-certificate-id=234"
1063+ "hyperdrive update xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --ca-certificate-id=2345 --mtls-certificate-id=234 --sslmode=verify-full "
9891064 ) ;
9901065 await expect ( reqProm ) . resolves . toMatchInlineSnapshot ( `
9911066 Object {
9921067 "mtls": Object {
9931068 "ca_certificate_id": "2345",
9941069 "mtls_certificate_id": "234",
1070+ "sslmode": "verify-full",
9951071 },
9961072 }
9971073 ` ) ;
@@ -1010,7 +1086,8 @@ describe("hyperdrive commands", () => {
10101086 },
10111087 \\"mtls\\": {
10121088 \\"ca_certificate_id\\": \\"2345\\",
1013- \\"mtls_certificate_id\\": \\"234\\"
1089+ \\"mtls_certificate_id\\": \\"234\\",
1090+ \\"sslmode\\": \\"verify-full\\"
10141091 }
10151092 }"
10161093 ` ) ;
@@ -1080,6 +1157,7 @@ function mockHyperdriveGetListOrDelete() {
10801157 mtls : {
10811158 ca_certificate_id : "1234" ,
10821159 mtls_certificate_id : "1234" ,
1160+ sslmode : "verify-full" ,
10831161 } ,
10841162 } ,
10851163 ] ,
0 commit comments