Skip to content

Commit

Permalink
Merge pull request #139 from snicco/feat/signed-url-wp-bridge
Browse files Browse the repository at this point in the history
feat(signed-url-wp-bridge): initial implementation
  • Loading branch information
calvinalkan committed May 21, 2022
2 parents 3f7126c + 637f228 commit c869469
Show file tree
Hide file tree
Showing 64 changed files with 814 additions and 130 deletions.
1 change: 1 addition & 0 deletions commit-scopes.json
Expand Up @@ -24,6 +24,7 @@
"session-wp-bridge",
"signed-url-psr15-bridge",
"signed-url-psr16-bridge",
"signed-url-wp-bridge",
"better-wp-cache-bundle",
"better-wp-hooks-bundle",
"better-wp-mail-bundle",
Expand Down
1 change: 1 addition & 0 deletions composer-require-checker.json
Expand Up @@ -7,6 +7,7 @@
"wp_cache_delete",
"wp_cache_flush",
"wp_cache_get",
"wp_cache_decr",
"wp_cache_get_multiple",
"wp_cache_set",
"wp_get_current_user",
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Expand Up @@ -82,6 +82,7 @@
"Snicco\\Bridge\\SessionWP\\": "src/Snicco/Bridge/session-wp/src",
"Snicco\\Bridge\\SignedUrlPsr15\\": "src/Snicco/Bridge/signed-url-psr15/src",
"Snicco\\Bridge\\SignedUrlPsr16\\": "src/Snicco/Bridge/signed-url-psr16/src",
"Snicco\\Bridge\\SignedUrlWP\\": "src/Snicco/Bridge/signed-url-wp/src",
"Snicco\\Bundle\\BetterWPCache\\": "src/Snicco/Bundle/better-wp-cache/src",
"Snicco\\Bundle\\BetterWPDB\\": "src/Snicco/Bundle/better-wpdb/src",
"Snicco\\Bundle\\BetterWPHooks\\": "src/Snicco/Bundle/better-wp-hooks/src",
Expand Down Expand Up @@ -141,6 +142,7 @@
"Snicco\\Bridge\\SessionWP\\Tests\\": "src/Snicco/Bridge/session-wp/tests",
"Snicco\\Bridge\\SignedUrlPsr15\\Tests\\": "src/Snicco/Bridge/signed-url-psr15/tests",
"Snicco\\Bridge\\SignedUrlPsr16\\Tests\\": "src/Snicco/Bridge/signed-url-psr16/tests",
"Snicco\\Bridge\\SignedUrlWP\\Tests\\": "src/Snicco/Bridge/signed-url-wp/tests",
"Snicco\\Bundle\\BetterWPCache\\Tests\\": "src/Snicco/Bundle/better-wp-cache/tests",
"Snicco\\Bundle\\BetterWPDB\\Tests\\": "src/Snicco/Bundle/better-wpdb/tests",
"Snicco\\Bundle\\BetterWPHooks\\Tests\\": "src/Snicco/Bundle/better-wp-hooks/tests",
Expand Down Expand Up @@ -298,6 +300,7 @@
"snicco/signed-url-psr15-bridge": "self.version",
"snicco/signed-url-psr16-bridge": "self.version",
"snicco/signed-url-testing": "self.version",
"snicco/signed-url-wp-bridge": "self.version",
"snicco/str-arr": "self.version",
"snicco/templating": "self.version",
"snicco/templating-bundle": "self.version",
Expand Down
2 changes: 1 addition & 1 deletion ecs.php
Expand Up @@ -178,7 +178,7 @@
[
LineLengthFixer::LINE_LENGTH => 120,
LineLengthFixer::BREAK_LONG_LINES => true,
LineLengthFixer::INLINE_SHORT_LINES => true,
LineLengthFixer::INLINE_SHORT_LINES => false,
],
]);

Expand Down
Expand Up @@ -42,7 +42,7 @@ public function delete($key): bool

$driver = new Psr16SessionDriver($cache, 10);

$driver->write('id1', SerializedSession::fromString('foo', 'val', time()),);
$driver->write('id1', SerializedSession::fromString('foo', 'val', time()), );

$this->expectException(CouldNotDestroySession::class);
$this->expectExceptionMessage('Cant destroy session with selector [id1]');
Expand Down Expand Up @@ -102,7 +102,7 @@ public function set($key, $value, $ttl = null): bool
$this->expectException(CouldNotWriteSessionContent::class);
$this->expectExceptionMessage('id1');

$driver->write('id1', SerializedSession::fromString('foo', 'val', time()),);
$driver->write('id1', SerializedSession::fromString('foo', 'val', time()), );
}

