-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/ZENKO-4837' into tmp/octopus/w/2.7/feature/ZENK…
- Loading branch information
Showing
6 changed files
with
140 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Feature: Bucket Websites | ||
|
||
@2.6.0 | ||
@PreMerge | ||
@BucketWebsite | ||
Scenario Outline: Bucket Website CRUD | ||
# The scenario should test that we can put a bucket website configuration on a bucket | ||
# send an index.html | ||
# And also use a pensieve API to add the new endpoint to the list | ||
# Then using the local etc hosts, we should be able to load the html page | ||
Given an existing bucket "website" "" versioning, "without" ObjectLock "without" retention mode | ||
And an index html file | ||
When the user puts the bucket website configuration | ||
And the user creates an S3 Bucket policy granting public read access | ||
And the "<domain>" endpoint is added to the overlay | ||
Then the user should be able to load the index.html file from the "<domain>" endpoint | ||
|
||
Examples: | ||
| domain | | ||
| mywebsite.com | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import assert from 'assert'; | ||
import { Given, When, Then } from '@cucumber/cucumber'; | ||
import Zenko from '../../world/Zenko'; | ||
import { putObject } from '../utils/utils'; | ||
import { S3, Utils } from 'cli-testing'; | ||
|
||
const pageMessage = Utils.randomString(); | ||
|
||
Given('an index html file', async function (this: Zenko) { | ||
// push a file with a basic html content named index.html in the bucket | ||
const content = `<html><head><title>Index</title></head><body><h1>${pageMessage}</h1></body></html>`; | ||
this.addToSaved('objectSize', content.length); | ||
await putObject(this, 'index.html', content); | ||
}); | ||
|
||
When('the user puts the bucket website configuration', async function (this: Zenko) { | ||
const bucketWebSiteConfiguration = JSON.stringify({ | ||
IndexDocument: { | ||
Suffix: 'index.html', | ||
}, | ||
ErrorDocument: { | ||
Key: 'error.html', | ||
}, | ||
}); | ||
|
||
await S3.putBucketWebsite({ | ||
bucket: this.getSaved<string>('bucketName'), | ||
websiteConfiguration: bucketWebSiteConfiguration, | ||
}); | ||
}); | ||
|
||
When('the {string} endpoint is added to the overlay', async function (this: Zenko, endpoint: string) { | ||
await this.addWebsiteEndpoint(endpoint); | ||
}); | ||
|
||
When('the user creates an S3 Bucket policy granting public read access', async function (this: Zenko) { | ||
const policy = { | ||
Version: '2012-10-17', | ||
Statement: [ | ||
{ | ||
Sid: 'PublicReadGetObject', | ||
Effect: 'Allow', | ||
Principal: '*', | ||
Action: [ | ||
's3:GetObject', | ||
], | ||
Resource: [ | ||
`arn:aws:s3:::${this.getSaved<string>('bucketName')}/*`, | ||
], | ||
}, | ||
], | ||
}; | ||
await S3.putBucketPolicy({ | ||
bucket: this.getSaved<string>('bucketName'), | ||
policy: JSON.stringify(policy), | ||
}); | ||
}); | ||
|
||
Then('the user should be able to load the index.html file from the {string} endpoint', | ||
async function (this: Zenko, endpoint: string) { | ||
const baseUrl = this.parameters.ssl === false ? 'http://' : 'https://'; | ||
// The ingress may take some time to be ready (<60s) | ||
const uri = `${baseUrl}${this.getSaved<string>('bucketName')}.${endpoint}`; | ||
let response; | ||
let content; | ||
let tries = 60; | ||
|
||
while (tries > 0) { | ||
tries--; | ||
try { | ||
response = await fetch(uri); | ||
content = await response.text(); | ||
assert.strictEqual(content.includes(pageMessage), true); | ||
return; | ||
} catch (err) { | ||
this.logger.debug('Error when fetching the bucket website', { | ||
err, | ||
uri, | ||
response, | ||
content, | ||
}); | ||
await Utils.sleep(1000); | ||
} | ||
} | ||
assert.fail('Failed to fetch the bucket website after 20 tries'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters