message: test: grant proper permissions to bucket destination
diff: @@ -32,31 +32,34 @@ nock(HOST_ADDRESS)
  .replyWithError({code: 'ENOTFOUND'})
  .persist();
  -describe('Logging', () => {
  - let PROJECT_ID: string;
  - const TESTS_PREFIX = 'nodejs-logging-system-test';
  - const WRITE_CONSISTENCY_DELAY_MS = 5000;
  -
  +describe('Logging', async () => {
  const bigQuery = new BigQuery();
  const pubsub = new PubSub();
  const storage = new Storage();
  const logging = new Logging();
  + const PROJECT_ID = await logging.auth.getProjectId();
  + const TESTS_PREFIX = 'nodejs-logging-system-test';
  + const WRITE_CONSISTENCY_DELAY_MS = 5000;
  +
  // Create the possible destinations for sinks that we will create.
  const bucket = storage.bucket(generateName());
  const dataset = bigQuery.dataset(generateName().replace(/-/g, '_'));
  const topic = pubsub.topic(generateName());
  - before(async () => {
  - await Promise.all([
  - bucket.create(),
  - dataset.create(),
  - topic.create(),
  - logging.auth.getProjectId().then(projectId => {
  - PROJECT_ID = projectId;
  - }),
  - ]);
  + const serviceAccount = (await logging.auth.getCredentials()).client_email;
  +
  + await bucket.create();
  + await bucket.iam.setPolicy({
  + bindings: [
  + {
  + role: 'roles/storage.admin',
  + members: [`serviceAccount:${serviceAccount}`],
  + },
  + ],
  });
  + await dataset.create();
  + await topic.create();
  after(async () => {
  const oneHourAgo = new Date();
  @@ -71,19 +74,15 @@ describe('Logging', () => {
  ]);
  async function deleteBuckets() {
  - const [buckets] = await storage.getBuckets({
  - prefix: TESTS_PREFIX,
  - });
  - return Promise.all(
  - buckets
  - .filter(bucket => {
  + const [buckets] = await storage.getBuckets({prefix: TESTS_PREFIX});
  + const bucketsToDelete = buckets.filter(bucket => {
  return new Date(bucket.metadata.timeCreated) < oneHourAgo;
  - })
  - .map(async bucket => {
  + });
  +
  + for (const bucket of bucketsToDelete) {
  await bucket.deleteFiles();
  await bucket.delete();
  - })
  - );
  + }
  }
  async function deleteDatasets() {
  