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

Psre 2138/feature/pre hash string utils PSRE-2229 #70

Merged
merged 23 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f52a0a1
[FEATURE] Containerise dev env LRN-34270
david-scarratt-lrn Nov 25, 2021
970aee5
[TEST] Allow passing test arguments via ARGS_PHPUNIT
shtrom Mar 1, 2024
af5a1d1
[TEST] phpunit --migrate-configuration
shtrom Mar 12, 2024
2816b5d
[VENDOR] require --dev squizlabs/php_codesniffer=*
shtrom Mar 12, 2024
b79be8f
[LINT] Add phpcs config
shtrom Mar 12, 2024
a9cfd06
[BUILD] Add lint target
shtrom Mar 12, 2024
5a8465e
[LINT] Run phpcbf on codebase
shtrom Mar 12, 2024
e4e8ebc
[LINT] Apply manual fixes
shtrom Mar 12, 2024
b2c94b7
[TEST] Move instanciation of Init to test rather than data providers
shtrom Mar 14, 2024
a07f237
[TEST] Move getWorking*Params to separate ParamsFixture
shtrom Mar 1, 2024
a447d80
[TEST] Minute updates to ParamsFixture
shtrom Mar 13, 2024
c4daed9
[TEST] ParamsFixture: provide expected signature for params from Fixture
shtrom Mar 13, 2024
26fdfa8
[TEST] InitTest: Use valid action for dataApiPost -> Set
shtrom Mar 13, 2024
7c02fc5
[FEATURE] Introduce PreHashString services
shtrom Feb 19, 2024
fdeab94
[REFACTOR] Init: Use PreHashString services
shtrom Mar 13, 2024
ffed4f2
[TEST] ParamsFixture: reintroduce v1 signatures to actively test back…
shtrom Mar 13, 2024
cc60b06
[TEST] Signing services: test both v1 and v2 signatures
shtrom Mar 13, 2024
ea380b8
[TEST] LegacyPreHashStringTest: hardcode expected PHS for v1Compat an…
shtrom Mar 14, 2024
3b00efc
[TEST] ParamsFixture: add service-agnostic entrypoint methods
shtrom Mar 14, 2024
cdcf4c8
[REFACTOR] Remove legacy PHS+Signing code
shtrom Mar 13, 2024
3f22736
[TEST] Add github workflow
shtrom Mar 14, 2024
bcc5b5c
[BUG] Request can be empty (or null)
shtrom Apr 2, 2024
49c0fc7
[REFACTOR] Signatures: reduce visibility of internal consts
shtrom Apr 5, 2024
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
32 changes: 32 additions & 0 deletions .github/workflows/push-pr-main-test-lint-unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#####
# Pull Request workflow triggers on pushes to, or pull requests against, main
# Jobs performed:
# 1. Lint
# 2. Unit test
# 3. Integration tests
#####
name: Tests
on:
pull_request:
branches:
- master
push:
branches:
# Every push on those branches
- master

jobs:
run_tests:
runs-on: ubuntu-latest
name: Lint & Tests
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Run Lint Checks
run: make lint
- name: Run Python Tests
run: make test-unit
- name: Run Integration Test
run: make test-integration-env
5 changes: 5 additions & 0 deletions .phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0"?>
<ruleset name="PHP_CodeSniffer">
<description>PHP_CodeSniffer configuration</description>
<rule ref="PSR12"/>
</ruleset>
9 changes: 4 additions & 5 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ and this project adheres to [Semantic
Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [v1.0.3] - 2024-04-07
### Added
- Rename author-aide to authoraide
- Added composable services for signature generation.
- Support authoraide.

### Refactor
- Refactored the signature generation to use composable services.

## [v1.0.3] - 2024-03-07
### Added
- Support author aide

## [v1.0.2] - 2023-07-03
### Added
Expand Down
20 changes: 14 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
ARGS_PHPUNIT ?=

DOCKER := $(if $(LRN_SDK_NO_DOCKER),,$(shell which docker))
PHP_VERSION = 8.3
DEBIAN_VERSION = bookworm
IMAGE = php-cli-composer:$(PHP_VERSION)

TARGETS = all build devbuild prodbuild \
quickstart install-vendor \
quickstart check-quickstart install-vendor \
dist dist-test dist-zip release \
test test-coverage test-integration-env test-unit \
lint test test-coverage test-integration-env test-unit \
clean clean-dist clean-test clean-vendor
.PHONY: $(TARGETS)
.default: all
Expand Down Expand Up @@ -37,6 +39,7 @@ DIST = $(DIST_PREFIX)$(SRC_VERSION)
COMPOSER = composer
COMPOSER_INSTALL_FLAGS = --no-interaction --optimize-autoloader --classmap-authoritative

PHPCS= ./vendor/bin/phpcs
PHPUNIT = ./vendor/bin/phpunit

###
Expand All @@ -46,6 +49,8 @@ quickstart: VENDOR_FLAGS = --no-dev
quickstart: install-vendor
cd docs/quickstart && php -S $(LOCALHOST):8000

check-quickstart: vendor/autoload.php
$(COMPOSER) install $(COMPOSER_INSTALL_FLAGS) --no-dev;
###
# internal tooling rules
####
Expand All @@ -59,17 +64,20 @@ prodbuild: install-vendor
release:
@./release.sh

lint: install-vendor
$(PHPCS) src

test: install-vendor
$(PHPUNIT) --do-not-cache-result
$(PHPUNIT) --do-not-cache-result $(ARGS_PHPUNIT)

test-coverage: install-vendor
XDEBUG_MODE=coverage $(PHPUNIT) --do-not-cache-result
XDEBUG_MODE=coverage $(PHPUNIT) --do-not-cache-result $(ARGS_PHPUNIT)

test-unit: install-vendor
$(PHPUNIT) --do-not-cache-result --testsuite unit
$(PHPUNIT) --do-not-cache-result --testsuite unit $(ARGS_PHPUNIT)

test-integration-env: install-vendor
$(PHPUNIT) --do-not-cache-result --testsuite integration
$(PHPUNIT) --do-not-cache-result --testsuite integration $(ARGS_PHPUNIT)

###
# dist rules
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"ext-mbstring": "*"
},
"require-dev": {
"phpunit/phpunit": "^6.0 || ^7.0 || ^8.0 || ^9.0"
"phpunit/phpunit": "^6.0 || ^7.0 || ^8.0 || ^9.0",
"squizlabs/php_codesniffer": "*"
}
}
3 changes: 2 additions & 1 deletion docs/quickstart/analytics/basic_data.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

