Add robotsTxt tests
This commit is contained in:
17
src/apps.js
17
src/apps.js
@@ -1049,7 +1049,7 @@ function setAutomaticUpdate(appId, enable, auditSource, callback) {
|
||||
|
||||
function setRobotsTxt(appId, robotsTxt, auditSource, callback) {
|
||||
assert.strictEqual(typeof appId, 'string');
|
||||
assert(!robotsTxt || typeof robotsTxt === 'string');
|
||||
assert(robotsTxt === null || typeof robotsTxt === 'string');
|
||||
assert.strictEqual(typeof auditSource, 'object');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
@@ -1059,14 +1059,17 @@ function setRobotsTxt(appId, robotsTxt, auditSource, callback) {
|
||||
error = validateRobotsTxt(robotsTxt);
|
||||
if (error) return callback(error);
|
||||
|
||||
appdb.update(appId, { robotsTxt: robotsTxt }, function (error) {
|
||||
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(new AppsError(AppsError.NOT_FOUND, 'No such app'));
|
||||
if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error));
|
||||
reverseProxy.writeAppConfig(_.extend({}, app, { robotsTxt }), function (error) {
|
||||
if (error) return callback(new AppsError(AppsError.EXTERNAL_ERROR, 'Error writing nginx config'));
|
||||
|
||||
// TODO: call reverseProxy config re-write here
|
||||
eventlog.add(eventlog.ACTION_APP_CONFIGURE, auditSource, { appId: appId, app: app, robotsTxt: robotsTxt });
|
||||
appdb.update(appId, { robotsTxt: robotsTxt }, function (error) {
|
||||
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(new AppsError(AppsError.NOT_FOUND, 'No such app'));
|
||||
if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error));
|
||||
|
||||
callback();
|
||||
eventlog.add(eventlog.ACTION_APP_CONFIGURE, auditSource, { appId: appId, app: app, robotsTxt: robotsTxt });
|
||||
|
||||
callback();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user