Skip to content

Instantly share code, notes, and snippets.

@gregarndt
Created December 11, 2015 14:54
Show Gist options
  • Save gregarndt/ad2d538307c6d934813d to your computer and use it in GitHub Desktop.
Save gregarndt/ad2d538307c6d934813d to your computer and use it in GitHub Desktop.
import assert from 'assert';
import DockerWorker from '../dockerworker';
import TestWorker from '../testworker';
suite('allow ptrace', () => {
let worker;
setup(async () => {
worker = new TestWorker(DockerWorker);
await worker.launch();
});
teardown(async () => {
if (worker) {
await worker.terminate();
worker = null;
}
});
test('ptrace enabled', async () => {
let result = await worker.postToQueue({
scopes: ['docker-worker:feature:allowPtrace'],
payload: {
image: 'taskcluster/test-ubuntu',
command: [
'bash',
'-c',
'ls /'
],
features: {
allowPtrace: true
},
maxRunTime: 5 * 60
}
});
assert.equal(result.run.state, 'completed', 'task should be successful');
assert.equal(result.run.reasonResolved, 'completed',
'task should be successful');
});
test('missing feature scope', async () => {
let result = await worker.postToQueue({
payload: {
features: {
allowPtrace: true
},
image: 'taskcluster/test-ubuntu',
command: [
'/bin/bash',
'-c',
'ls'
],
maxRunTime: 5 * 60
}
});
assert.ok(
result.log.includes('[taskcluster:error] Task was aborted because states'),
'Error does not container message about states being aborted'
);
assert.ok(
result.log.includes('Error calling \'link\' for allowPtrace'),
'Error does not contain the name of the feature'
);
assert.ok(
result.log.includes('Insufficient scopes to use \'allowPtrace\''),
'Error does not contain message about insufficient scopes'
);
assert.equal(result.status.state, 'failed', 'Task not marked as failed');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment