Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Larky case tests #248

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:
- run:
name: Maven Build/Test
command: |
mvn clean install dependency:go-offline -T 2.0C -B
mvn clean install -Dtest=!LarkyQuickTests -DfailIfNoTests=false dependency:go-offline -T 2.0C -B
- <<: *save-maven-cache
- run: find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} $TEST_RESULTS_PATH/junit/ \;
- run: find . -type f -regex ".*/target/surefire-reports/.*-output.txt" -exec cp {} $TEST_RESULTS_PATH/junit/ \;
Expand All @@ -147,6 +147,26 @@ jobs:
- store_test_results:
path: *test_results_directory

larky-case-tests:
<<: *job-defaults
machine:
image: ubuntu-1604:202007-01
steps:
- checkout
- <<: *install-java
- <<: *restore-maven-cache
- run: mkdir -p $TEST_RESULTS_PATH/junit/
- run: mkdir -p $TEST_RESULTS_PATH/coverage/
- run:
name: Maven Build/Test
command: |
mvn clean install -pl larky -Dtest=LarkyQuickTests dependency:go-offline -T 2.0C -B
- <<: *save-maven-cache
- run: find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} $TEST_RESULTS_PATH/junit/ \;
- run: find . -type f -regex ".*/target/surefire-reports/.*-output.txt" -exec cp {} $TEST_RESULTS_PATH/junit/ \;
- run: find . -type f -regex ".*/target/site/.*" -exec cp --parents {} $TEST_RESULTS_PATH/coverage/ \;


build-and-test-docker:
<<: *job-defaults
machine: true
Expand Down Expand Up @@ -280,6 +300,7 @@ workflows:
build_and_tests:
jobs:
- build-and-test
- larky-case-tests
- build-and-test-docker
- build-dist-linux:
requires:
Expand Down
32 changes: 32 additions & 0 deletions examples/test_aws_v4_sign.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
load("@stdlib//builtins", builtins="builtins")
load("@vendor//Crypto/Hash/HMAC", HMAC="HMAC")
load("@vendor//Crypto/Hash/SHA256", SHA256="SHA256")

load("@stdlib//unittest", "unittest")
load("@vendor//asserts", "asserts")


def b(s):
return builtins.bytes(s, encoding="UTF8")


def test_aws_v4_sign():
expected_signature = "20a7ab2bfce9848a117546ad4f701270683e0f86e72703872841f7343a1a1a7e"
key = "this-is-a-key"
date = "1959-02-03"
region = "us-west-2"
service_name = "some-service"
kDate = HMAC.new(b("AWS4" + key), b(date), digestmod=SHA256).digest()
kRegion = HMAC.new(kDate, b(region), digestmod=SHA256).digest()
kService = HMAC.new(kRegion, b(service_name), digestmod=SHA256).digest()
kSigning = HMAC.new(kService, b("aws4_request"), digestmod=SHA256).hexdigest()
asserts.assert_that(kSigning).is_equal_to(expected_signature)

def _testsuite():
_suite = unittest.TestSuite()
_suite.addTest(unittest.FunctionTestCase(test_aws_v4_sign))
return _suite


_runner = unittest.TextTestRunner()
_runner.run(_testsuite())
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.verygood.security.larky;

import static com.verygood.security.larky.ModuleSupplier.CORE_MODULES;

import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet;

Expand Down Expand Up @@ -30,11 +28,15 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static com.verygood.security.larky.ModuleSupplier.CORE_MODULES;


public class LarkyQuickTests {

private static final String PROPERTY_NAME = "larky.quick_test";
private static final Path QUICK_TEST_DIR = Paths.get(
"src","test", "resources", "quick_tests"
// "src", "test", "resources", "quick_tests"
"..", "examples"
);
private static final TestingConsole console = new TestingConsole();

Expand Down Expand Up @@ -64,7 +66,7 @@ private List<Path> enumerateTests() {
.filter(f -> {
String fileName = f.getFileName().toString();

if(!Strings.isNullOrEmpty(singleTestDesired)) {
if (!Strings.isNullOrEmpty(singleTestDesired)) {
return fileName.equals(singleTestDesired);
}

Expand Down