# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. set_include_path(implode(PATH_SEPARATOR, array(get_include_path(), '/usr/share/yubikey-val', '/etc/yubico/val'))); require_once 'ykval-synclib.php'; require_once 'ykval-config.php'; require_once 'ykval-log.php'; if ($argc != 3) { print "warning and critical levels have to be given on commandline\n"; exit(3); } $warning = $argv[1]; $critical = $argv[2]; $sync = new SyncLib('ykval-verify:synclib'); $len = $sync->getQueueLength(); $message = "Queue length is {$len}"; if ($len > $critical) { print "CRITICAL: {$message}\n"; exit(2); } elseif ($len > $warning) { print "WARNING: {$message}\n"; exit(1); } else { print "OK: {$message}\n"; exit(0); }
public function testNullQueue() { $sl = new SyncLib(); $sl->syncServers = array("http://localhost/wsapi/syncvalid1", "http://doesntexist/wsapi/syncvalid2", "http://localhost/wsapi/syncvalid3"); $start_length = $sl->getQueueLength(); $p1 = array('modified' => 1259585588 + 1000, 'otp' => "ccccccccccccfrhiutjgfnvgdurgliidceuilikvfhui", 'yk_publicname' => "cccccccccccc", 'yk_counter' => 9, 'yk_use' => 3, 'yk_high' => 100, 'yk_low' => 1000); $this->assertTrue($sl->queue($p1, $p1)); $res = $sl->db->findByMultiple('queue', array("modified" => 1259585588 + 1000, "server_nonce" => $sl->server_nonce)); $lastRes = $res[0]; $info = $sl->otpParamsFromInfoString($lastRes['info']); $res = array('queued' => $lastRes['queued'], 'modified' => $lastRes['modified'], 'otp' => $lastRes['otp'], 'server' => $lastRes['server'], 'nonce' => $info['nonce'], 'yk_publicname' => $info['yk_publicname'], 'yk_counter' => $info['yk_counter'], 'yk_use' => $info['yk_use'], 'yk_high' => $info['yk_high'], 'yk_low' => $info['yk_low']); $this->assertNotNull($res['queued']); $res = $sl->sync(3); $this->assertEquals(1 + $start_length, $sl->getQueueLength()); $res = $sl->db->findByMultiple('queue', array("modified" => 1259585588 + 1000, "server_nonce" => $sl->server_nonce)); $lastRes = $res[0]; $info = $sl->otpParamsFromInfoString($lastRes['info']); $res = array('queued' => $lastRes['queued'], 'modified' => $lastRes['modified'], 'otp' => $lastRes['otp'], 'server' => $lastRes['server'], 'nonce' => $info['nonce'], 'yk_publicname' => $info['yk_publicname'], 'yk_counter' => $info['yk_counter'], 'yk_use' => $info['yk_use'], 'yk_high' => $info['yk_high'], 'yk_low' => $info['yk_low']); $this->assertNull($res['queued']); }