Skip to content

Commit

Permalink
Add trailing commas
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Aug 4, 2024
1 parent 2a72cac commit 33514e5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/Controller/MetaRefresh.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class MetaRefresh
* @throws \Exception
*/
public function __construct(
Configuration $config
Configuration $config,
) {
$this->config = $config;
$this->module_config = Configuration::getConfig('module_metarefresh.php');
Expand Down
10 changes: 5 additions & 5 deletions src/MetaLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public function loadSource(array $source): void
$entities = $this->loadXML($data, $source);

Check failure on line 148 in src/MetaLoader.php

View workflow job for this annotation

GitHub Actions / Quality control

PossiblyUndefinedVariable

src/MetaLoader.php:148:40: PossiblyUndefinedVariable: Possibly undefined variable $data defined in try block (see https://psalm.dev/018)
} catch (Exception $e) {
Logger::notice(
'XML parser error when parsing ' . $source['src'] . ' - attempting to re-use cached metadata'
'XML parser error when parsing ' . $source['src'] . ' - attempting to re-use cached metadata',
);
Logger::debug('XML parser returned: ' . $e->getMessage());
$this->addCachedMetadata($source);
Expand Down Expand Up @@ -199,7 +199,7 @@ public function loadSource(array $source): void
$source['src'],
$attributeAuthorities[0],

Check failure on line 200 in src/MetaLoader.php

View workflow job for this annotation

GitHub Actions / Quality control

InvalidArgument

src/MetaLoader.php:200:25: InvalidArgument: Argument 2 of SimpleSAML\Module\metarefresh\MetaLoader::addMetadata expects array<array-key, SAML2\XML\md\AttributeAuthorityDescriptor>|null, but SAML2\XML\md\AttributeAuthorityDescriptor provided (see https://psalm.dev/004)
'attributeauthority-remote',
$template
$template,
);
}
}
Expand All @@ -221,7 +221,7 @@ private function processCertificates(Metadata\SAMLParser $entity, array $source)
if (!$entity->validateSignature($source['certificates'])) {
$entityId = $entity->getEntityId();
Logger::notice(
'Skipping "' . $entityId . '" - could not verify signature using certificate.' . "\n"
'Skipping "' . $entityId . '" - could not verify signature using certificate.' . "\n",
);
return false;
}
Expand Down Expand Up @@ -481,7 +481,7 @@ public function writeState(): void
"<?php\n/* This file was generated by the metarefresh module at " . $this->getTime() . ".\n" .
" Do not update it manually as it will get overwritten. */\n" .
'$state = ' . var_export($this->state, true) . ";\n",
0644
0644,
);
}
}
Expand Down Expand Up @@ -577,7 +577,7 @@ public function writeARPfile(Configuration $config): void
$md,
$config->getOptionalString('attributemap', ''),
$config->getOptionalString('prefix', ''),
$config->getOptionalString('suffix', '')
$config->getOptionalString('suffix', ''),
);


Expand Down
2 changes: 1 addition & 1 deletion tests/src/ARPTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function testARP(): void
$config = Configuration::loadFromArray(
['module.enable' => ['metarefresh' => true]],
'[ARRAY]',
'simplesaml'
'simplesaml',
);
Configuration::setPreLoadedConfig($config, 'config.php');

Expand Down
21 changes: 11 additions & 10 deletions tests/src/MetaLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace SimpleSAML\Test\Module\metarefresh;

use Exception;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Configuration;

Expand Down Expand Up @@ -77,7 +78,7 @@ protected function setUp(): void
$this->config = Configuration::loadFromArray(
['module.enable' => ['metarefresh' => true]],
'[ARRAY]',
'simplesaml'
'simplesaml',
);
Configuration::setPreLoadedConfig($this->config, 'config.php');
$this->metaloader = new \SimpleSAML\Module\metarefresh\MetaLoader();
Expand Down Expand Up @@ -106,20 +107,20 @@ public function testMetaLoader(): void
$output = $this->getActualOutputForAssertion();
try {
eval($output);
} catch (\Exception $e) {
} catch (Exception $e) {
$this->fail('Metarefresh does not produce syntactially valid code');
}
$this->assertArrayHasKey('https://idp.example.com/idp/shibboleth', $metadata);

$this->assertTrue(
empty(array_diff_key($this->expected, $metadata['https://idp.example.com/idp/shibboleth']))
empty(array_diff_key($this->expected, $metadata['https://idp.example.com/idp/shibboleth'])),
);
}

public function testSignatureVerificationCertificatePass(): void
{
$this->metaloader->loadSource(
array_merge($this->source, ['certificates' => [dirname(__FILE__, 2) . '/mdx.pem']])
array_merge($this->source, ['certificates' => [dirname(__FILE__, 2) . '/mdx.pem']]),
);
$this->metaloader->dumpMetadataStdOut();
$this->expectOutputRegex('/UTEbMBkGA1UECgwSRXhhbXBsZSBVbml2ZXJzaXR5MRgwFgYDVQQDDA9pZHAuZXhh/');
Expand All @@ -140,7 +141,7 @@ public function testWriteMetadataFiles(): void
$this->assertArrayHasKey('https://idp.example.com/idp/shibboleth', $metadata);
$this->assertTrue(
/** @psalm-suppress UndefinedVariable */
empty(array_diff_key($this->expected, $metadata['https://idp.example.com/idp/shibboleth']))
empty(array_diff_key($this->expected, $metadata['https://idp.example.com/idp/shibboleth'])),
);
}

Expand All @@ -158,7 +159,7 @@ public function testMetaLoaderSetExpiryWhenNotPresent(): void
$output = $this->getActualOutputForAssertion();
try {
eval($output);
} catch (\Exception $e) {
} catch (Exception $e) {
$this->fail('Metarefresh does not produce syntactially valid code');
}
$this->assertArrayHasKey('https://idp.example.com/idp/shibboleth', $metadata);
Expand Down Expand Up @@ -189,14 +190,14 @@ public function testAttributewhitelist1(): void
$output = $this->getActualOutputForAssertion();
try {
eval($output);
} catch (\Exception $e) {
} catch (Exception $e) {
$this->fail('Metarefresh does not produce syntactially valid code');
}
/* Check we matched the IdP */
$this->assertArrayHasKey('https://idp.example.com/idp/shibboleth', $metadata);

$this->assertTrue(
empty(array_diff_key($this->expected, $metadata['https://idp.example.com/idp/shibboleth']))
empty(array_diff_key($this->expected, $metadata['https://idp.example.com/idp/shibboleth'])),
);
}

Expand Down Expand Up @@ -257,15 +258,15 @@ public function testAttributewhitelist3(): void
$output = $this->getActualOutputForAssertion();
try {
eval($output);
} catch (\Exception $e) {
} catch (Exception $e) {
$this->fail('Metarefresh does not produce syntactially valid code');
}

/* Check we matched the IdP */
$this->assertArrayHasKey('https://idp.example.com/idp/shibboleth', $metadata);

$this->assertTrue(
empty(array_diff_key($this->expected, $metadata['https://idp.example.com/idp/shibboleth']))
empty(array_diff_key($this->expected, $metadata['https://idp.example.com/idp/shibboleth'])),
);
}
}

0 comments on commit 33514e5

Please sign in to comment.