MCPcopy
hub / github.com/IBM/sarama / TestClusterAdminCreateTopicWithoutAuthorization

Function TestClusterAdminCreateTopicWithoutAuthorization

admin_test.go:121–149  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

119}
120
121func TestClusterAdminCreateTopicWithoutAuthorization(t *testing.T) {
122 seedBroker := NewMockBroker(t, 1)
123 defer seedBroker.Close()
124
125 seedBroker.SetHandlerByMap(map[string]MockResponse{
126 "MetadataRequest": NewMockMetadataResponse(t).
127 SetController(seedBroker.BrokerID()).
128 SetBroker(seedBroker.Addr(), seedBroker.BrokerID()),
129 "CreateTopicsRequest": NewMockCreateTopicsResponse(t),
130 })
131
132 config := NewTestConfig()
133 config.Version = V0_11_0_0
134
135 admin, err := NewClusterAdmin([]string{seedBroker.Addr()}, config)
136 if err != nil {
137 t.Fatal(err)
138 }
139
140 err = admin.CreateTopic("_internal_topic", &TopicDetail{NumPartitions: 1, ReplicationFactor: 1}, false)
141 want := "insufficient permissions to create topic with reserved prefix"
142 if !strings.HasSuffix(err.Error(), want) {
143 t.Fatal(err)
144 }
145 err = admin.Close()
146 if err != nil {
147 t.Fatal(err)
148 }
149}
150
151func TestClusterAdminListTopics(t *testing.T) {
152 seedBroker := NewMockBroker(t, 1)

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
SetHandlerByMapMethod · 0.95
BrokerIDMethod · 0.95
AddrMethod · 0.95
CreateTopicMethod · 0.95
CloseMethod · 0.95
NewMockBrokerFunction · 0.85
NewMockMetadataResponseFunction · 0.85
NewClusterAdminFunction · 0.85
SetBrokerMethod · 0.80
SetControllerMethod · 0.80

Tested by

no test coverage detected