Skip to content
This repository has been archived by the owner on Mar 11, 2021. It is now read-only.

validation added for create env #22

Merged
merged 7 commits into from
Jan 14, 2019

Conversation

nurali-techie
Copy link
Contributor

@nurali-techie nurali-techie commented Jan 7, 2019

Validation added for clusterApiURL.

Fixes: #20

@codecov
Copy link

codecov bot commented Jan 9, 2019

Codecov Report

Merging #22 into master will decrease coverage by 0.22%.
The diff coverage is 60%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #22      +/-   ##
==========================================
- Coverage   61.76%   61.53%   -0.23%     
==========================================
  Files           6        6              
  Lines         306      325      +19     
==========================================
+ Hits          189      200      +11     
- Misses        104      111       +7     
- Partials       13       14       +1
Impacted Files Coverage Δ
configuration/configuration.go 46.66% <0%> (-2.18%) ⬇️
controller/environment.go 86.2% <78.94%> (-0.28%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aa3b173...a15f2d7. Read the comment docs.

@nurali-techie nurali-techie changed the title WIP: validation added for create env validation added for create env Jan 14, 2019
@nurali-techie nurali-techie requested a review from xcoulon January 14, 2019 07:29
return nil
}
}
return errors.NewInternalErrorFromString(fmt.Sprintf("cluster with URL '%s' not linked with user account", clusterURL))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you return an InternalServerError here? Could you return something more explicit, such as Forbidden if the cluster is not linked to the user?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done a15f2d7

spaceID := uuid.NewV4()
payload := newCreateEnvironmentPayload("osio-stage", "stage", "cluster2.com")

_, err := test.CreateEnvironmentInternalServerError(t, s.ctx, s.svc, s.ctrl, spaceID, payload)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see question above about the InternalServerError returned when the cluster is not linked to the user.

@@ -132,3 +143,17 @@ func (c *EnvironmentController) Show(ctx *app.ShowEnvironmentContext) error {
}
return ctx.OK(res)
}

func (c *EnvironmentController) checkClustersUser(ctx context.Context, clusterURL string) error {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add a test for this func?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this link test is added to test this function only. If you observe blackbox_tests, it is a way to test all different combination. This new test is added such that only checkClustersUser function is tested rest are assumed to be working. Do you still see need to add test, which will have less pre-setup but everything else same as from part of blackbox test ??

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, fair enough, if all cases in the this function are covered but your blackbox tests

@@ -132,3 +143,17 @@ func (c *EnvironmentController) Show(ctx *app.ShowEnvironmentContext) error {
}
return ctx.OK(res)
}

func (c *EnvironmentController) checkClustersUser(ctx context.Context, clusterURL string) error {
clusters, err := c.clusterService.UserClusters(ctx)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, if can be simplified in the future, once fabric8-services/fabric8-cluster#59 is done

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't use /api/clusters with URL as we need clusters who linked to users. For ex, we call /api/clusters with URL and we get response with cluster_details. It just mean that the cluster is a valid cluster and available with cluster_service but it can't guarantee that the cluster is linked to user also.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nurali-techie ok, my bad indeed! In that case, would you need a new endpoint such as /api/user/cluster?url=... to get a single response (or 404 if the user is not linked to the cluster with the given URL)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kool, so we don't have such a endpoint today.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, but if you need it, please open an issue and I'll take care of it

Copy link

@xcoulon xcoulon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for taking my change request into account @nurali-techie ;)

@nurali-techie
Copy link
Contributor Author

@nurali-techie nurali-techie merged commit d556c07 into fabric8-services:master Jan 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants