File tree Expand file tree Collapse file tree 6 files changed +52
-4
lines changed
functional/healthchecks/test Expand file tree Collapse file tree 6 files changed +52
-4
lines changed Original file line number Diff line number Diff line change @@ -956,6 +956,8 @@ class Config extends EventEmitter {
956956 'bad config: internalPort must be a positive integer' ) ;
957957 }
958958
959+ this . serverHeader = config . serverHeader || 'S3 Server' ;
960+
959961 this . port = config . port ;
960962 this . listenOn = this . _parseEndpoints ( config . listenOn , 'listenOn' ) ;
961963 this . internalPort = config . internalPort ;
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ const https = require('https');
33const cluster = require ( 'cluster' ) ;
44const { series } = require ( 'async' ) ;
55const arsenal = require ( 'arsenal' ) ;
6+ const { setServerHeader } = arsenal . s3routes . routesUtils ;
67const { RedisClient, StatsClient } = arsenal . metrics ;
78const monitoringClient = require ( './utilities/monitoringHandler' ) ;
89
@@ -34,6 +35,8 @@ const websiteEndpoints = _config.websiteEndpoints;
3435let client = dataWrapper . client ;
3536const implName = dataWrapper . implName ;
3637
38+ setServerHeader ( _config . serverHeader ) ;
39+
3740let allEndpoints ;
3841function updateAllEndpoints ( ) {
3942 allEndpoints = Object . keys ( _config . restEndpoints ) ;
Original file line number Diff line number Diff line change 3333 "@azure/storage-blob" : " ^12.28.0" ,
3434 "@hapi/joi" : " ^17.1.1" ,
3535 "@smithy/node-http-handler" : " ^3.0.0" ,
36- "arsenal" : " git+https://github.com/scality/Arsenal#8.3.8 " ,
36+ "arsenal" : " git+https://github.com/scality/Arsenal#8.3.9 " ,
3737 "async" : " 2.6.4" ,
3838 "bucketclient" : " scality/bucketclient#8.2.7" ,
3939 "bufferutil" : " ^4.0.8" ,
Original file line number Diff line number Diff line change @@ -131,6 +131,22 @@ if (config.healthChecks.enableInternalRoute) {
131131 } ) ;
132132}
133133
134+ describe ( 'Server response header' , ( ) => {
135+ it ( 'should return the configured serverHeader value on S3 API responses' , done => {
136+ const getOptions = deepCopy ( options ) ;
137+ getOptions . method = 'GET' ;
138+ getOptions . path = '/' ;
139+ getOptions . port = config . port || 8000 ;
140+ getOptions . agent = makeAgent ( ) ;
141+ const req = transport . request ( getOptions , res => {
142+ assert . strictEqual ( res . headers [ 'server' ] , config . serverHeader ) ;
143+ done ( ) ;
144+ } ) ;
145+ req . on ( 'error' , done ) ;
146+ req . end ( ) ;
147+ } ) ;
148+ } ) ;
149+
134150describe ( 'Healthcheck stats' , ( ) => {
135151 const totalReqs = 5 ;
136152 beforeEach ( done => {
Original file line number Diff line number Diff line change @@ -987,4 +987,31 @@ describe('Config', () => {
987987 assert . throws ( ( ) => new ConfigObject ( ) ) ;
988988 } ) ;
989989 } ) ;
990+
991+ describe ( 'serverHeader' , ( ) => {
992+ let sandbox ;
993+ let readFileStub ;
994+
995+ beforeEach ( ( ) => {
996+ sandbox = sinon . createSandbox ( ) ;
997+ readFileStub = sandbox . stub ( fs , 'readFileSync' ) ;
998+ readFileStub . callThrough ( ) ;
999+ } ) ;
1000+
1001+ afterEach ( ( ) => {
1002+ sandbox . restore ( ) ;
1003+ } ) ;
1004+
1005+ it ( 'should default to "S3 Server" when not configured' , ( ) => {
1006+ const config = new ConfigObject ( ) ;
1007+ assert . strictEqual ( config . serverHeader , 'S3 Server' ) ;
1008+ } ) ;
1009+
1010+ it ( 'should use the configured value when set' , ( ) => {
1011+ const modifiedConfig = { ...defaultConfig , serverHeader : 'ScalityS3' } ;
1012+ readFileStub . withArgs ( sinon . match ( / c o n f i g .j s o n $ / ) ) . returns ( JSON . stringify ( modifiedConfig ) ) ;
1013+ const config = new ConfigObject ( ) ;
1014+ assert . strictEqual ( config . serverHeader , 'ScalityS3' ) ;
1015+ } ) ;
1016+ } ) ;
9901017} ) ;
Original file line number Diff line number Diff line change @@ -6114,9 +6114,9 @@ arraybuffer.prototype.slice@^1.0.4:
61146114 optionalDependencies:
61156115 ioctl "^2.0.2"
61166116
6117- "arsenal@git+https://github.com/scality/Arsenal#8.3.8 ":
6118- version "8.3.8 "
6119- resolved "git+https://github.com/scality/Arsenal#ded10b14ec7e1cc4ab813a88439a27a74c7e2a19 "
6117+ "arsenal@git+https://github.com/scality/Arsenal#8.3.9 ":
6118+ version "8.3.9 "
6119+ resolved "git+https://github.com/scality/Arsenal#51e5b761f7f0612a722c828fa3d43b438c50ab7c "
61206120 dependencies:
61216121 "@aws-sdk/client-kms" "^3.975.0"
61226122 "@aws-sdk/client-s3" "^3.975.0"
You can’t perform that action at this time.
0 commit comments