for _, node := range p { vid, _ := dproxy.New(node).M("vendorThingID").String() if vid == newVid { return true } } return false }).Should(Equal(true)) By("Get a login user") uid, ut, err := util.UserLogin(app, "user123", "pass") Expect(err).To(Succeed()) user = common.User{ID: uid, Token: ut} By("Add the logged-in user as owner of gateway") Expect(util.AddOwner(app, user.ID, user.Token, gwID, "password")).To(Succeed()) By("onboard end-node to cloud") enID, err = util.OnboardNode(app, user, gwID, newVid, "pass") Expect(err).To(Succeed()) Expect(enID).ShouldNot(Equal("")) By("Notify gateway-agent with end-node onboard completion") _, err = util.MapNode(tConfig.GatewayAddress, app, common.Node{ID: enID, VID: newVid}, t) Expect(err).To(Succeed()) By("Subscribe to receiving commands") var ( command common.Command lock sync.Mutex )
properties, _ := dproxy.New(node).M("thingProperties").Map() states, _ := dproxy.New(node).M("states").Map() if vid == newVid && properties != nil && states != nil { return true } } return false }).Should(Equal(true)) By("Get a login user") uid, ut, err := util.UserLogin(app, "user123", "pass") user = common.User{ID: uid, Token: ut} Expect(err).To(Succeed()) By("Add the logged-in user as owner of gateway") err = util.AddOwner(app, user.ID, user.Token, gwID, "password") Expect(err).To(Succeed()) By("Onboard new end-node to cloud") enID, err = util.OnboardNode(app, user, gwID, newVid, "pass") Expect(err).To(Succeed()) Expect(enID).ShouldNot(Equal("")) By("Notify gateway-agent with onboarding end-node completion") _, err = util.MapNode(tConfig.GatewayAddress, app, common.Node{ID: enID, VID: newVid}, t) Expect(err).To(Succeed()) By("New end-node should be in the onboarded list") Eventually(func() bool { p, _, err := util.ListOnboardedNodes(tConfig.GatewayAddress, app, t) if err != nil {
var eGwID string var eEnVID string var eEnID string var client1 mqtt.Client BeforeEach(func() { master = tConfig.Apps["master"] addr = tConfig.GatewayAddress en = tConfig.Apps["enApp1"] By("Prepare endnode app") uid, ut, err := util.UserLogin(en, "user123", "pass") eUser = common.User{ID: uid, Token: ut} Expect(err).To(Succeed()) gwID, err := util.OnboardGatewayAnonymous(en, gwConfig.Gateway.VendorThingID, gwConfig.Gateway.ThingPassword) Expect(err).To(Succeed()) Expect(util.AddOwner(en, eUser.ID, eUser.Token, gwID, gwConfig.Gateway.ThingPassword)).To(Succeed()) eGwID = gwID enVid := fmt.Sprintf("vid-%d", time.Now().UnixNano()/int64(time.Millisecond)) enID, err := util.OnboardNode(en, eUser, eGwID, enVid, "pass") Expect(err).To(Succeed()) Expect(enID).NotTo(Equal("")) eEnID = enID eEnVID = enVid By("Prepare gateway app") uid, ut, err = util.UserLogin(master, "user123", "pass") mUser = common.User{ID: uid, Token: ut} Expect(err).To(Succeed()) gwID, err = util.OnboardGatewayAnonymous(master, gwConfig.Gateway.VendorThingID, gwConfig.Gateway.ThingPassword) Expect(err).To(Succeed()) Expect(util.AddOwner(master, mUser.ID, mUser.Token, gwID, gwConfig.Gateway.ThingPassword)).To(Succeed())