-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(remaining-validity): adds remaining valitity method (#778)
- Loading branch information
1 parent
80071fc
commit 536f4a6
Showing
5 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict'; | ||
|
||
var test = require('tape'); | ||
var createFixture = require('../../utils/create-fixture'); | ||
var fixture = createFixture(); | ||
var client = fixture.client; | ||
|
||
var now = new Date().getTime() / 1000; | ||
|
||
test('client.GetSecuredApiKeyRemainingValidity(): expired key', function(t) { | ||
t.plan(1); | ||
|
||
var apiKey = client.generateSecuredApiKey('foo', { | ||
validUntil: now - (10 * 60) | ||
}); | ||
|
||
t.true(client.getSecuredApiKeyRemainingValidity(apiKey) < 0); | ||
}); | ||
|
||
test('client.GetSecuredApiKeyRemainingValidity(): valid key', function(t) { | ||
t.plan(1); | ||
|
||
var apiKey = client.generateSecuredApiKey('foo', { | ||
validUntil: now + (10 * 60) | ||
}); | ||
|
||
t.true(client.getSecuredApiKeyRemainingValidity(apiKey) > 0); | ||
}); | ||
|
||
test('client.GetSecuredApiKeyRemainingValidity(): ValidUntil not found', function(t) { | ||
t.plan(1); | ||
|
||
var apiKey = client.generateSecuredApiKey('foo'); | ||
|
||
t.throws(function() { | ||
client.getSecuredApiKeyRemainingValidity(apiKey); | ||
}, 'ValidUntil not found.'); | ||
}); |