Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,8 @@ class Config extends EventEmitter {
'bad config: internalPort must be a positive integer');
}

this.serverHeader = config.serverHeader || 'S3 Server';

this.port = config.port;
this.listenOn = this._parseEndpoints(config.listenOn, 'listenOn');
this.internalPort = config.internalPort;
Expand Down
3 changes: 3 additions & 0 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const https = require('https');
const cluster = require('cluster');
const { series } = require('async');
const arsenal = require('arsenal');
const { setServerHeader } = arsenal.s3routes.routesUtils;
const { RedisClient, StatsClient } = arsenal.metrics;
const monitoringClient = require('./utilities/monitoringHandler');

Expand Down Expand Up @@ -34,6 +35,8 @@ const websiteEndpoints = _config.websiteEndpoints;
let client = dataWrapper.client;
const implName = dataWrapper.implName;

setServerHeader(_config.serverHeader);

let allEndpoints;
function updateAllEndpoints() {
allEndpoints = Object.keys(_config.restEndpoints);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"dependencies": {
"@azure/storage-blob": "^12.28.0",
"@hapi/joi": "^17.1.1",
"arsenal": "git+https://github.com/scality/arsenal#8.2.48",
"arsenal": "git+https://github.com/scality/arsenal#e9506a3778ec8e9f395e59c3c6dec86b0c23882f",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arsenal dependency is pinned to a commit hash instead of a tag. Other git-based deps in this file (bucketclient, utapi, etc.) use version tags. This should be updated to the released tag (e.g. 8.2.49) once the Arsenal PR is merged and tagged.

— Claude Code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Complementing what claude said: I recommend creating a separate DROPME commit to reduce the chances to forget about it

"async": "2.6.4",
"aws-sdk": "^2.1692.0",
"bucketclient": "scality/bucketclient#8.2.7",
Expand Down
16 changes: 16 additions & 0 deletions tests/functional/healthchecks/test/checkRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,22 @@ if (config.healthChecks.enableInternalRoute) {
});
}

describe('Server response header', () => {
it('should return the configured serverHeader value on S3 API responses', done => {
const getOptions = deepCopy(options);
getOptions.method = 'GET';
getOptions.path = '/';
getOptions.port = config.port || 8000;
getOptions.agent = makeAgent();
const req = transport.request(getOptions, res => {
assert.strictEqual(res.headers['server'], config.serverHeader);
done();
});
req.on('error', done);
req.end();
});
});

describe('Healthcheck stats', () => {
const totalReqs = 5;
beforeEach(done => {
Expand Down
27 changes: 27 additions & 0 deletions tests/unit/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -983,4 +983,31 @@ describe('Config', () => {
assert.throws(() => new ConfigObject());
});
});

describe('serverHeader', () => {
let sandbox;
let readFileStub;

beforeEach(() => {
sandbox = sinon.createSandbox();
readFileStub = sandbox.stub(fs, 'readFileSync');
readFileStub.callThrough();
});

afterEach(() => {
sandbox.restore();
});

it('should default to "S3 Server" when not configured', () => {
const config = new ConfigObject();
assert.strictEqual(config.serverHeader, 'S3 Server');
});

it('should use the configured value when set', () => {
const modifiedConfig = { ...defaultConfig, serverHeader: 'ScalityS3' };
readFileStub.withArgs(sinon.match(/config.json$/)).returns(JSON.stringify(modifiedConfig));
const config = new ConfigObject();
assert.strictEqual(config.serverHeader, 'ScalityS3');
});
});
});
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1527,9 +1527,9 @@ arraybuffer.prototype.slice@^1.0.4:
optionalDependencies:
ioctl "^2.0.2"

"arsenal@git+https://github.com/scality/arsenal#8.2.48":
version "8.2.48"
resolved "git+https://github.com/scality/arsenal#362f7908b6126709add96ee981d5235d96bab58c"
"arsenal@git+https://github.com/scality/arsenal#e9506a3778ec8e9f395e59c3c6dec86b0c23882f":
version "8.2.49"
resolved "git+https://github.com/scality/arsenal#e9506a3778ec8e9f395e59c3c6dec86b0c23882f"
dependencies:
"@azure/identity" "^4.13.0"
"@azure/storage-blob" "^12.28.0"
Expand Down
Loading