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 2121 "dependencies" : {
2222 "@azure/storage-blob" : " ^12.28.0" ,
2323 "@hapi/joi" : " ^17.1.1" ,
24- "arsenal" : " git+https://github.com/scality/arsenal#8.2.48 " ,
24+ "arsenal" : " git+https://github.com/scality/arsenal#8.2.50 " ,
2525 "async" : " 2.6.4" ,
2626 "aws-sdk" : " ^2.1692.0" ,
2727 "bucketclient" : " scality/bucketclient#8.2.7" ,
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 @@ -1527,9 +1527,9 @@ arraybuffer.prototype.slice@^1.0.4:
15271527 optionalDependencies :
15281528 ioctl "^2.0.2"
15291529
1530- " arsenal@git+https://github.com/scality/arsenal#8.2.48 " :
1531- version "8.2.48 "
1532- resolved "git+https://github.com/scality/arsenal#362f7908b6126709add96ee981d5235d96bab58c "
1530+ " arsenal@git+https://github.com/scality/arsenal#8.2.50 " :
1531+ version "8.2.50 "
1532+ resolved "git+https://github.com/scality/arsenal#2b0a8026cb62e0f6a621738e78f5e9fcc977275e "
15331533 dependencies :
15341534 " @azure/identity" " ^4.13.0"
15351535 " @azure/storage-blob" " ^12.28.0"
You can’t perform that action at this time.
0 commit comments