Skip to content

Commit

Permalink
ci(php): test snaps to annotations (#300)
Browse files Browse the repository at this point in the history
  • Loading branch information
gotbadger authored Feb 22, 2024
1 parent 7fba874 commit ceead2f
Show file tree
Hide file tree
Showing 237 changed files with 3,023 additions and 24,680 deletions.
78 changes: 0 additions & 78 deletions tests/php/lang/cbc_predictable_iv/__snapshots__/test.js.snap

This file was deleted.

36 changes: 25 additions & 11 deletions tests/php/lang/cbc_predictable_iv/test.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
const { createInvoker, getEnvironment } = require("../../../helper.js")
const {
createNewInvoker,
getEnvironment,
} = require("../../../helper.js")
const { ruleId, ruleFile, testBase } = getEnvironment(__dirname)

describe(ruleId, () => {
const invoke = createInvoker(ruleId, ruleFile, testBase)
const invoke = createNewInvoker(ruleId, ruleFile, testBase)

test("ok", () => {
const testCase = "ok.php"
expect(invoke(testCase)).toMatchSnapshot()
})

test("bad", () => {
const testCase = "bad.php"

test("bad", () => {
const testCase = "bad.php"
expect(invoke(testCase)).toMatchSnapshot()
})
})
const results = invoke(testCase)

expect(results.Missing).toEqual([])
expect(results.Extra).toEqual([])
})


test("ok", () => {
const testCase = "ok.php"

const results = invoke(testCase)

expect(results.Missing).toEqual([])
expect(results.Extra).toEqual([])
})

})
2 changes: 2 additions & 0 deletions tests/php/lang/cbc_predictable_iv/testdata/bad.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@

$algorithm = "aes-256-cbc";

# bearer:expected php_lang_cbc_predictable_iv
openssl_encrypt($data, $algorithm, $passphrase, 0, "oops", null);
# bearer:expected php_lang_cbc_predictable_iv
openssl_encrypt($data, $algorithm, $passphrase, iv: "oops");
94 changes: 0 additions & 94 deletions tests/php/lang/cookies/__snapshots__/test.js.snap

This file was deleted.

36 changes: 25 additions & 11 deletions tests/php/lang/cookies/test.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
const { createInvoker, getEnvironment } = require("../../../helper.js")
const {
createNewInvoker,
getEnvironment,
} = require("../../../helper.js")
const { ruleId, ruleFile, testBase } = getEnvironment(__dirname)

describe(ruleId, () => {
const invoke = createInvoker(ruleId, ruleFile, testBase)
const invoke = createNewInvoker(ruleId, ruleFile, testBase)

test("bad", () => {
const testCase = "bad.php"
expect(invoke(testCase)).toMatchSnapshot()
})

test("bad", () => {
const testCase = "bad.php"

test("ok", () => {
const testCase = "ok.php"
expect(invoke(testCase)).toMatchSnapshot()
})
})
const results = invoke(testCase)

expect(results.Missing).toEqual([])
expect(results.Extra).toEqual([])
})


test("ok", () => {
const testCase = "ok.php"

const results = invoke(testCase)

expect(results.Missing).toEqual([])
expect(results.Extra).toEqual([])
})

})
2 changes: 2 additions & 0 deletions tests/php/lang/cookies/testdata/bad.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

# bearer:expected php_lang_cookies
setcookie("user_email", $user->email, 0);
# bearer:expected php_lang_cookies
setrawcookie("user_email", $user->email, 0);

This file was deleted.

36 changes: 25 additions & 11 deletions tests/php/lang/deserialization_of_user_input/test.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
const { createInvoker, getEnvironment } = require("../../../helper.js")
const {
createNewInvoker,
getEnvironment,
} = require("../../../helper.js")
const { ruleId, ruleFile, testBase } = getEnvironment(__dirname)

describe(ruleId, () => {
const invoke = createInvoker(ruleId, ruleFile, testBase)
const invoke = createNewInvoker(ruleId, ruleFile, testBase)

test("bad", () => {
const testCase = "bad.php"
expect(invoke(testCase)).toMatchSnapshot()
})

test("bad", () => {
const testCase = "bad.php"

test("ok", () => {
const testCase = "ok.php"
expect(invoke(testCase)).toMatchSnapshot()
})
})
const results = invoke(testCase)

expect(results.Missing).toEqual([])
expect(results.Extra).toEqual([])
})


test("ok", () => {
const testCase = "ok.php"

const results = invoke(testCase)

expect(results.Missing).toEqual([])
expect(results.Extra).toEqual([])
})

})
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?php

# bearer:expected php_lang_deserialization_of_user_input
$data = unserialize($_GET["oops"], ["max_depth" => 10]);
Loading

0 comments on commit ceead2f

Please sign in to comment.