/* Copyright (c) 2023 Learnosity, MIT License
* Basic example code for pulling information from the Learnosity cloud using Data API. */

// Setup to load the necessary classes from the example directory, & set up variables for access.
require_once __DIR__ . '/../../../bootstrap.php';
require_once __DIR__ . '/../../../bootstrap.php';
$config = require_once __DIR__ . '/../config.php'; // Load security keys from config.php, for Learnosity's public demos account.
use LearnositySdk\Request\DataApi; // Load core Data API library.
$itembank_uri = 'https://data.learnosity.com/v2023.1.LTS/sessions/responses'; // Choosing the Data API endpoint for sessions/responses.
Expand Down
1 change: 1 addition & 0 deletions docs/quickstart/analytics/init_data.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Copyright (c) 2021 Learnosity, MIT License
*
Expand Down
6 changes: 4 additions & 2 deletions docs/quickstart/analytics/student-reporting.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Copyright (c) 2021 Learnosity, MIT License
*
Expand Down Expand Up @@ -55,9 +56,10 @@
'reports',
$security,
$consumerSecret,
$request);
$request
);
$initOptions = $init->generate();
?>
?>

<!-- Section 2: Web page content. -->
<!DOCTYPE html>
Expand Down
6 changes: 4 additions & 2 deletions docs/quickstart/assessment/standalone-assessment.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Copyright (c) 2021 Learnosity, MIT License
*
Expand Down Expand Up @@ -60,9 +61,10 @@
'items',
$security,
$consumerSecret,
$request);
$request
);
$initOptions = $init->generate(); // JSON blob of signed config params.
?>
?>

<!-- Section 2: Web page content. -->
<!DOCTYPE html>
Expand Down
6 changes: 4 additions & 2 deletions docs/quickstart/authoring/authoring-activities.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Copyright (c) 2021 Learnosity, MIT License
*
Expand Down Expand Up @@ -40,9 +41,10 @@
'author',
$security,
$consumerSecret,
$request);
$request
);
$initOptions = $init->generate();
?>
?>

<!-- Section 2: Web page content. -->
<!DOCTYPE html>
Expand Down
6 changes: 4 additions & 2 deletions docs/quickstart/authoring/authoring-items.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Copyright (c) 2021 Learnosity, MIT License
*
Expand Down Expand Up @@ -41,9 +42,10 @@
'author',
$security,
$consumerSecret,
$request);
$request
);
$initOptions = $init->generate(); // JSON blob of signed config params.
?>
?>

<!-- Section 2: Web page content. -->
<!DOCTYPE html>
Expand Down
5 changes: 3 additions & 2 deletions docs/quickstart/config.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

// The consumerKey and consumerSecret are the public & private
// security keys required to access Learnosity APIs and
// data. Learnosity will provide keys for your own private account.
// Note: The consumer secret should be in a properly secured credential store,
// and *NEVER* checked into version control.
// Note: The consumer secret should be in a properly secured credential store,
// and *NEVER* checked into version control.
// The keys listed here grant access to Learnosity's public demos account.
return [
'consumerKey' => 'yis0TYCu7U9V4o7M',
Expand Down
36 changes: 14 additions & 22 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="bootstrap.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">./src/</directory>
</include>
<report>
<clover outputFile="./tests/coverage.xml"/>
<html outputDirectory="./tests/coverage" lowUpperBound="35" highLowerBound="70"/>
</report>
</coverage>
<php>
<ini name="intl.default_locale" value="en" />
<ini name="intl.error_level" value="0" />
<ini name="memory_limit" value="-1" />
<ini name="intl.default_locale" value="en"/>
<ini name="intl.error_level" value="0"/>
<ini name="memory_limit" value="-1"/>
</php>
<logging>
<log type="coverage-html" target="./tests/coverage" lowUpperBound="35" highLowerBound="70" />
<log type="coverage-clover" target="./tests/coverage.xml" />
<log type="junit" target="./tests/junit.xml" />
<junit outputFile="./tests/junit.xml"/>
</logging>
<filter>
<whitelist>
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
<testsuites>
<testsuite name="unit">
<directory>./tests/</directory>
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptions/ValidationException.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace LearnositySdk\Exceptions;

use Exception;

class ValidationException extends Exception
{

}
Loading
Loading