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 @@ -972,6 +972,8 @@ class Config extends EventEmitter {
972972 'bad config: internalPort must be a positive integer' ) ;
973973 }
974974
975+ this . serverHeader = config . serverHeader || 'S3 Server' ;
976+
975977 this . port = config . port ;
976978 this . listenOn = this . _parseEndpoints ( config . listenOn , 'listenOn' ) ;
977979 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 3030 "@azure/storage-blob" : " ^12.28.0" ,
3131 "@hapi/joi" : " ^17.1.1" ,
3232 "@smithy/node-http-handler" : " ^3.0.0" ,
33- "arsenal" : " git+https://github.com/scality/Arsenal#8.3.8 " ,
33+ "arsenal" : " git+https://github.com/scality/Arsenal#8.3.9 " ,
3434 "async" : " 2.6.4" ,
3535 "bucketclient" : " scality/bucketclient#8.2.7" ,
3636 "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 @@ -983,4 +983,31 @@ describe('Config', () => {
983983 assert . throws ( ( ) => new ConfigObject ( ) ) ;
984984 } ) ;
985985 } ) ;
986+
987+ describe ( 'serverHeader' , ( ) => {
988+ let sandbox ;
989+ let readFileStub ;
990+
991+ beforeEach ( ( ) => {
992+ sandbox = sinon . createSandbox ( ) ;
993+ readFileStub = sandbox . stub ( fs , 'readFileSync' ) ;
994+ readFileStub . callThrough ( ) ;
995+ } ) ;
996+
997+ afterEach ( ( ) => {
998+ sandbox . restore ( ) ;
999+ } ) ;
1000+
1001+ it ( 'should default to "S3 Server" when not configured' , ( ) => {
1002+ const config = new ConfigObject ( ) ;
1003+ assert . strictEqual ( config . serverHeader , 'S3 Server' ) ;
1004+ } ) ;
1005+
1006+ it ( 'should use the configured value when set' , ( ) => {
1007+ const modifiedConfig = { ...defaultConfig , serverHeader : 'ScalityS3' } ;
1008+ readFileStub . withArgs ( sinon . match ( / c o n f i g .j s o n $ / ) ) . returns ( JSON . stringify ( modifiedConfig ) ) ;
1009+ const config = new ConfigObject ( ) ;
1010+ assert . strictEqual ( config . serverHeader , 'ScalityS3' ) ;
1011+ } ) ;
1012+ } ) ;
9861013} ) ;
Original file line number Diff line number Diff line change @@ -6181,9 +6181,9 @@ arraybuffer.prototype.slice@^1.0.4:
61816181 optionalDependencies:
61826182 ioctl "^2.0.2"
61836183
6184- "arsenal@git+https://github.com/scality/Arsenal#8.3.8 ":
6185- version "8.3.8 "
6186- resolved "git+https://github.com/scality/Arsenal#ded10b14ec7e1cc4ab813a88439a27a74c7e2a19 "
6184+ "arsenal@git+https://github.com/scality/Arsenal#8.3.9 ":
6185+ version "8.3.9 "
6186+ resolved "git+https://github.com/scality/Arsenal#51e5b761f7f0612a722c828fa3d43b438c50ab7c "
61876187 dependencies:
61886188 "@aws-sdk/client-kms" "^3.975.0"
61896189 "@aws-sdk/client-s3" "^3.975.0"
You can’t perform that action at this time.
0 commit comments