US Congress Stock Trading API examples & templates
Use these vals as a playground to view and fork US Congress Stock Trading API examples and templates on Val Town. Run any example below or find templates that can be used as a pre-built solution.
rozek
Authorization_from_SQLite_Test
HTTP
Here are some tests for val Authorization_from_SQLite Test Cases Positive Test Cases Valid credentials with existing user TableName: "Authorization_from_SQLite_Test" Database content: UserId "alice", PasswordHash "{PBKDF2}10000$salt123$hashedPassword123" Authorization header: "Basic " + btoa("alice:correctPassword") Expected result: true Valid credentials with case-insensitive UserId TableName: "Authorization_from_SQLite_Test" Database content: UserId "Bob", PasswordHash "{PBKDF2}10000$salt456$hashedPassword456" Authorization header: "Basic " + btoa("bob:correctPassword") Expected result: true Negative Test Cases Invalid password TableName: "Authorization_from_SQLite_Test" Database content: UserId "charlie", PasswordHash "{PBKDF2}10000$salt789$hashedPassword789" Authorization header: "Basic " + btoa("charlie:wrongPassword") Expected result: false No Authorization header TableName: "Authorization_from_SQLite_Test" Database content: UserId "david", PasswordHash "{PBKDF2}10000$saltABC$hashedPasswordABC" Authorization header: undefined Expected result: false Non-existent user TableName: "Authorization_from_SQLite_Test" Database content: (empty) Authorization header: "Basic " + btoa("eve:anyPassword") Expected result: false Error Cases Invalid table name TableName: "1INVALID" Authorization header: "Basic " + btoa("frank:password") Expected result: Error thrown Edge Cases Empty string as password TableName: "Authorization_from_SQLite_Test" Database content: UserId "grace", PasswordHash "{PBKDF2}10000$saltDEF$hashedEmptyPassword" Authorization header: "Basic " + btoa("grace:") Expected result: true (if the empty password hashes correctly) Non-Basic authorization type TableName: "Authorization_from_SQLite_Test" Database content: UserId "henry", PasswordHash "{PBKDF2}10000$saltGHI$hashedPasswordGHI" Authorization header: "Bearer " + btoa("henry:password") Expected result: false Malformed PasswordHash in database TableName: "Authorization_from_SQLite_Test" Database content: UserId "isaac", PasswordHash "malformedHash" Authorization header: "Basic " + btoa("isaac:password") Expected result: false Very long UserId (at 256 character limit) TableName: "Authorization_from_SQLite_Test" Database content: UserId (256 'a' characters), PasswordHash "{PBKDF2}10000$saltJKL$hashedPasswordJKL" Authorization header: "Basic " + btoa("a".repeat(256) + ":password") Expected result: true (if password is correct) UserId exceeding 256 characters TableName: "Authorization_from_SQLite_Test" Authorization header: "Basic " + btoa("a".repeat(257) + ":password") Expected result: false (as it shouldn't exist in the database) Empty UserId TableName: "Authorization_from_SQLite_Test" Authorization header: "Basic " + btoa(":password") Expected result: false
0
easrng
uploadTo0x0
Script
upload to 0x0.st usage: import { uploadTo0x0 } from "https://esm.town/v/easrng/uploadTo0x0"
console.log(await uploadTo0x0("test data", "filename")) data can be a string, a TypedArray, an ArrayBuffer, or a Blob returns a url (ie https://0x0.st/X-wB.txt ) to a file that expires after an hour
4
nbbaier
submitPR
Script
Submit a PR from Val Town This val provides a (very) thin wrapper around the GH rest API methods for creating a pull request. It handles the creation of a Octokit client for you. Usage import { submitPR } from "https://esm.town/v/nbbaier/submitPR";
await submitPR(Deno.env.get("GH_REPO_TOKEN"), {
owner: "nbbaier",
repo: "test-ground",
head: "branch_2",
base: "main",
title: "trying another PR",
body: "cool stuff, take a look",
}); Parameters The function takes two parameters: your gh access token and an object that's identical to the object submitted to the gh API. See GH's documentation for more info!
0