Skip to content

Commit

Permalink
Fix Bootstrap service tests
Browse files Browse the repository at this point in the history
Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
  • Loading branch information
dborovcanin committed May 21, 2019
1 parent 1193bc7 commit a9d947e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
21 changes: 21 additions & 0 deletions bootstrap/mocks/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,27 @@ func (crm *configRepositoryMock) Update(config bootstrap.Config) error {
return nil
}

func (crm *configRepositoryMock) UpdateCert(owner, thingKey, clientCert, clientKey, caCert string) error {
crm.mu.Lock()
defer crm.mu.Unlock()
var forUpdate bootstrap.Config
for _, v := range crm.configs {
if v.MFKey == thingKey && v.Owner == owner {
forUpdate = v
break
}
}
if _, ok := crm.configs[forUpdate.MFThing]; !ok {
return bootstrap.ErrNotFound
}
forUpdate.ClientCert = clientCert
forUpdate.ClientKey = clientKey
forUpdate.CACert = caCert
crm.configs[forUpdate.MFThing] = forUpdate

return nil
}

func (crm *configRepositoryMock) UpdateConnections(key, id string, channels []bootstrap.Channel, connections []string) error {
crm.mu.Lock()
defer crm.mu.Unlock()
Expand Down
8 changes: 4 additions & 4 deletions bootstrap/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ type bootstrapRes struct {
MFThing string `json:"mainflux_id"`
MFKey string `json:"mainflux_key"`
MFChannels []channelRes `json:"mainflux_channels"`
ClientCert string `json:"client_cert"`
ClientKey string `json:"client_key"`
CaCert string `json:"ca_cert"`
Content string `json:"content"`
ClientCert string `json:"client_cert,omitempty"`
ClientKey string `json:"client_key,omitempty"`
CaCert string `json:"ca_cert,omitempty"`
Content string `json:"content,omitempty"`
}

type channelRes struct {
Expand Down

0 comments on commit a9d947e

Please sign in to comment.