Skip to content

Commit

Permalink
storage: restore system tests (#2407)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenplusplus authored Jun 29, 2017
1 parent 90b41d2 commit 21ce94f
Showing 1 changed file with 37 additions and 43 deletions.
80 changes: 37 additions & 43 deletions packages/storage/system-test/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ var Bucket = Storage.Bucket;
var File = Storage.File;

describe('storage', function() {
var IS_CI = env.projectId === 'long-door-651';
var TESTS_PREFIX = 'gcloud-test-';
var TESTS_PREFIX = 'gcloud-tests-';

var storage = new Storage(env);
var bucket = storage.bucket(generateName());
Expand All @@ -64,13 +63,6 @@ describe('storage', function() {
});

after(function(done) {
if (IS_CI) {
// The system tests account is unable to delete files.
// RE: https://github.com/GoogleCloudPlatform/google-cloud-node/issues/2224
done();
return;
}

storage.getBuckets({
prefix: TESTS_PREFIX
}, function(err, buckets) {
Expand Down Expand Up @@ -482,6 +474,13 @@ describe('storage', function() {
});

describe('buckets', function() {
var bucket;

before(function() {
bucket = storage.bucket(generateName('bucket'));
return bucket.create();
});

it('should get a policy', function(done) {
bucket.iam.getPolicy(function(err, policy) {
assert.ifError(err);
Expand All @@ -507,38 +506,43 @@ describe('storage', function() {
});

it('should set a policy', function(done) {
var policy = {
bindings: [
{
role: 'roles/storage.legacyBucketReader',
members: [
'allUsers'
]
}
]
};

bucket.iam.setPolicy(policy, function(err, newPolicy) {
bucket.iam.getPolicy(function(err, policy) {
assert.ifError(err);
assert.deepEqual(newPolicy.bindings, policy.bindings);
done();

policy.bindings.push({
role: 'roles/storage.legacyBucketReader',
members: [
'allUsers'
]
});

bucket.iam.setPolicy(policy, function(err, newPolicy) {
assert.ifError(err);

var legacyBucketReaderBinding = newPolicy.bindings
.filter(function(binding) {
return binding.role === 'roles/storage.legacyBucketReader';
})[0];

assert(legacyBucketReaderBinding.members.includes('allUsers'));

done();
});
});
});

it('should test the iam permissions', function(done) {
var testPermissions = [
'storage.buckets.get',

// Unable to test.
// RE: https://github.com/GoogleCloudPlatform/google-cloud-node/issues/2224
// 'storage.buckets.getIamPolicy'
'storage.buckets.getIamPolicy'
];

bucket.iam.testPermissions(testPermissions, function(err, permissions) {
assert.ifError(err);

assert.deepEqual(permissions, {
'storage.buckets.get': true
'storage.buckets.get': true,
'storage.buckets.getIamPolicy': true
});

done();
Expand Down Expand Up @@ -593,12 +597,6 @@ describe('storage', function() {

describe('bucket metadata', function() {
it('should allow setting metadata on a bucket', function(done) {
if (IS_CI) {
// RE: https://github.com/GoogleCloudPlatform/google-cloud-node/issues/2224
this.skip();
return;
}

var metadata = {
website: {
mainPageSuffix: 'http://fakeuri',
Expand Down Expand Up @@ -960,8 +958,7 @@ describe('storage', function() {
});
});

// RE: https://github.com/GoogleCloudPlatform/google-cloud-node/issues/2224
(IS_CI ? describe.skip : describe)('write/read/remove files', function() {
describe('write, read, and remove files', function() {
before(function(done) {
function setHash(filesKey, done) {
var file = FILES[filesKey];
Expand Down Expand Up @@ -1406,8 +1403,7 @@ describe('storage', function() {
});
});

// RE: https://github.com/GoogleCloudPlatform/google-cloud-node/issues/2224
(IS_CI ? describe.skip : describe)('combine files', function() {
describe('combine files', function() {
it('should combine multiple files into one', function(done) {
var files = [
{ file: bucket.file('file-one.txt'), contents: '123' },
Expand Down Expand Up @@ -1439,8 +1435,7 @@ describe('storage', function() {
});
});

// RE: https://github.com/GoogleCloudPlatform/google-cloud-node/issues/2224
(IS_CI ? describe.skip : describe)('list files', function() {
describe('list files', function() {
var NEW_FILES = [
bucket.file('CloudLogo1'),
bucket.file('CloudLogo2'),
Expand Down Expand Up @@ -1594,7 +1589,7 @@ describe('storage', function() {
});
});

(IS_CI ? describe.skip : describe)('sign urls', function() {
describe('sign urls', function() {
var localFile = fs.readFileSync(FILES.logo.path);
var file;

Expand Down Expand Up @@ -1642,8 +1637,7 @@ describe('storage', function() {
});
});

// RE: https://github.com/GoogleCloudPlatform/google-cloud-node/issues/2224
(IS_CI ? describe.skip : describe)('sign policy', function() {
describe('sign policy', function() {
var file;

before(function(done) {
Expand Down

0 comments on commit 21ce94f

Please sign in to comment.