diff --git a/client/lib/application/src/access-form/access-form.jsx b/client/lib/application/src/access-form/access-form.jsx
index c6d4ad40..c2042409 100644
--- a/client/lib/application/src/access-form/access-form.jsx
+++ b/client/lib/application/src/access-form/access-form.jsx
@@ -11,7 +11,7 @@ import MINT_BUCKET_TEMPLATE from 'MINT_BUCKET_TEMPLATE';
function getDefaultBucket(account) {
return MINT_BUCKET_TEMPLATE
- .replace("${id}", account.id);
+ .replace('${id}', account.id);
}
class AccessForm extends React.Component {
@@ -130,9 +130,10 @@ class AccessForm extends React.Component {
Activate credential distribution into these S3 buckets (Naming Conventions). A *
indicates unsaved changes.
{ this.state.s3_buckets.length === 0 && defaultAccount ?
-
+
Psst, your mint bucket is probably:
{getDefaultBucket(defaultAccount)}
diff --git a/client/lib/application/test/access-form.test.js b/client/lib/application/test/access-form.test.js
index 6abab2c4..ccf7c17c 100644
--- a/client/lib/application/test/access-form.test.js
+++ b/client/lib/application/test/access-form.test.js
@@ -10,7 +10,7 @@ import UserStore from 'common/src/data/user/user-store';
import UserActions from 'common/src/data/user/user-actions';
import AccessForm from 'application/src/access-form/access-form.jsx';
-const MOCK_KIO = {
+const OAUTH_KIO = {
id: 'kio',
username: 'kio-robot',
last_password_rotation: '2015-01-01T12:42:41Z',
@@ -20,13 +20,21 @@ const MOCK_KIO = {
has_problems: false,
redirect_url: 'http://example.com/oauth',
s3_buckets: [
- 'kio-stups-bucket'
],
scopes: [{
resource_type_id: 'customer',
scope_id: 'read_all'
}]
-};
+},
+APP_KIO = {
+ id: 'kio',
+ team_id: 'stups',
+ active: true
+},
+ACCOUNTS = [{
+ id: '123',
+ name: 'stups'
+}];
class MockFlux extends Flummox {
constructor() {
@@ -58,10 +66,13 @@ describe('The access control form view', () => {
flux.getStore('essentials').receiveScopes(['customer', [{
id: 'read_all'
}]]);
- flux.getStore('mint').receiveOAuthConfig(['kio', MOCK_KIO]);
+ flux.getStore('mint').receiveOAuthConfig(['kio', OAUTH_KIO]);
+ flux.getStore('kio').receiveApplication(APP_KIO);
+ flux.getStore('user').receiveAccounts(ACCOUNTS);
actionSpy = sinon.stub(flux.getActions('mint'), 'saveOAuthConfig', () => {
return Promise.resolve();
});
+
props = {
flux: flux,
applicationId: 'kio'
@@ -74,4 +85,25 @@ describe('The access control form view', () => {
TestUtils.Simulate.submit(f);
expect(actionSpy.calledOnce).to.be.true;
});
+
+ it('should suggest a mint bucket', () => {
+ TestUtils.findRenderedDOMComponentWithAttributeValue(form, 'data-block', 'mint-bucket-suggestion');
+ });
+
+ it('should add suggested bucket to list', () => {
+ expect(() => {
+ TestUtils.findRenderedDOMComponentWithAttributeValue(form, 'data-block', 'editable-list-item');
+ }).to.throw;
+ let btn = TestUtils.findRenderedDOMComponentWithAttributeValue(form, 'data-block', 'mint-bucket-add-suggestion');
+ TestUtils.Simulate.click(btn);
+ TestUtils.findRenderedDOMComponentWithAttributeValue(form, 'data-block', 'editable-list-item');
+ });
+
+ it('should not suggest after adding', () => {
+ let btn = TestUtils.findRenderedDOMComponentWithAttributeValue(form, 'data-block', 'mint-bucket-add-suggestion');
+ TestUtils.Simulate.click(btn);
+ expect(() => {
+ TestUtils.findRenderedDOMComponentWithAttributeValue(form, 'data-block', 'mint-bucket-suggestion');
+ }).to.throw;
+ });
});
\ No newline at end of file
diff --git a/client/mocha-globals.js b/client/mocha-globals.js
index 0e998062..0dd9d58f 100644
--- a/client/mocha-globals.js
+++ b/client/mocha-globals.js
@@ -116,4 +116,4 @@ global.YTENV_SERVICE_URL_TLD = '';
global.YTENV_DOCKER_REGISTRY = '';
global.YTENV_RESOURCE_WHITELIST = '';
global.YTENV_APPLICATION_WHITELIST = '';
-global.YTENV_MINT_BUCKET_TEMPLATE = '';
\ No newline at end of file
+global.YTENV_MINT_BUCKET_TEMPLATE = '';
diff --git a/client/webpack.production.config.js b/client/webpack.production.config.js
index 16b7cfc8..da724e19 100644
--- a/client/webpack.production.config.js
+++ b/client/webpack.production.config.js
@@ -61,7 +61,8 @@ module.exports = {
DOCKER_REGISTRY: 'YTENV_DOCKER_REGISTRY',
SERVICE_URL_TLD: 'YTENV_SERVICE_URL_TLD',
RESOURCE_WHITELIST: 'YTENV_RESOURCE_WHITELIST',
- APPLICATION_WHITELIST: 'YTENV_APPLICATION_WHITELIST'
+ APPLICATION_WHITELIST: 'YTENV_APPLICATION_WHITELIST',
+ MINT_BUCKET_TEMPLATE: 'YTENV_MINT_BUCKET_TEMPLATE'
},
eslint: {
configFile: './.eslintrc',
diff --git a/client/webpack.test.config.js b/client/webpack.test.config.js
index 84c8d18d..ffad0369 100644
--- a/client/webpack.test.config.js
+++ b/client/webpack.test.config.js
@@ -56,6 +56,7 @@ module.exports = {
SERVICE_URL_TLD: 'YTENV_SERVICE_URL_TLD',
RESOURCE_WHITELIST: 'YTENV_RESOURCE_WHITELIST',
APPLICATION_WHITELIST: 'YTENV_APPLICATION_WHITELIST',
+ MINT_BUCKET_TEMPLATE: 'YTENV_MINT_BUCKET_TEMPLATE',
// needed because otherwise two react instances
// are running in tests and they trip each other up
react: 'var React'