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

fix recipientId generation #107

Open
wants to merge 4 commits into
base: 5.4
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
6 changes: 6 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ http://127.0.0.1:9080
http://127.0.0.1:9080/docusign/authorization_code/embedded_auth_code
http://127.0.0.1:9080/docusign/authorization_code/remote_auth_code

Detect and download the browser drivers automatically:

```shell
vendor/bin/bdi detect drivers
```

Then, run the following command to execute e2e tests:

```shell
Expand Down
47 changes: 17 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,22 @@ jobs:
- '8.0'
symfony:
- '4.4.*'
- '5.1.*'
- '5.2.*'
dependency:
- ''
- '--prefer-lowest'
include:
- deprecations: false
- php: '8.0'
dependency: ''
symfony: '5.2.*'
deprecations: true
- php: '7.4'
dependency: ''
symfony: '5.1.*'
symfony: '5.2.*'
coverage: true
bootable: true
- php: '8.0'
dependency: '--ignore-platform-req=php'
symfony: '4.4.*'
- php: '8.0'
dependency: '--ignore-platform-req=php'
symfony: '5.1.*'
- php: '8.0'
dependency: '--prefer-lowest --ignore-platform-req=php'
symfony: '4.4.*'
- php: '8.0'
dependency: '--prefer-lowest --ignore-platform-req=php'
symfony: '5.1.*'
exclude:
- php: '8.0'
dependency: ''
- php: '8.0'
dependency: '--prefer-lowest'
deprecations: true
fail-fast: false
steps:
- name: Checkout
Expand All @@ -57,9 +46,13 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: composer:v2, flex
coverage: pcov
tools: php-cs-fixer
tools: composer:v2, flex, php-cs-fixer

- name: Install chromium
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends chromium-browser

- name: Get Composer Cache Directory
id: composer-cache
Expand All @@ -79,7 +72,7 @@ jobs:
run: composer update --no-progress --ansi --prefer-stable ${{ matrix.dependency }}

- name: Disable deprecations notices for lowest dependencies
if: matrix.dependency != ''
if: matrix.deprecations == false
run: echo "SYMFONY_DEPRECATIONS_HELPER=weak" >> $GITHUB_ENV

- name: Bundle is bootable
Expand All @@ -93,20 +86,14 @@ jobs:
composer req gheb/docusign-bundle

- name: Run php-cs-fixer tests
if: matrix.php != '8.0'
run: php-cs-fixer fix --diff --dry-run

- name: Install chromium
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends chromium-browser

- name: Run phpstan tests
if: matrix.dependency == '' && matrix.php != '7.3' && matrix.php != '8.0'
if: matrix.dependency == '' && matrix.php == '7.4'
run: vendor/bin/phpstan analyze

- name: Run phpstan tests lowest
if: matrix.dependency != '' && matrix.php != '8.0'
if: matrix.dependency != '' && matrix.php == '7.4'
run: vendor/bin/phpstan analyze -c phpstan.neon.lowest.dist

- name: Prepare PHPUnit tests
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
/features/.env.*
!features/var/storage/dummy.pdf
/completed.pdf
/drivers/
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"webmozart/assert": "^1.5"
},
"require-dev": {
"dbrekelmans/bdi": "^0.3.0",
"doctrine/annotations": "^1.11",
"league/flysystem-bundle": "^1.2",
"nyholm/symfony-bundle-test": "dev-master",
Expand All @@ -54,7 +55,7 @@
"symfony/debug": "^4.4 || ^5.0",
"symfony/dotenv": "^4.4 || ^5.0",
"symfony/monolog-bundle": "^3.5",
"symfony/panther": "^0.6.1",
"symfony/panther": "^1.0",
"symfony/phpunit-bridge": "^5.1",
"symfony/polyfill-php72": "^1.9",
"symfony/process": "^4.4 || ^5.0",
Expand All @@ -79,10 +80,12 @@
},
"scripts": {
"post-install-cmd": [
"vendor/bin/simple-phpunit --version"
"vendor/bin/simple-phpunit --version",
"vendor/bin/bdi detect drivers"
],
"post-update-cmd": [
"vendor/bin/simple-phpunit --version"
"vendor/bin/simple-phpunit --version",
"vendor/bin/bdi detect drivers"
]
},
"config": {
Expand Down
10 changes: 5 additions & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<env name="KERNEL_CLASS" value="DocusignBundle\E2e\Kernel" />
<env name="SYMFONY_PHPUNIT_VERSION" value="9.4" />
<server name="PANTHER_WEB_SERVER_DIR" value="./features/public/" />
<server name="PANTHER_CHROME_DRIVER_BINARY" value="./tests/config/chromedriver" />
<server name="PANTHER_CHROME_DRIVER_BINARY" value="./drivers/chromedriver" />
<server name="PANTHER_NO_SANDBOX" value="1" />
</php>

Expand All @@ -20,11 +20,11 @@
</testsuite>
</testsuites>

<filter>
<whitelist>
<coverage>
<include>
<directory>src</directory>
</whitelist>
</filter>
</include>
</coverage>

<extensions>
<extension class="Symfony\Component\Panther\ServerExtension" />
Expand Down
3 changes: 1 addition & 2 deletions src/Controller/Callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@

final class Callback implements TranslatorAwareInterface
{
public const EVENT_COMPLETE = 'signing_complete';

use TranslatorAwareTrait;
public const EVENT_COMPLETE = 'signing_complete';

public function __invoke(Request $request, EventDispatcherInterface $eventDispatcher): Response
{
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->validate()
->ifString()
->then(static function ($v) {
@trigger_error('The "grant_type" configuration key has been deprecated since 5.3.0 and will be removed in 6.0. Implicit authentication should not be used in this bundle.', E_USER_DEPRECATED);
@trigger_error('The "grant_type" configuration key has been deprecated since 5.3.0 and will be removed in 6.0. Implicit authentication should not be used in this bundle.', \E_USER_DEPRECATED);

return $v;
})
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/DocusignExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function load(array $configs, ContainerBuilder $container): void
// Clickwrap mode
if (EnvelopeBuilder::MODE_CLICKWRAP === $value['mode']) {
$clickwrapExtensionDefinition->addMethodCall('addConfig', [$name, $value['demo'], [
'environment' => pathinfo($value['api_uri'], PATHINFO_DIRNAME),
'environment' => pathinfo($value['api_uri'], \PATHINFO_DIRNAME),
'accountId' => $value['auth_clickwrap']['api_account_id'],
'clientUserId' => $value['auth_clickwrap']['user_guid'],
'clickwrapId' => $value['auth_clickwrap']['clickwrap_id'],
Expand Down
4 changes: 2 additions & 2 deletions src/EnvelopeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function addCarbonCopy(string $name, string $email): self
$carbonCopy = new Model\CarbonCopy();
$carbonCopy->setEmail($email);
$carbonCopy->setName($name);
$carbonCopy->setRecipientId((string) $this->docReference);
vincentchalamon marked this conversation as resolved.
Show resolved Hide resolved
$carbonCopy->setRecipientId(sha1($email.$name));

$this->carbonCopies[] = $carbonCopy;

Expand Down Expand Up @@ -176,7 +176,7 @@ public function addSigner(string $name, string $email): self
$data = [
'email' => $email,
'name' => $name,
'recipient_id' => $this->docReference,
'recipient_id' => sha1($email.$name),
];

if (self::MODE_EMBEDDED === $this->getMode()) {
Expand Down
3 changes: 1 addition & 2 deletions src/EnvelopeCreator/DefineEnvelope.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@

final class DefineEnvelope implements EnvelopeBuilderCallableInterface, TranslatorAwareInterface
{
public const EMAIL_SUBJECT = 'Please sign this document';

use TranslatorAwareTrait;
public const EMAIL_SUBJECT = 'Please sign this document';

private $router;
private $envelopeBuilder;
Expand Down
2 changes: 1 addition & 1 deletion src/EnvelopeCreator/GetViewUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use DocusignBundle\Utils\CallbackRouteGenerator;
use Symfony\Component\Routing\RouterInterface;

/*final */class GetViewUrl implements EnvelopeBuilderCallableInterface
/*final */ class GetViewUrl implements EnvelopeBuilderCallableInterface
{
private $router;
private $envelopeBuilder;
Expand Down
4 changes: 2 additions & 2 deletions src/Grant/JwtGrant.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private function createToken(): string
->relatedTo($this->userGuid) // sub
->issuedAt($time) // iat
->expiresAt($time->modify("$this->ttl sec")) // exp
->permittedFor(parse_url($this->accountApiUri, PHP_URL_HOST)) // aud
->permittedFor(parse_url($this->accountApiUri, \PHP_URL_HOST)) // aud
->withClaim('scope', 'signature impersonation') // scope
->getToken($config->signer(), $config->signingKey())
->toString();
Expand All @@ -101,7 +101,7 @@ private function createToken(): string
->relatedTo($this->userGuid) // sub
->issuedAt($time) // iat
->expiresAt($time + $this->ttl) // exp
->permittedFor(parse_url($this->accountApiUri, PHP_URL_HOST)) // aud
->permittedFor(parse_url($this->accountApiUri, \PHP_URL_HOST)) // aud
->withClaim('scope', 'signature impersonation') // scope
->getToken(new Sha256(), new Key("file://$this->privateKey"));
}
Expand Down
2 changes: 1 addition & 1 deletion src/TokenEncoder/TokenEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function encode(array $parameters): string

return password_hash(http_build_query($parameters + [
'integration_key' => $this->integrationKey,
]), PASSWORD_BCRYPT);
]), \PASSWORD_BCRYPT);
}

public function isTokenValid(array $parameters, ?string $token): bool
Expand Down
8 changes: 7 additions & 1 deletion tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\HttpKernel\Kernel;

class ConfigurationTest extends TestCase
{
Expand Down Expand Up @@ -159,7 +160,12 @@ public function testItThrowsAnErrorOnInvalidModeConfig(): void
public function testItThrowsAnErrorOnMissingModeConfig(): void
{
$this->expectException(InvalidConfigurationException::class);
$this->expectExceptionMessage('The child node "mode" at path "docusign.demo" must be configured.');
// Error message has changed between Symfony 4.4 and 5.*
if (4 === Kernel::MAJOR_VERSION) {
$this->expectExceptionMessage('The child node "mode" at path "docusign.demo" must be configured.');
} else {
$this->expectExceptionMessage('The child config "mode" under "docusign.demo" must be configured: Type of signature to use: remote or embedded.');
}
$this->processor->processConfiguration($this->configuration, [
'docusign' => [
'demo' => true,
Expand Down
2 changes: 1 addition & 1 deletion tests/EmbeddedAuthCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,6 @@ public function testICanSignAnEmbeddedDocument(): void
$crawler = $client->waitFor('.alert');

$this->assertSame('The document has been successfully signed!', $crawler->filter('.alert')->text());
$this->assertSame('/embedded_auth_code', parse_url($crawler->getUri(), PHP_URL_PATH));
$this->assertSame('/embedded_auth_code', parse_url($crawler->getUri(), \PHP_URL_PATH));
}
}
2 changes: 1 addition & 1 deletion tests/EmbeddedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ public function testICanSignAnEmbeddedDocument(): void
$crawler = $client->waitFor('.alert');

$this->assertSame('The document has been successfully signed!', $crawler->filter('.alert')->text());
$this->assertSame('/embedded', parse_url($crawler->getUri(), PHP_URL_PATH));
$this->assertSame('/embedded', parse_url($crawler->getUri(), \PHP_URL_PATH));
}
}
2 changes: 1 addition & 1 deletion tests/EnvelopeCreator/CreateDocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class CreateDocumentTest extends TestCase
private $envelopeBuilderProphecyMock;
private $fileSystemProphecyMock;

public function setUp(): void
protected function setUp(): void
{
$this->envelopeBuilderProphecyMock = $this->prophesize(EnvelopeBuilderInterface::class);
$this->fileSystemProphecyMock = $this->prophesize(FilesystemInterface::class);
Expand Down
2 changes: 1 addition & 1 deletion tests/EnvelopeCreator/CreateSignatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CreateSignatureTest extends TestCase
private $envelopeBuilderProphecyMock;
private $signatureExtractorProphecyMock;

public function setUp(): void
protected function setUp(): void
{
$this->envelopeBuilderProphecyMock = $this->prophesize(EnvelopeBuilderInterface::class);
$this->signatureExtractorProphecyMock = $this->prophesize(SignatureExtractor::class);
Expand Down
2 changes: 1 addition & 1 deletion tests/EnvelopeCreator/DefineEnvelopeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DefineEnvelopeTest extends TestCase
private $translatorProphecyMock;
private $tokenEncoderProphecyMock;

public function setUp(): void
protected function setUp(): void
{
$this->envelopeBuilderProphecyMock = $this->prophesize(EnvelopeBuilderInterface::class);
$this->routerProphecyMock = $this->prophesize(RouterInterface::class);
Expand Down
2 changes: 1 addition & 1 deletion tests/EnvelopeCreator/EnvelopeCreatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class EnvelopeCreatorTest extends TestCase
private $defineEnvelopeProphecyMock;
private $sendEnvelopeProphecyMock;

public function setUp(): void
protected function setUp(): void
{
$this->envelopeBuilderProphecyMock = $this->prophesize(EnvelopeBuilderInterface::class);
$this->routerProphecyMock = $this->prophesize(RouterInterface::class);
Expand Down
2 changes: 1 addition & 1 deletion tests/EnvelopeCreator/GetViewUrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class GetViewUrlTest extends TestCase
private $envelopeBuilderProphecyMock;
private $routerProphecyMock;

public function setUp(): void
protected function setUp(): void
{
$this->envelopeBuilderProphecyMock = $this->prophesize(EnvelopeBuilderInterface::class);
$this->routerProphecyMock = $this->prophesize(RouterInterface::class);
Expand Down
2 changes: 1 addition & 1 deletion tests/EnvelopeCreator/SendEnvelopeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SendEnvelopeTest extends TestCase
private $envelopesApiProphecyMock;
private $envelopeSummaryProphecyMock;

public function setUp(): void
protected function setUp(): void
{
$this->envelopeBuilderProphecyMock = $this->prophesize(EnvelopeBuilderInterface::class);
$this->grantProphecyMock = $this->prophesize(GrantInterface::class);
Expand Down
2 changes: 1 addition & 1 deletion tests/RemoteAuthCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ public function testICanSentARemoteDocumentToBeSigned(): void
$crawler = $client->waitFor('.alert');

$this->assertSame('The document has been successfully sent to the signer!', $crawler->filter('.alert')->text());
$this->assertSame('/remote_auth_code', parse_url($crawler->getUri(), PHP_URL_PATH));
$this->assertSame('/remote_auth_code', parse_url($crawler->getUri(), \PHP_URL_PATH));
}
}
2 changes: 1 addition & 1 deletion tests/RemoteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ public function testICanSentARemoteDocumentToBeSigned(): void
$crawler = $client->waitFor('.alert');

$this->assertSame('The document has been successfully sent to the signer!', $crawler->filter('.alert')->text());
$this->assertSame('/remote', parse_url($crawler->getUri(), PHP_URL_PATH));
$this->assertSame('/remote', parse_url($crawler->getUri(), \PHP_URL_PATH));
}
}
Binary file removed tests/config/chromedriver
Binary file not shown.