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

Resources, deprecations, new unit and feature tests #5

Merged
merged 35 commits into from
Sep 7, 2024
Merged

Conversation

shahmal1yev
Copy link
Owner

  • refactor: Replace Pest with PHPUnit and remove obsolete test files
  • Refactor BlueskyClient to Introduce Deprecations and Improve Method Naming
  • Add PHPUnit support and BlueskyClient feature tests
  • Update PHP requirement from >=5.6 to >=7.4
  • Create helpers.php on src and add it to files of composer.json
  • Client refactoring, resources, assets
  • feat(tests): add asset testing support for primitive and non-primitive assets
  • Add unit tests for various resource and asset classes
  • Create BadAssetCallException
  • Update ResourceContract interface with asset methods
  • Add new non-primitive types: FollowerAssetType and LabelAssetType
  • Refactor asset handling in BaseAsset and BaseResource
  • Refactor Assets Namespace and Structure
  • Refactor imports in BlueskyClientTest.php
  • Add LabelAssetTest class for LabelAsset testing
  • Update composer.json and remove helpers.php
  • Refactor variable name in CollectionAsset
  • Added unit tests for Asset and Resource classes
  • Added method annotations
  • docs: update README with badges, dependencies, and usage example
  • Add ResourceSupport Trait and Update API Implementations
  • Updated composer.json to include phpstan/phpstan for static analysis.
  • Add $data property to the UserAssetTest.php
  • Add Composer Scripts for Testing and Static Analysis
  • Add GitHub Actions workflow
  • Fix: Adjust BlueskyClient and Tests
  • Update GitHub Actions workflow and Composer scripts
  • Refactor Bluesky RecordBuilder and Client for consistency and deprecation

- 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.
- BlueskyClientTest's "execute" method accessing object properties as directly
- Move `LabelAssetTest` to correct directory
- 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.
Copy link

gitguardian bot commented Sep 7, 2024

⚠️ GitGuardian has uncovered 47 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
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
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. 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


🦉 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.

@shahmal1yev shahmal1yev merged commit 6a3427f into main Sep 7, 2024
3 checks passed
@shahmal1yev shahmal1yev self-assigned this Sep 23, 2024
@shahmal1yev shahmal1yev added the enhancement New feature or request label Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant