@@ -540,18 +540,58 @@ describe("hyperdrive commands", () => {
540
540
` ) ;
541
541
} ) ;
542
542
543
+ it ( "should create a hyperdrive with mtls config" , async ( ) => {
544
+ const reqProm = mockHyperdriveCreate ( ) ;
545
+ await runWrangler (
546
+ "hyperdrive create test123 --host=example.com --database=neondb --user=test --password=password --port=1234 --ca-certificate-uuid=12345 --mtls-certificate-uuid=1234"
547
+ ) ;
548
+ await expect ( reqProm ) . resolves . toMatchInlineSnapshot ( `
549
+ Object {
550
+ "mtls": Object {
551
+ "ca_certificate_uuid": "12345",
552
+ "mtls_certificate_uuid": "1234",
553
+ },
554
+ "name": "test123",
555
+ "origin": Object {
556
+ "database": "neondb",
557
+ "host": "example.com",
558
+ "password": "password",
559
+ "port": 1234,
560
+ "scheme": "postgresql",
561
+ "user": "test",
562
+ },
563
+ }
564
+ ` ) ;
565
+ expect ( std . out ) . toMatchInlineSnapshot ( `
566
+ "🚧 Creating 'test123'
567
+ ✅ Created new Hyperdrive config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
568
+ 📋 To start using your config from a Worker, add the following binding configuration to your Wrangler configuration file:
569
+
570
+ {
571
+ \\"hyperdrive\\": [
572
+ {
573
+ \\"binding\\": \\"HYPERDRIVE\\",
574
+ \\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\"
575
+ }
576
+ ]
577
+ }"
578
+ ` ) ;
579
+ } ) ;
580
+
543
581
it ( "should handle listing configs" , async ( ) => {
544
582
mockHyperdriveGetListOrDelete ( ) ;
545
583
await runWrangler ( "hyperdrive list" ) ;
546
584
expect ( std . out ) . toMatchInlineSnapshot ( `
547
585
"📋 Listing Hyperdrive configs
548
- ┌──────────────────────────────────────┬─────────┬────────┬────────────────┬──────┬──────────┬───────────────────┐
549
- │ id │ name │ user │ host │ port │ database │ caching │
550
- ├──────────────────────────────────────┼─────────┼────────┼────────────────┼──────┼──────────┼───────────────────┤
551
- │ xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx │ test123 │ test │ example.com │ 5432 │ neondb │ │
552
- ├──────────────────────────────────────┼─────────┼────────┼────────────────┼──────┼──────────┼───────────────────┤
553
- │ yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy │ new-db │ dbuser │ www.google.com │ 3211 │ mydb │ {\\"disabled\\":true} │
554
- └──────────────────────────────────────┴─────────┴────────┴────────────────┴──────┴──────────┴───────────────────┘"
586
+ ┌──────────────────────────────────────┬─────────────┬─────────┬────────────────┬──────┬───────────┬───────────────────┬───────────────────────────────────────────────────────────────┐
587
+ │ id │ name │ user │ host │ port │ database │ caching │ mtls │
588
+ ├──────────────────────────────────────┼─────────────┼─────────┼────────────────┼──────┼───────────┼───────────────────┼───────────────────────────────────────────────────────────────┤
589
+ │ xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx │ test123 │ test │ example.com │ 5432 │ neondb │ │ │
590
+ ├──────────────────────────────────────┼─────────────┼─────────┼────────────────┼──────┼───────────┼───────────────────┼───────────────────────────────────────────────────────────────┤
591
+ │ yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy │ new-db │ dbuser │ www.google.com │ 3211 │ mydb │ {\\"disabled\\":true} │ │
592
+ ├──────────────────────────────────────┼─────────────┼─────────┼────────────────┼──────┼───────────┼───────────────────┼───────────────────────────────────────────────────────────────┤
593
+ │ zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz │ new-db-mtls │ pg-mtls │ www.mtls.com │ 3212 │ mydb-mtls │ │ {\\"ca_certificate_uuid\\":\\"1234\\",\\"mtls_certificate_uuid\\":\\"1234\\"} │
594
+ └──────────────────────────────────────┴─────────────┴─────────┴────────────────┴──────┴───────────┴───────────────────┴───────────────────────────────────────────────────────────────┘"
555
595
` ) ;
556
596
} ) ;
557
597
@@ -856,6 +896,40 @@ describe("hyperdrive commands", () => {
856
896
"
857
897
` ) ;
858
898
} ) ;
899
+
900
+ it ( "should handle updating a hyperdrive config's mtls configuration" , async ( ) => {
901
+ const reqProm = mockHyperdriveUpdate ( ) ;
902
+ await runWrangler (
903
+ "hyperdrive update xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --ca-certificate-uuid=2345 --mtls-certificate-uuid=234"
904
+ ) ;
905
+ await expect ( reqProm ) . resolves . toMatchInlineSnapshot ( `
906
+ Object {
907
+ "mtls": Object {
908
+ "ca_certificate_uuid": "2345",
909
+ "mtls_certificate_uuid": "234",
910
+ },
911
+ }
912
+ ` ) ;
913
+ expect ( std . out ) . toMatchInlineSnapshot ( `
914
+ "🚧 Updating 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
915
+ ✅ Updated xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx Hyperdrive config
916
+ {
917
+ \\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\",
918
+ \\"name\\": \\"test123\\",
919
+ \\"origin\\": {
920
+ \\"scheme\\": \\"postgresql\\",
921
+ \\"host\\": \\"example.com\\",
922
+ \\"port\\": 5432,
923
+ \\"database\\": \\"neondb\\",
924
+ \\"user\\": \\"test\\"
925
+ },
926
+ \\"mtls\\": {
927
+ \\"ca_certificate_uuid\\": \\"2345\\",
928
+ \\"mtls_certificate_uuid\\": \\"234\\"
929
+ }
930
+ }"
931
+ ` ) ;
932
+ } ) ;
859
933
} ) ;
860
934
861
935
const defaultConfig : HyperdriveConfig = {
@@ -908,6 +982,21 @@ function mockHyperdriveGetListOrDelete() {
908
982
disabled : true ,
909
983
} ,
910
984
} ,
985
+ {
986
+ id : "zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz" ,
987
+ name : "new-db-mtls" ,
988
+ origin : {
989
+ host : "www.mtls.com" ,
990
+ port : 3212 ,
991
+ database : "mydb-mtls" ,
992
+ user : "pg-mtls" ,
993
+ scheme : "pg-mtls" ,
994
+ } ,
995
+ mtls : {
996
+ ca_certificate_uuid : "1234" ,
997
+ mtls_certificate_uuid : "1234" ,
998
+ } ,
999
+ } ,
911
1000
] ,
912
1001
true
913
1002
)
@@ -955,6 +1044,11 @@ function mockHyperdriveUpdate(): Promise<PatchHyperdriveBody> {
955
1044
delete origin . port ;
956
1045
}
957
1046
}
1047
+ const mtls = defaultConfig . mtls ;
1048
+ if ( mtls && reqBody . mtls ) {
1049
+ mtls . ca_certificate_uuid = reqBody . mtls . ca_certificate_uuid ;
1050
+ mtls . mtls_certificate_uuid = reqBody . mtls . mtls_certificate_uuid ;
1051
+ }
958
1052
959
1053
return HttpResponse . json (
960
1054
createFetchResult (
@@ -963,6 +1057,7 @@ function mockHyperdriveUpdate(): Promise<PatchHyperdriveBody> {
963
1057
name : reqBody . name ?? defaultConfig . name ,
964
1058
origin,
965
1059
caching : reqBody . caching ?? defaultConfig . caching ,
1060
+ mtls : reqBody . mtls ,
966
1061
} ,
967
1062
true
968
1063
)
@@ -999,6 +1094,7 @@ function mockHyperdriveCreate(): Promise<CreateUpdateHyperdriveBody> {
999
1094
access_client_id : reqBody . origin . access_client_id ,
1000
1095
} ,
1001
1096
caching : reqBody . caching ,
1097
+ mtls : reqBody . mtls ,
1002
1098
} ,
1003
1099
true
1004
1100
)
0 commit comments