Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
811342e3
Commit
811342e3
authored
Oct 10, 2019
by
Enrique Alcantara
Committed by
Tiger
Nov 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement error handling in auth form
Handle isAuthenticating state Handle authentication error state
parent
06c996be
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
102 additions
and
16 deletions
+102
-16
app/assets/javascripts/create_cluster/eks_cluster/components/create_eks_cluster.vue
...ate_cluster/eks_cluster/components/create_eks_cluster.vue
+1
-1
app/assets/javascripts/create_cluster/eks_cluster/components/service_credentials_form.vue
...uster/eks_cluster/components/service_credentials_form.vue
+34
-10
app/assets/javascripts/create_cluster/eks_cluster/store/state.js
...ets/javascripts/create_cluster/eks_cluster/store/state.js
+1
-1
spec/frontend/create_cluster/eks_cluster/components/service_credentials_form_spec.js
...r/eks_cluster/components/service_credentials_form_spec.js
+66
-4
No files found.
app/assets/javascripts/create_cluster/eks_cluster/components/create_eks_cluster.vue
View file @
811342e3
<
script
>
<
script
>
import
{
mapState
}
from
'
vuex
'
;
import
ServiceCredentialsForm
from
'
./service_credentials_form.vue
'
;
import
ServiceCredentialsForm
from
'
./service_credentials_form.vue
'
;
import
EksClusterConfigurationForm
from
'
./eks_cluster_configuration_form.vue
'
;
import
EksClusterConfigurationForm
from
'
./eks_cluster_configuration_form.vue
'
;
import
{
mapState
}
from
'
vuex
'
;
export
default
{
export
default
{
components
:
{
components
:
{
...
...
app/assets/javascripts/create_cluster/eks_cluster/components/service_credentials_form.vue
View file @
811342e3
<
script
>
<
script
>
import
{
GlFormInput
,
GlButton
}
from
'
@gitlab/ui
'
;
import
{
GlFormInput
}
from
'
@gitlab/ui
'
;
import
{
sprintf
,
s__
}
from
'
~/locale
'
;
import
{
sprintf
,
s__
,
__
}
from
'
~/locale
'
;
import
_
from
'
underscore
'
;
import
_
from
'
underscore
'
;
import
{
mapState
}
from
'
vuex
'
;
import
{
mapState
,
mapActions
}
from
'
vuex
'
;
import
ClipboardButton
from
'
~/vue_shared/components/clipboard_button.vue
'
;
import
ClipboardButton
from
'
~/vue_shared/components/clipboard_button.vue
'
;
import
LoadingButton
from
'
~/vue_shared/components/loading_button.vue
'
;
export
default
{
export
default
{
components
:
{
components
:
{
GlFormInput
,
GlFormInput
,
Gl
Button
,
Loading
Button
,
ClipboardButton
,
ClipboardButton
,
},
},
props
:
{
props
:
{
...
@@ -27,7 +28,15 @@ export default {
...
@@ -27,7 +28,15 @@ export default {
};
};
},
},
computed
:
{
computed
:
{
...
mapState
([
'
accountId
'
,
'
externalId
'
]),
...
mapState
([
'
accountId
'
,
'
externalId
'
,
'
isCreatingRole
'
,
'
createRoleError
'
]),
submitButtonDisabled
()
{
return
this
.
isCreatingRole
||
!
this
.
roleArn
;
},
submitButtonLabel
()
{
return
this
.
isCreatingRole
?
__
(
'
Authenticating
'
)
:
s__
(
'
ClusterIntegration|Authenticate with AWS
'
);
},
accountAndExternalIdsHelpText
()
{
accountAndExternalIdsHelpText
()
{
const
escapedUrl
=
_
.
escape
(
this
.
accountAndExternalIdsHelpPath
);
const
escapedUrl
=
_
.
escape
(
this
.
accountAndExternalIdsHelpPath
);
...
@@ -61,6 +70,14 @@ export default {
...
@@ -61,6 +70,14 @@ export default {
);
);
},
},
},
},
methods
:
{
...
mapActions
([
'
createRole
'
]),
handleAuthenticate
()
{
const
{
roleArn
,
externalId
}
=
this
;
this
.
createRole
({
roleArn
,
externalId
});
},
},
};
};
</
script
>
</
script
>
<
template
>
<
template
>
...
@@ -73,11 +90,14 @@ export default {
...
@@ -73,11 +90,14 @@ export default {
)
)
}}
}}
</p>
</p>
<div
v-if=
"createRoleError"
class=
"js-invalid-credentials bs-callout bs-callout-danger"
>
{{
createRoleError
}}
</div>
<div
class=
"form-row"
>
<div
class=
"form-row"
>
<div
class=
"form-group col-md-6"
>
<div
class=
"form-group col-md-6"
>
<label
for=
"gitlab-account-id"
>
{{
__
(
'
Account ID
'
)
}}
</label>
<label
for=
"gitlab-account-id"
>
{{
__
(
'
Account ID
'
)
}}
</label>
<div
class=
"input-group"
>
<div
class=
"input-group"
>
<gl-form-input
type=
"text"
readonly
:value=
"accountId"
id=
"gitlab-account-i
d"
/>
<gl-form-input
id=
"gitlab-account-id"
type=
"text"
readonly
:value=
"accountI
d"
/>
<div
class=
"input-group-append"
>
<div
class=
"input-group-append"
>
<clipboard-button
<clipboard-button
:text=
"accountId"
:text=
"accountId"
...
@@ -90,7 +110,7 @@ export default {
...
@@ -90,7 +110,7 @@ export default {
<div
class=
"form-group col-md-6"
>
<div
class=
"form-group col-md-6"
>
<label
for=
"eks-external-id"
>
{{
__
(
'
External ID
'
)
}}
</label>
<label
for=
"eks-external-id"
>
{{
__
(
'
External ID
'
)
}}
</label>
<div
class=
"input-group"
>
<div
class=
"input-group"
>
<gl-form-input
type=
"text"
readonly
:value=
"externalId"
id=
"eks-external-i
d"
/>
<gl-form-input
id=
"eks-external-id"
type=
"text"
readonly
:value=
"externalI
d"
/>
<div
class=
"input-group-append"
>
<div
class=
"input-group-append"
>
<clipboard-button
<clipboard-button
:text=
"externalId"
:text=
"externalId"
...
@@ -109,8 +129,12 @@ export default {
...
@@ -109,8 +129,12 @@ export default {
<gl-form-input
id=
"eks-provision-role-arn"
v-model=
"roleArn"
/>
<gl-form-input
id=
"eks-provision-role-arn"
v-model=
"roleArn"
/>
<p
class=
"form-text text-muted"
v-html=
"provisionRoleArnHelpText"
></p>
<p
class=
"form-text text-muted"
v-html=
"provisionRoleArnHelpText"
></p>
</div>
</div>
<gl-button
class=
"js-submit-service-credentials"
:disabled=
"!roleArn"
>
<loading-button
{{
s__
(
'
ClusterIntegration|Authenticate with AWS
'
)
}}
class=
"js-submit-service-credentials"
</gl-button>
:disabled=
"submitButtonDisabled"
:loading=
"isCreatingRole"
:label=
"submitButtonLabel"
@
click=
"handleAuthenticate($event)"
/>
</form>
</form>
</
template
>
</
template
>
app/assets/javascripts/create_cluster/eks_cluster/store/state.js
View file @
811342e3
import
{
KUBERNETES_VERSIONS
}
from
'
../constants
'
;
import
{
KUBERNETES_VERSIONS
}
from
'
../constants
'
;
export
default
()
=>
({
export
default
()
=>
({
is
ValidatingCredentials
:
false
,
is
Authenticating
:
false
,
hasCredentials
:
false
,
hasCredentials
:
false
,
invalidCredentials
:
false
,
invalidCredentials
:
false
,
invalidCredentialsError
:
null
,
invalidCredentialsError
:
null
,
...
...
spec/frontend/create_cluster/eks_cluster/components/service_credentials_form_spec.js
View file @
811342e3
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
Vuex
from
'
vuex
'
;
import
{
shallowMount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
ServiceCredentialsForm
from
'
~/create_cluster/eks_cluster/components/service_credentials_form.vue
'
;
import
ServiceCredentialsForm
from
'
~/create_cluster/eks_cluster/components/service_credentials_form.vue
'
;
import
LoadingButton
from
'
~/vue_shared/components/loading_button.vue
'
;
import
eksClusterState
from
'
~/create_cluster/eks_cluster/store/state
'
;
const
localVue
=
createLocalVue
();
localVue
.
use
(
Vuex
);
describe
(
'
ServiceCredentialsForm
'
,
()
=>
{
describe
(
'
ServiceCredentialsForm
'
,
()
=>
{
let
vm
;
let
vm
;
let
state
;
let
createRoleAction
;
const
accountId
=
'
accountId
'
;
const
accountId
=
'
accountId
'
;
const
externalId
=
'
externalId
'
;
const
externalId
=
'
externalId
'
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
state
=
Object
.
assign
(
eksClusterState
(),
{
accountId
,
externalId
,
});
createRoleAction
=
jest
.
fn
();
const
store
=
new
Vuex
.
Store
({
state
,
actions
:
{
createRole
:
createRoleAction
,
},
});
vm
=
shallowMount
(
ServiceCredentialsForm
,
{
vm
=
shallowMount
(
ServiceCredentialsForm
,
{
propsData
:
{
propsData
:
{
accountId
,
externalId
,
accountAndExternalIdsHelpPath
:
''
,
accountAndExternalIdsHelpPath
:
''
,
createRoleArnHelpPath
:
''
,
createRoleArnHelpPath
:
''
,
},
},
localVue
,
store
,
});
});
});
});
afterEach
(()
=>
vm
.
destroy
());
afterEach
(()
=>
vm
.
destroy
());
...
@@ -23,7 +44,8 @@ describe('ServiceCredentialsForm', () => {
...
@@ -23,7 +44,8 @@ describe('ServiceCredentialsForm', () => {
const
findCopyAccountIdButton
=
()
=>
vm
.
find
(
'
.js-copy-account-id-button
'
);
const
findCopyAccountIdButton
=
()
=>
vm
.
find
(
'
.js-copy-account-id-button
'
);
const
findExternalIdInput
=
()
=>
vm
.
find
(
'
#eks-external-id
'
);
const
findExternalIdInput
=
()
=>
vm
.
find
(
'
#eks-external-id
'
);
const
findCopyExternalIdButton
=
()
=>
vm
.
find
(
'
.js-copy-external-id-button
'
);
const
findCopyExternalIdButton
=
()
=>
vm
.
find
(
'
.js-copy-external-id-button
'
);
const
findSubmitButton
=
()
=>
vm
.
find
(
'
.js-submit-service-credentials
'
);
const
findInvalidCredentials
=
()
=>
vm
.
find
(
'
.js-invalid-credentials
'
);
const
findSubmitButton
=
()
=>
vm
.
find
(
LoadingButton
);
it
(
'
displays provided account id
'
,
()
=>
{
it
(
'
displays provided account id
'
,
()
=>
{
expect
(
findAccountIdInput
().
attributes
(
'
value
'
)).
toBe
(
accountId
);
expect
(
findAccountIdInput
().
attributes
(
'
value
'
)).
toBe
(
accountId
);
...
@@ -50,4 +72,44 @@ describe('ServiceCredentialsForm', () => {
...
@@ -50,4 +72,44 @@ describe('ServiceCredentialsForm', () => {
expect
(
findSubmitButton
().
attributes
(
'
disabled
'
)).
toBeFalsy
();
expect
(
findSubmitButton
().
attributes
(
'
disabled
'
)).
toBeFalsy
();
});
});
it
(
'
dispatches authenticate action when submit button is clicked
'
,
()
=>
{
findSubmitButton
().
vm
.
$emit
(
'
click
'
);
expect
(
createRoleAction
).
toHaveBeenCalled
();
});
describe
(
'
when is creating role
'
,
()
=>
{
beforeEach
(()
=>
{
vm
.
setData
({
roleArn
:
'
123
'
});
// set role ARN to enable button
state
.
isCreatingRole
=
true
;
});
it
(
'
disables submit button
'
,
()
=>
{
expect
(
findSubmitButton
().
props
(
'
disabled
'
)).
toBe
(
true
);
});
it
(
'
sets submit button as loading
'
,
()
=>
{
expect
(
findSubmitButton
().
props
(
'
loading
'
)).
toBe
(
true
);
})
it
(
'
displays Authenticating label on submit button
'
,
()
=>
{
expect
(
findSubmitButton
().
props
(
'
label
'
)).
toBe
(
'
Authenticating
'
);
});
})
describe
(
'
when role can’t be created
'
,
()
=>
{
beforeEach
(()
=>
{
state
.
createRoleError
=
'
Invalid credentials
'
;
});
it
(
'
displays invalid role warning banner
'
,
()
=>
{
expect
(
findInvalidCredentials
().
exists
()).
toBe
(
true
);
});
it
(
'
displays invalid role error message
'
,
()
=>
{
expect
(
findInvalidCredentials
().
text
()).
toContain
(
state
.
createRoleError
);
});
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment