public function testValidate()
 {
     $the_device = $this->test_data->the_device;
     $tid = $this->token_model->add(array('serial' => $this->test_data->the_gateway->serial, 'mac' => $this->test_data->the_device->mac));
     $token = $this->token_model->load($tid);
     $this->assertNotNull($token);
     $ret = $this->_urlGet('/api/validation', array('serial' => $this->test_data->the_gateway->serial, 'ip' => fake_ip(), 'mac' => $the_device->mac, 'token' => $token->token, 'incoming' => 0, 'outgoing' => 0));
     $this->assertEquals($ret, 'Auth: 1');
 }
 public function testLogin()
 {
     // Testing the get
     $this->_urlGet($this->url('/api/login'), array('serial' => $this->data->the_gateway->serial, 'gateway_ip' => fake_ip(), 'gateway_port' => 12345, 'ip' => fake_ip(), 'mac' => $this->data->the_device->mac, 'url' => 'http://www.baidu.com'));
     $this->assertEquals($this->loginrequest_model->count_all(), 1);
 }
 public function testFakeIP()
 {
     $this->assertTrue($this->CI->input->valid_ip(fake_ip()));
 }
Example #4
0
function fake_gateway($owner_id, $name = null, $id = 1000, $serial = null)
{
    $CI =& get_instance();
    $CI->load->library('uuid');
    $the_serial = $serial ? $serial : $CI->uuid->get();
    $the_name = $name ? $name : 'Gateway[' . $id . ']';
    return (object) array('id' => $id, 'owner_id' => $owner_id, 'name' => $the_name, 'serial' => $the_serial, 'mac' => fake_mac(), 'ip' => ip2long(fake_ip()));
}