         )
     )
 
+    it('should fail for an unlogged user', (done) ->
+        options = defaultQueryOptions('/sensors/', 'GET')
+        http.get(options, (res) ->
+            res.statusCode.should.eql(401)
+            done()
+        )
+    )
+
     it('should authenticate a user', (done) ->
         qstring = JSON.stringify({
             "username": "test",
             "password": "test"
         })
-        options = defaultQueryOptions('/login', 'POST')
+        options = defaultQueryOptions('/login/', 'POST')
         req = http.request(options)
         req.on('response', (res) ->
             res.on('data', (data) ->

port = 4000
user_id = null
api_key = null

defaultQueryOptions = (path, method) ->
    options = {

        req.end()
    )

    it('should give list of sensors for a logged user', (done) ->
        options = defaultQueryOptions('/sensors/', 'GET')
        http.get(options, (res) ->
            res.statusCode.should.eql(200)
            res.on('data', (data) ->
                body = data.toString('utf8')
                body = JSON.parse(body)

                # Fixtures currently have size 12
                body.should.have.length(12)
                first_sensor = body[0]
                first_sensor.should.have.property('identifier')
                first_sensor.identifier.should.be.eql('MOISTURE_3')

                first_sensor.should.have.property('model')
                first_sensor.should.have.property('hub')
                first_sensor.should.have.property('room')


            )
            done()
        )
    )

)
