diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f59ee3a..d0a836e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Add support for date filters and `finished_at` ordering in `Deployments::all` * Add support for listing merge requests associated with a deployment * Add support for `with_custom_attributes` and `with_projects` in `Groups::show` +* Add support for project remote mirror read endpoints ## [12.0.0] - 2025-02-23 diff --git a/src/Api/Projects.php b/src/Api/Projects.php index 5de2ca13..92f5ecfa 100644 --- a/src/Api/Projects.php +++ b/src/Api/Projects.php @@ -1296,6 +1296,21 @@ public function deleteProtectedTag(int|string $project_id, string $tag_name): mi return $this->delete($this->getProjectPath($project_id, 'protected_tags/'.self::encodePath($tag_name))); } + public function remoteMirrors(int|string $project_id): mixed + { + return $this->get($this->getProjectPath($project_id, 'remote_mirrors')); + } + + public function remoteMirror(int|string $project_id, int $mirror_id): mixed + { + return $this->get($this->getProjectPath($project_id, 'remote_mirrors/'.self::encodePath($mirror_id))); + } + + public function remoteMirrorPublicKey(int|string $project_id, int $mirror_id): mixed + { + return $this->get($this->getProjectPath($project_id, 'remote_mirrors/'.self::encodePath($mirror_id).'/public_key')); + } + /** * @param array $parameters { * diff --git a/tests/Api/ProjectsTest.php b/tests/Api/ProjectsTest.php index 0f7c7d5b..a2ba2602 100644 --- a/tests/Api/ProjectsTest.php +++ b/tests/Api/ProjectsTest.php @@ -2790,6 +2790,50 @@ public function shouldRemoveProtectedTag(): void $this->assertEquals($expectedBool, $api->deleteProtectedTag(1, 'release-*')); } + #[Test] + public function shouldGetRemoteMirrors(): void + { + $expectedArray = [ + ['id' => 101486, 'url' => 'https://*****:*****@gitlab.com/gitlab-org/security/gitlab.git'], + ]; + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with('projects/1/remote_mirrors') + ->willReturn($expectedArray); + + $this->assertEquals($expectedArray, $api->remoteMirrors(1)); + } + + #[Test] + public function shouldGetRemoteMirror(): void + { + $expectedArray = ['id' => 101486, 'url' => 'https://*****:*****@gitlab.com/gitlab-org/security/gitlab.git']; + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with('projects/1/remote_mirrors/101486') + ->willReturn($expectedArray); + + $this->assertEquals($expectedArray, $api->remoteMirror(1, 101486)); + } + + #[Test] + public function shouldGetRemoteMirrorPublicKey(): void + { + $expectedArray = ['public_key' => 'ssh-rsa AAAAB3NzaC1yc2EA...']; + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with('projects/1/remote_mirrors/101486/public_key') + ->willReturn($expectedArray); + + $this->assertEquals($expectedArray, $api->remoteMirrorPublicKey(1, 101486)); + } + protected function getApiClass(): string { return Projects::class;