/**
Expand All @@ -122,7 +122,7 @@ public function set($key, $value, $ttl = null): void
$this->expectException(CouldNotWriteSessionContent::class);
$this->expectExceptionMessage('id1');

$driver->write('id1', SerializedSession::fromString('foo', 'val', time()),);
$driver->write('id1', SerializedSession::fromString('foo', 'val', time()), );
}

/**
Expand Down
Expand Up @@ -39,7 +39,7 @@ protected function setUp(): void
*/
public function next_is_called_for_valid_signature(): void
{
$m = new ValidateSignature($this->validator,);
$m = new ValidateSignature($this->validator, );

$link = $this->signer->sign('/foo', 10);

Expand All @@ -57,7 +57,7 @@ public function next_is_called_for_valid_signature(): void
*/
public function next_is_not_called_for_invalid_signature(): void
{
$m = new ValidateSignature($this->validator,);
$m = new ValidateSignature($this->validator, );

$link = $this->signer->sign('/foo', 10);

Expand All @@ -72,7 +72,7 @@ public function next_is_not_called_for_invalid_signature(): void
*/
public function next_not_called_for_expired(): void
{
$m = new ValidateSignature($this->validator,);
$m = new ValidateSignature($this->validator, );

$link = $this->signer->sign('/foo', 1);

Expand All @@ -89,7 +89,7 @@ public function next_not_called_for_expired(): void
*/
public function next_not_called_for_used(): void
{
$m = new ValidateSignature($this->validator,);
$m = new ValidateSignature($this->validator, );

$link = $this->signer->sign('/foo', 1, 2);

Expand Down
6 changes: 6 additions & 0 deletions src/Snicco/Bridge/signed-url-wp/.gitattributes
@@ -0,0 +1,6 @@
.gitattributes export-ignore
.gitignore export-ignore
phpunit.dist.xml export-ignore
*.md export-ignore
/tests export-ignore
/.github export-ignore
@@ -0,0 +1,19 @@
name: Automatically close PR's

on:
pull_request_target:
types: [ opened ]

jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: superbrothers/close-pull-request@v3
with:
# Optional. Post a issue comment just before closing a pull request.
comment: |
Hi, thank you for your contribution.
Unfortunately, this repository is read-only. It's a split from our main development repository.
We'd like to kindly ask you to move the contribution there - https://github.com/snicco/snicco.
We'll check it, review it and give you feed back right way.
Thank you.
5 changes: 5 additions & 0 deletions src/Snicco/Bridge/signed-url-wp/.gitignore
@@ -0,0 +1,5 @@
/.phpunit.cache/
/vendor
composer.lock
/tests/fixtures/cache
!tests/fixtures/cache/.gitkeep
120 changes: 120 additions & 0 deletions src/Snicco/Bridge/signed-url-wp/LICENSE.md
@@ -0,0 +1,120 @@
#### Copyright (c) Calvin Alkan

This software package is licensed under the terms of the GNU LGPLv3. See below for the license text.

### GNU LESSER GENERAL PUBLIC LICENSE

Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc.
<https://fsf.org/>

Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.

This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU
General Public License, supplemented by the additional permissions listed below.

#### 0. Additional Definitions.

As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to
version 3 of the GNU General Public License.

"The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined
below.

An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on
the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by
the Library.

A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of
the Library with which the Combined Work was made is also called the "Linked Version".

The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding
any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not
on the Linked Version.

The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application,
including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the
System Libraries of the Combined Work.

#### 1. Exception to Section 3 of the GNU GPL.

You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.

#### 2. Conveying Modified Versions.

If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied
by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may
convey a copy of the modified version:

- a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not
supply the function or data, the facility still operates, and performs whatever part of its purpose remains
meaningful, or
- b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.

#### 3. Object Code Incorporating Material from Library Header Files.

The object code form of an Application may incorporate material from a header file that is part of the Library. You may
convey such object code under terms of your choice, provided that, if the incorporated material is not limited to
numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:

- a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its
use are covered by this License.
- b) Accompany the object code with a copy of the GNU GPL and this license document.

#### 4. Combined Works.

You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification
of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications,
if you also do each of the following:

- a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and
its use are covered by this License.
- b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
- c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library
among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
- d) Do one of the following:
-
0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application
Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application
with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by
section 6 of the GNU GPL for conveying Corresponding Source.
-
1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a)
uses at run time a copy of the Library already present on the user's computer system, and (b) will operate
properly with a modified version of the Library that is interface-compatible with the Linked Version.
- e) Provide Installation Information, but only if you would otherwise be required to provide such information under
section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified
version of the Combined Work produced by recombining or relinking the Application with a modified version of the
Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source
and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner
specified by section 6 of the GNU GPL for conveying Corresponding Source.)

#### 5. Combined Libraries.

You may place library facilities that are a work based on the Library side by side in a single library together with
other library facilities that are not Applications and are not covered by this License, and convey such a combined
library under terms of your choice, if you do both of the following:

- a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library
facilities, conveyed under the terms of this License.
- b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.

#### 6. Revised Versions of the GNU Lesser General Public License.

The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time
to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new
problems or concerns.

