Skip to content

Commit

Permalink
ci(python): update to use annotations (#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
gotbadger authored Feb 22, 2024
1 parent 012b0cf commit 51cc13d
Show file tree
Hide file tree
Showing 15 changed files with 150 additions and 648 deletions.
54 changes: 0 additions & 54 deletions tests/python/lang/logger/__snapshots__/test.js.snap

This file was deleted.

55 changes: 37 additions & 18 deletions tests/python/lang/logger/test.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,40 @@
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)

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

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

test("shared_datatype", () => {
const testCase = "shared_datatype.py"
expect(invoke(testCase)).toMatchSnapshot()
})
})
const invoke = createNewInvoker(ruleId, ruleFile, testBase)


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

const results = invoke(testCase)

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


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

const results = invoke(testCase)

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


test("shared_datatype", () => {
const testCase = "shared_datatype.py"

const results = invoke(testCase)

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

})
1 change: 1 addition & 0 deletions tests/python/lang/logger/testdata/bad.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ def do_something(user):

def authenticate(user):
do_something()
# bearer:expected python_lang_logger
logging.info(f"User '{user.email}' logged")
130 changes: 0 additions & 130 deletions tests/python/lang/weak_hash_md5/__snapshots__/test.js.snap

This file was deleted.

36 changes: 25 additions & 11 deletions tests/python/lang/weak_hash_md5/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.py"
expect(invoke(testCase)).toMatchSnapshot()
})

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

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

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


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

const results = invoke(testCase)

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

})
3 changes: 3 additions & 0 deletions tests/python/lang/weak_hash_md5/testdata/bad.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import hashlib

result = hashlib.md5()
# bearer:expected python_lang_weak_hash_md5
result.update('password')
result.digest()

# bearer:expected python_lang_weak_hash_md5
result = hashlib.md5(b'password')
result.digest()

username = user.name
# bearer:expected python_lang_weak_hash_md5
result = hashlib.md5(username.encode())
result.hexdigest()
Loading

0 comments on commit 51cc13d

Please sign in to comment.