Skip to content

Commit 07a59e1

Browse files
authored
Merge pull request #3 from securenative/dev
Dev
2 parents bdafae6 + ef61b7c commit 07a59e1

File tree

8 files changed

+70
-41
lines changed

8 files changed

+70
-41
lines changed
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,24 @@ jobs:
1515
os: [ubuntu-latest]
1616
steps:
1717
- name: Notify slack success
18-
if: success()
19-
id: slack # IMPORTANT: reference this step ID value in future Slack steps
20-
env:
21-
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
22-
uses: voxmedia/[email protected]
23-
with:
24-
channel: github-actions
25-
status: STARTING
26-
color: warning
18+
if: success()
19+
id: slack # IMPORTANT: reference this step ID value in future Slack steps
20+
env:
21+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
22+
uses: voxmedia/[email protected]
23+
with:
24+
channel: github-actions
25+
status: STARTING
26+
color: warning
2727

2828
- uses: actions/checkout@v2
2929
- uses: php-actions/composer@v1
30+
- uses: nanasess/setup-php@master
3031
- uses: php-actions/phpunit@v9
3132

33+
- name: Run tests
34+
run: phpunit test/AgentTest.php && php test/SecureNativeTest.php
35+
3236
- name: Publish to codecov
3337
run: bash <(curl -s https://codecov.io/bash)
3438

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,24 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Notify slack success
15-
if: success()
16-
id: slack # IMPORTANT: reference this step ID value in future Slack steps
17-
env:
18-
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
19-
uses: voxmedia/[email protected]
20-
with:
21-
channel: github-actions
22-
status: STARTING
23-
color: warning
15+
if: success()
16+
id: slack # IMPORTANT: reference this step ID value in future Slack steps
17+
env:
18+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
19+
uses: voxmedia/[email protected]
20+
with:
21+
channel: github-actions
22+
status: STARTING
23+
color: warning
2424

2525
- uses: actions/checkout@v2
2626
- uses: php-actions/composer@v1
27+
- uses: nanasess/setup-php@master
2728
- uses: php-actions/phpunit@v9
2829

30+
- name: Run tests
31+
run: phpunit test/AgentTest.php && php test/SecureNativeTest.php
32+
2933
- name: Publish to codecov
3034
run: bash <(curl -s https://codecov.io/bash)
3135

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,24 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Notify slack success
12-
if: success()
13-
id: slack # IMPORTANT: reference this step ID value in future Slack steps
14-
env:
15-
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
16-
uses: voxmedia/[email protected]
17-
with:
18-
channel: github-actions
19-
status: STARTING
20-
color: warning
12+
if: success()
13+
id: slack # IMPORTANT: reference this step ID value in future Slack steps
14+
env:
15+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
16+
uses: voxmedia/[email protected]
17+
with:
18+
channel: github-actions
19+
status: STARTING
20+
color: warning
2121

2222
- uses: actions/checkout@v2
2323
- uses: php-actions/composer@v1
24+
- uses: nanasess/setup-php@master
2425
- uses: php-actions/phpunit@v9
2526

27+
- name: Run tests
28+
run: phpunit test/AgentTest.php && php test/SecureNativeTest.php
29+
2630
- name: Publish to codecov
2731
run: bash <(curl -s https://codecov.io/bash)
2832

README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,18 @@ use SecureNative\sdk\SecureNativeOptions;
7878
use SecureNative\sdk\EventTypes;
7979
use SecureNative\sdk\SecureNativeContext;
8080

81-
82-
$token = "[SECURED_CLIENT_TOKEN]";
83-
$ctx = new SecureNativeContext($token, "79.179.88.157", null, (object)["user-agent" => "Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us"], null, null, null);
81+
$clientToken = "SECURED_CLIENT_TOKEN"
82+
$headers = (object)["user-agent" => "Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us"] // User-Agent header is important to get device information!
83+
$ip = "127.0.0.1"
84+
$remoteIp = "127.0.0.1"
85+
$url = null
86+
$method = null
87+
$body = null
88+
$ctx = new SecureNativeContext($clientToken, $ip, $remoteIp, $headers, $url, $method, $body);
8489

8590
SecureNative::track(array(
8691
'event' => EventTypes::LOG_IN,
87-
'context' => ctx,
92+
'context' => $ctx,
8893
'userId' => '1234',
8994
'userTraits' => (object)[
9095
'name' => 'Your Name',
@@ -159,17 +164,17 @@ use SecureNative\sdk\SecureNativeContext;
159164

160165
$ver = SecureNative::verify(array(
161166
'event' => EventTypes::VERIFY,
162-
'userId' => '27',
167+
'userId' => '1234',
163168
'context' => SecureNativeContext::fromRequest(),
164169
'userTraits' => (object)[
165170
'name' => 'Your Name',
166171
'email' => '[email protected]'
167172
]
168173
));
169174

170-
ver.riskLevel // Low, Medium, High
171-
ver.score // Risk score: 0 - 1 (0 - Very Low, 1 - Very High)
172-
ver.triggers // ["TOR", "New IP", "New City"]
175+
$ver.riskLevel // Low, Medium, High
176+
$ver.score // Risk score: 0 - 1 (0 - Very Low, 1 - Very High)
177+
$ver.triggers // ["TOR", "New IP", "New City"]
173178
```
174179

175180
## Webhook signature verification

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
"php": ">=7.2.0",
2727
"guzzlehttp/guzzle": "^6.0",
2828
"antecedent/patchwork": "~2.0",
29-
"monolog/monolog": "2.0.2"
29+
"monolog/monolog": "2.0.2",
30+
"phpunit/phpunit": "^8"
3031
},
3132
"require-dev": {
32-
"phpunit/phpunit": "^8",
3333
"php-coveralls/php-coveralls": "*"
3434
}
3535
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
use SecureNative\sdk\EventTypes;
44
use SecureNative\sdk\SecureNative;
55
use SecureNative\sdk\SecureNativeContext;
6-
use PHPUnit\Framework\TestCase;
76
use SecureNative\sdk\SecureNativeOptions;
87

9-
final class AgentTest extends TestCase
8+
final class AgentTest extends PHPUnit\Framework\TestCase
109
{
1110
const TEST_API_KEY = 'sample_key';
1211
/**
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
declare(strict_types=1);
33

44
use GuzzleHttp\Exception\RequestException;
5-
use PHPUnit\Framework\TestCase;
65
use SecureNative\sdk\SecureNative;
76
use SecureNative\sdk\SecureNativeOptions;
87
use SecureNative\sdk\Utils;
98
use SecureNative\sdk\VerifyResult;
109

1110
const TEST_API_KEY = 'sample_key';
1211

13-
final class SecureNativeTest extends TestCase
12+
final class SecureNativeTest extends PHPUnit\Framework\TestCase
1413
{
1514

1615
/**

test/phpunit.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0"?>
2+
<phpunit colors="true">
3+
<testsuites>
4+
<testsuite name="main">
5+
<directory suffix="Test.php">.</directory>
6+
</testsuite>
7+
</testsuites>
8+
9+
<filter>
10+
<whitelist>
11+
<directory suffix=".php">../src</directory>
12+
</whitelist>
13+
</filter>
14+
</phpunit>

0 commit comments

Comments
 (0)