Each version is given a distinguishing version number. If the Library as you received it specifies that a certain
numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of
following the terms and conditions either of that published version or of any later version published by the Free
Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General
Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software
Foundation.

If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General
Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for
you to choose that version for the Library.
27 changes: 27 additions & 0 deletions src/Snicco/Bridge/signed-url-wp/codeception.dist.yml
@@ -0,0 +1,27 @@
namespace: Snicco\Bridge\SignedUrlWP
paths:
tests: tests
output: tests/_output
data: tests/_data
support: tests/_support

bootstrap: bootstrap.php

params:
- env

settings:
colors: true
disallow_test_output: true
error_level: E_ALL
log_incomplete_skipped: true
report_useless_tests: true

reporters:
report: "PhpStorm_Codeception_ReportPrinter"

coverage:
enabled: true
include:
- src/*
show_uncovered: true
89 changes: 89 additions & 0 deletions src/Snicco/Bridge/signed-url-wp/composer.json
@@ -0,0 +1,89 @@
{
"name": "snicco/signed-url-wp-bridge",
"authors": [
{
"name": "Calvin Alkan",
"email": "calvin@snicco.de"
}
],
"require": {
"php": "^7.4|^8.0",
"snicco/signed-url": "^1.1.3",
"snicco/better-wp-api": "^1.1.3",
"snicco/better-wpdb": "^1.1.3",
"snicco/testable-clock": "^1.1.3"
},
"require-dev": {
"phpunit/phpunit": "^9.5.13",
"lucatume/wp-browser": "^3.1.4",
"codeception/codeception": "^4.1.29",
"snicco/signed-url-testing": "^1.1.3"
},
"autoload": {
"psr-4": {
"Snicco\\Bridge\\SignedUrlWP\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Snicco\\Bridge\\SignedUrlWP\\Tests\\": "tests"
}
},
"conflict": {
"snicco/http-routing": "<1.1.3",
"snicco/testable-clock": "<1.1.3",
"snicco/signed-url": "<1.1.3",
"snicco/templating": "<1.1.3",
"snicco/psr7-error-handler": "<1.1.3",
"snicco/str-arr": "<1.1.3",
"snicco/better-wp-hooks": "<1.1.3",
"snicco/event-dispatcher": "<1.1.3",
"snicco/eloquent": "<1.1.3",
"snicco/better-wp-mail": "<1.1.3",
"snicco/better-wp-api": "<1.1.3",
"snicco/kernel": "<1.1.3",
"snicco/blade-bridge": "<1.1.3",
"snicco/signed-url-psr16-bridge": "<1.1.3",
"snicco/illuminate-container-bridge": "<1.1.3",
"snicco/signed-url-psr15-bridge": "<1.1.3",
"snicco/pimple-bridge": "<1.1.3",
"snicco/no-robots-middleware": "<1.1.3",
"snicco/open-redirect-protection-middleware": "<1.1.3",
"snicco/wp-capapility-middleware": "<1.0.0",
"snicco/wp-nonce-middleware": "<1.1.3",
"snicco/payload-middleware": "<1.1.3",
"snicco/default-headers-middleware": "<1.1.3",
"snicco/wp-auth-only-middleware": "<1.1.3",
"snicco/content-negotiation-middleware": "<1.1.3",
"snicco/redirect-middleware": "<1.1.3",
"snicco/must-match-route-middleware": "<1.1.3",
"snicco/method-override-middleware": "<1.1.3",
"snicco/share-cookies-middleware": "<1.1.3",
"snicco/https-only-middleware": "<1.1.3",
"snicco/guests-only-middleware": "<1.0.0",
"snicco/trailing-slash-middleware": "<1.1.3",
"snicco/testing-bundle": "<1.1.3",
"snicco/http-routing-bundle": "<1.1.3",
"snicco/debug-bundle": "<1.1.3",
"snicco/templating-bundle": "<1.1.3",
"snicco/better-wpdb-bundle": "<1.1.3",
"snicco/better-wp-hooks-bundle": "<1.1.3",
"snicco/blade-bundle": "<1.1.3",
"snicco/better-wp-mail-bundle": "<1.1.3",
"snicco/better-wp-cache-bundle": "<1.1.3",
"snicco/session-bundle": "<1.1.3",
"snicco/encryption-bundle": "<1.1.3",
"snicco/wp-guests-only-middleware": "<1.1.3",
"snicco/wp-capability-middleware": "<1.1.3",
"snicco/better-wp-mail-testing": "<1.1.3",
"snicco/session-testing": "<1.1.3",
"snicco/kernel-testing": "<1.1.3",
"snicco/signed-url-testing": "<1.1.3",
"snicco/http-routing-testing": "<1.1.3",
"snicco/event-dispatcher-testing": "<1.1.3",
"snicco/better-wp-cli": "<1.1.3"
},
"license": "LGPL-3.0-only",
"minimum-stability": "dev",
"prefer-stable": true
}

0 comments on commit c869469

Please sign in to comment.