diff --git a/backend/pkg/api/api_integration_test.go b/backend/pkg/api/api_integration_test.go index b881d5d16..b7dbd0e60 100644 --- a/backend/pkg/api/api_integration_test.go +++ b/backend/pkg/api/api_integration_test.go @@ -181,6 +181,12 @@ type assertHooks struct { } func (a *assertHooks) isCallAllowed(topicName string) bool { + // The target system may have created internal topics, which + // use an underscore prefix by convention. The calls to such topics + // are expected and therefore are allowed. + if strings.HasPrefix(topicName, "_") { + return true + } pc, _, _, _ := runtime.Caller(1) fnName := runtime.FuncForPC(pc).Name() parts := strings.Split(fnName, ".") @@ -212,6 +218,7 @@ func (a *assertHooks) getCallReturnValue(topicName string) assertCallReturnValue func newAssertHooks(t *testing.T, returnValues map[string]map[string]assertCallReturnValue) *Hooks { h := &assertHooks{ + t: t, allowedCalls: map[string]map[string]bool{}, returnValues: map[string]map[string]assertCallReturnValue{}, } diff --git a/backend/pkg/api/handle_topics_integration_test.go b/backend/pkg/api/handle_topics_integration_test.go index 50b262fd2..caa04fd5c 100644 --- a/backend/pkg/api/handle_topics_integration_test.go +++ b/backend/pkg/api/handle_topics_integration_test.go @@ -77,10 +77,16 @@ func (s *APIIntegrationTestSuite) TestHandleGetTopics() { err := json.Unmarshal(body, &getRes) require.NoError(err) - require.Len(getRes.Topics, 3) - assert.Equal(testutil.TopicNameForTest("get_topics_0"), getRes.Topics[0].TopicName) - assert.Equal(testutil.TopicNameForTest("get_topics_1"), getRes.Topics[1].TopicName) - assert.Equal(testutil.TopicNameForTest("get_topics_2"), getRes.Topics[2].TopicName) + // There may be internal topics, thus we need to check GTE + require.GreaterOrEqual(len(getRes.Topics), 3) + topicNames := make([]string, len(getRes.Topics)) + for i, topicDetails := range getRes.Topics { + topicNames[i] = topicDetails.TopicName + } + + assert.Contains(topicNames, testutil.TopicNameForTest("get_topics_0")) + assert.Contains(topicNames, testutil.TopicNameForTest("get_topics_1")) + assert.Contains(topicNames, testutil.TopicNameForTest("get_topics_2")) }) t.Run("no see permission", func(t *testing.T) { @@ -108,12 +114,12 @@ func (s *APIIntegrationTestSuite) TestHandleGetTopics() { } }() - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 1000*time.Second) defer cancel() res, body := s.apiRequest(ctx, http.MethodGet, "/api/topics", nil) - assert.Equal(200, res.StatusCode) + require.Equal(200, res.StatusCode) type response struct { Topics []*console.TopicSummary `json:"topics"`