Skip to content

Commit 69a168c

Browse files
authored
Start using composer to get SSP version (#2617)
* Use composer to get SSP version * Apply phpcbf fixes
1 parent 1993139 commit 69a168c

4 files changed

Lines changed: 16 additions & 8 deletions

File tree

modules/saml/src/Auth/Process/FilterScopes.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class FilterScopes extends ProcessingFilter
3434
*/
3535
private bool $allowNonScoped = true;
3636

37+
3738
/**
3839
* Constructor for the processing filter.
3940
*

src/SimpleSAML/Configuration.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@
3838
*/
3939
class Configuration implements Utils\ClearableState
4040
{
41-
/**
42-
* The release version of this package
43-
*/
44-
public const string VERSION = 'dev-master';
45-
4641
/**
4742
* A default value which means that the given option is required.
4843
*/
@@ -384,7 +379,14 @@ public static function getInstance(string $instancename = 'simplesaml'): Configu
384379
*/
385380
public function getVersion(): string
386381
{
387-
return self::VERSION;
382+
$version = \Composer\InstalledVersions::getRootPackage()['pretty_version'];
383+
// If the returned version is in format `vX.Y.Z`, remove leading
384+
// `v` to keep the compatibility with the previously used
385+
// format `X.Y.Z`.
386+
if (preg_match('/^v\d+\.\d+\.\d+/', $version)) {
387+
return substr($version, 1);
388+
}
389+
return $version;
388390
}
389391

390392

tests/modules/saml/src/Auth/Process/FilterScopesTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,11 @@ public function testAttributeValueMultipleAt(): void
223223
$this->assertEquals($request['Attributes'], $result['Attributes']);
224224
}
225225

226+
226227
/**
227228
* Test that non-scoped values pass or not depending on default or filter config setting.
228229
*/
229-
public function testNonScopedValuesRemovedWhenDisallowed(): void
230+
public function testNonScopedValuesRemovedWhenDisallowed(): void
230231
{
231232
$config = [
232233
// Explicitly disallow non-scoped values

tests/src/SimpleSAML/ConfigurationTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ class ConfigurationTest extends ClearStateTestCase
2424
public function testGetVersion(): void
2525
{
2626
$c = Configuration::getOptionalConfig();
27-
$this->assertEquals($c->getVersion(), Configuration::VERSION);
27+
$version = \Composer\InstalledVersions::getRootPackage()['pretty_version'];
28+
if (preg_match('/^v\d+\.\d+\.\d+/', $version)) {
29+
$version = substr($version, 1);
30+
}
31+
$this->assertEquals($c->getVersion(), $version);
2832
}
2933

3034

0 commit comments

Comments
 (0)