-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Resources, deprecations, new unit and feature tests #5
Conversation
- Replaced PestPHP with PHPUnit (version 9.6.20) as the testing framework. - Updated PHP version requirement from >=5.6 to >=7.4. - Removed the PestPHP plugin configuration from composer.json. - Deleted obsolete test files from the 'tests/Clients' directory. - Removed author information from composer.json.
… Naming - Deprecated `setStrategy()` method and added a notice for future removal. - Set `PasswordAuthentication` strategy by default in the constructor. - Deprecated `execute()` and `getRequest()` methods with plans for future renaming. - Removed outdated test cases related to setting authentication strategy.
- Update .gitignore to include rules for PHPUnit-related files. - Add PHPUnit result cache file to track test results. - Create `BlueskyClientTest` under `tests/Feature/` to cover: - Constructor tests for default and custom URLs. - `getRequest` method test. - `authenticate` method tests for valid and invalid credentials. - `execute` method tests for CreateRecord, UploadBlob, GetProfile, and combined operations.
Refactor BlueskyClient: Deprecations and Method Naming Improvements
Migrate from Pest to PHPUnit for Unit Testing
- Refactor client for working with casting - Add a resource (`GetProfileResource.php`) for `GetProfile.php` request - Add assets of `GetProfileResource.php`
…e assets - Introduced `AssetTest` trait to handle common setup and data for tests. - Added `ByListAssetTest`, `UserAssetTest`, `PrimitiveAssetTest`, and `NonPrimitiveAssetTest` traits to test both primitive and non-primitive assets. - Implemented test methods for falsy values, primitive asset verification, and non-primitive asset checks using reflection. - Added data providers to supply test cases for various assets, ensuring comprehensive test coverage.
- Added GetProfileResourceTest for testing primitive and non-primitive assets in `GetProfileResource`. - Created AssociatedAssetTest to validate `AssociatedAsset` primitive and non-primitive data handling. - Added BlockingByListAssetTest to test functionality of `BlockingByListAsset`. - Developed ChatAssetTest to check handling of primitive assets in `ChatAsset`. - Implemented CreatorAssetTest to test `CreatorAsset` with `UserAsset`. - Added DatetimeAssetTest to ensure correct behavior for `DatetimeAsset`, including valid date casting and exception handling for invalid formats. etc.
- Added two new methods to the ResourceContract interface: - `get(string $name)` to retrieve an asset by name, throwing a `BadAssetCallException` if the asset does not exist. - `exist(string $name): bool` to check if an asset exists on the resource.
- Created two new classes: `FollowerAssetType` and `LabelAssetType` under `Atproto\GenericCollection\Types\NonPrimitive`. - Both classes implement the `TypeInterface` and define a `validate` method that checks if a given value is an instance of `FollowerAsset` or `LabelAsset` respectively.
- Updated `BaseAsset` to use `AssetContract` instead of `ResourceContract`. - Added type casting to the `BaseAsset` constructor. - Modified `BaseResource` to change the method `exists` to `exist` for consistency. - Improved the `get` method in `BaseResource` to throw a `BadAssetCallException` if the asset does not exist and refactored the error handling logic. - Enhanced code readability with proper documentation and parameter alignment in `BaseResource`.
- Moved assets from `NonPrimitive` to `Assets` namespace. - Updated `GetProfileResource` to use new asset class paths. - Simplified asset classes by removing redundant code and reorganizing. - Introduced `CollectionAsset` trait for managing collections of assets. - Updated asset classes to utilize new `CollectionAsset` trait. - Removed obsolete asset classes and redundant methods. - Adjusted related files and classes to reflect namespace changes and improvements. Changes include: - Renamed and moved asset classes. - Updated class constructors and methods. - Added new asset classes for labels and followers. - Removed deprecated classes and methods.
- Introduced `BaseAssetTest`, `CollectionAssetTest`, `UserAssetTest`, and `BaseResourceTest` to test asset and resource-related functionality. - Ensured casting and reverting methods in `TestableAsset` and `TestCollectionAsset` are properly tested. - Verified dynamic method access and casting functionality in `UserAssetTest`. - Added tests for constructor and method behavior for `TestUserAsset`. - Confirmed that `BaseResourceTest` handles invalid asset calls gracefully.
- Added ResourceSupport trait to handle resource responses more flexibly. - Updated `GetProfile`, `CreateRecord`, and `UploadBlob` classes to use the new trait and return `ResourceContract` where applicable. - Enhanced `BlueskyClient` to support requests with and without resource responses. - Added tests for `BlueskyClient` to verify behavior with requests lacking `ResourceSupport`.
- Added `test` script to run PHPUnit tests with `composer test`. - Added `analyse` script to run PHPStan static analysis with `composer analyse`.
- Moved curl_close() to the correct location in BlueskyClient.php to ensure proper resource cleanup. - Modified assertions in BlueskyClientTest.php to ensure consistent handling of response data. - Improved reflection handling in NonPrimitiveAssetTest.php to correctly access private properties.
- Modified GitHub Actions workflow to ignore errors during feature tests by adding `continue-on-error: true` to the "Run Feature Tests" step. - Updated Composer scripts to define separate commands for unit and feature tests. - Adjusted paths in the `BlueskyClientTest` class to use relative paths for assets.
…tion - Marked methods `addText()`, `addType()`, `addCreatedAt()`, `addImage()`, and `buildRecord()` in `RecordBuilder` as deprecated. Introduced alternative methods `text()`, `type()`, `createdAt()`, `image()`, and `build()` for future use. - Updated `BlueskyClient` with deprecation notices for `setStrategy()`, `execute()`, and `getRequest()` methods, suggesting new methods to handle authentication and request processes more efficiently. - Refactored the `urlRegex` property in `RecordBuilder` as `static` and applied consistent formatting and trigger error warnings for deprecated methods.
|
GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
---|---|---|---|---|---|
10586546 | Triggered | Generic Password | 04bd6a3 | tests/Clients/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 812b97d | tests/Feature/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 812b97d | tests/Clients/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | a14bb3a | tests/Clients/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 812b97d | tests/Feature/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 812b97d | tests/Clients/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 812b97d | tests/Clients/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | a14bb3a | tests/Feature/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 812b97d | tests/Feature/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 04bd6a3 | tests/Clients/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 04bd6a3 | tests/Clients/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | a14bb3a | tests/Feature/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 04bd6a3 | tests/Clients/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 812b97d | tests/Clients/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | a14bb3a | tests/Feature/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 04bd6a3 | tests/Clients/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 812b97d | tests/Feature/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | a14bb3a | tests/Clients/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | a14bb3a | tests/Clients/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | a14bb3a | tests/Clients/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 812b97d | tests/Feature/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | a14bb3a | tests/Feature/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | a14bb3a | tests/Feature/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | a14bb3a | tests/Clients/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 812b97d | tests/Clients/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 04bd6a3 | tests/Clients/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 05046e6 | tests/Clients/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 32bb079 | tests/Feature/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 32bb079 | tests/Feature/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 32bb079 | tests/Feature/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 32bb079 | tests/Feature/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 32bb079 | tests/Feature/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 90c2664 | tests/Clients/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 2c9bc1d | tests/Clients/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 339f2d0 | tests/Feature/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 339f2d0 | tests/Feature/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 339f2d0 | tests/Feature/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 8c36772 | tests/Feature/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | a82fbec | tests/Feature/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | a82fbec | tests/Feature/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | a82fbec | tests/Feature/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | a82fbec | tests/Feature/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | a82fbec | tests/Feature/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | a82fbec | tests/Feature/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | a82fbec | tests/Feature/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 7c81e3c | tests/Feature/BlueskyClientTest.php | View secret |
10586546 | Triggered | Generic Password | 9f8d593 | tests/Feature/BlueskyClientTest.php | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secrets safely. Learn here the best practices.
- Revoke and rotate these secrets.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
BlueskyClient
to Introduce Deprecations and Improve Method NamingBlueskyClientTest.php
composer.json
to includephpstan/phpstan
for static analysis.UserAssetTest.php