-
Notifications
You must be signed in to change notification settings - Fork 29
Reverse lookup tenant by cluster/namespace (openshiftio/openshiftio#1389) #476
Reverse lookup tenant by cluster/namespace (openshiftio/openshiftio#1389) #476
Conversation
…389) Added an endpoint for `GET /api/tenants?cluster_url=x&namespace=y` The response will be a list of tenants with a single entry, or `404` if none was found. The request MUST be sent using the SA token. Fixes openshiftio/openshiftio#1389 Signed-off-by: Xavier Coulon <xcoulon@redhat.com>
@xcoulon snapshot fabric8-tenant image is available for testing. |
}, | ||
// skipping the paging links for now | ||
Meta: &app.TenantListMeta{ | ||
TotalCount: 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there only can be one result, why bother with a list at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM apart from one comment.
tenant/service_test.go
Outdated
func (s *TenantServiceTestSuite) TestLookupTenantByNamespace() { | ||
s.T().Run("ok", func(t *testing.T) { | ||
// given | ||
fxt := testfixture.NewTestFixture(s.T(), s.DB, testfixture.Tenants(1), testfixture.Namespaces(1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically fxt := testfixture.NewTestFixture(s.T(), s.DB, testfixture.Namespaces(1))
is enough due to the dependency on Tenants
right?
Btw. I would import the testfixture as tf
for more readability.
Also, you must not pass s.T()
but t
here and in all other places as well. Failing an outer test from the inside is really hard to debug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah right, I had changed a few t
/ s.T()
as I remembered you already warned me about this bug, but I guess I forgot a few places :/ And yes, fxt := testfixture.NewTestFixture(s.T(), s.DB, testfixture.Namespaces(1))
should be enough, but I wanted to be explicit on the fact that we need a Tenant
because it's what we're actually searching in this test.
Signed-off-by: Xavier Coulon <xcoulon@redhat.com>
test/testfixture/make_functions.go
Outdated
@@ -37,7 +37,7 @@ func makeNamespaces(fxt *TestFixture) error { | |||
tenantService := tenant.NewDBService(fxt.db) | |||
for i := range fxt.Namespaces { | |||
fxt.Namespaces[i] = &tenant.Namespace{ | |||
Type: tenant.TypeUser, | |||
Type: tenant.TypeChe, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what the default type should be here but I trust you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGMT
@xcoulon snapshot fabric8-tenant image is available for testing. |
[test] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't test this PR! But the changes look good to me overall.
thanks for the reviews, @kwk and @alexeykazakov ! |
@xcoulon snapshot fabric8-tenant image is available for testing. |
@xcoulon snapshot fabric8-tenant image is available for testing. |
Added an endpoint for
GET /api/tenants?cluster_url=x&namespace=y
The response will be a list of tenants with a single entry, or
404
if none was found.
The request MUST be sent using the SA token.
Fixes openshiftio/openshiftio#1389
Signed-off-by: Xavier Coulon xcoulon@redhat.com