@@ -2746,6 +2746,79 @@ func TestNullDocHandlingForMutable1xBody(t *testing.T) {
27462746 assert .Contains (t , err .Error (), "null doc body for doc" )
27472747}
27482748
2749+ // TestDatabaseXattrConfigHandlingForDBConfigUpdate:
2750+ // - Create database with xattrs enabled
2751+ // - Test updating the config to disable the use of xattrs in this database through replacing + upserting the config
2752+ // - Assert error code is returned and response contains error string
2753+ func TestDatabaseXattrConfigHandlingForDBConfigUpdate (t * testing.T ) {
2754+ base .LongRunningTest (t )
2755+ const (
2756+ dbName = "db1"
2757+ errResp = "sync gateway requires enable_shared_bucket_access=true"
2758+ )
2759+
2760+ testCases := []struct {
2761+ name string
2762+ upsertConfig bool
2763+ }{
2764+ {
2765+ name : "POST update" ,
2766+ upsertConfig : true ,
2767+ },
2768+ {
2769+ name : "PUT update" ,
2770+ upsertConfig : false ,
2771+ },
2772+ }
2773+ for _ , testCase := range testCases {
2774+ t .Run (testCase .name , func (t * testing.T ) {
2775+ rt := NewRestTester (t , & RestTesterConfig {
2776+ PersistentConfig : true ,
2777+ })
2778+ defer rt .Close ()
2779+
2780+ dbConfig := rt .NewDbConfig ()
2781+
2782+ resp := rt .CreateDatabase (dbName , dbConfig )
2783+ RequireStatus (t , resp , http .StatusCreated )
2784+ assert .NoError (t , rt .WaitForDBOnline ())
2785+
2786+ dbConfig .EnableXattrs = base .BoolPtr (false )
2787+
2788+ if testCase .upsertConfig {
2789+ resp = rt .UpsertDbConfig (dbName , dbConfig )
2790+ RequireStatus (t , resp , http .StatusInternalServerError )
2791+ assert .Contains (t , resp .Body .String (), errResp )
2792+ } else {
2793+ resp = rt .ReplaceDbConfig (dbName , dbConfig )
2794+ RequireStatus (t , resp , http .StatusInternalServerError )
2795+ assert .Contains (t , resp .Body .String (), errResp )
2796+ }
2797+ })
2798+ }
2799+ }
2800+
2801+ // TestCreateDBWithXattrsDisbaled:
2802+ // - Test that you cannot create a database with xattrs disabled
2803+ // - Assert error code is returned and response contains error string
2804+ func TestCreateDBWithXattrsDisbaled (t * testing.T ) {
2805+ rt := NewRestTester (t , & RestTesterConfig {
2806+ PersistentConfig : true ,
2807+ })
2808+ defer rt .Close ()
2809+ const (
2810+ dbName = "db1"
2811+ errResp = "sync gateway requires enable_shared_bucket_access=true"
2812+ )
2813+
2814+ dbConfig := rt .NewDbConfig ()
2815+ dbConfig .EnableXattrs = base .BoolPtr (false )
2816+
2817+ resp := rt .CreateDatabase (dbName , dbConfig )
2818+ RequireStatus (t , resp , http .StatusInternalServerError )
2819+ assert .Contains (t , resp .Body .String (), errResp )
2820+ }
2821+
27492822// TestPutDocUpdateVersionVector:
27502823// - Put a doc and assert that the versions and the source for the hlv is correctly updated
27512824// - Update that doc and assert HLV has also been updated
0 commit comments