Testing | laravel-suspicious-login-rust | Spatie       

 SPATIE  

laravel-suspicious-login-rust
=============================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-suspicious-login-rust](https://spatie.be/docs/laravel-suspicious-login-rust/v1)  Testing

 Version   v1      

 Other versions for crawler [v1](https://spatie.be/docs/laravel-suspicious-login-rust/v1) 

  Testing    
- [ Introduction ](https://spatie.be/docs/laravel-suspicious-login-rust/v1/introduction)
- [ Support us ](https://spatie.be/docs/laravel-suspicious-login-rust/v1/support-us)
- [ Installation ](https://spatie.be/docs/laravel-suspicious-login-rust/v1/installation-and-setup)
- [ Usage ](https://spatie.be/docs/laravel-suspicious-login-rust/v1/usage)
- [ Detection ](https://spatie.be/docs/laravel-suspicious-login-rust/v1/detection)
- [ Testing ](https://spatie.be/docs/laravel-suspicious-login-rust/v1/testing)
- [ Changelog ](https://spatie.be/docs/laravel-suspicious-login-rust/v1/changelog)
- [ Customization ](https://spatie.be/docs/laravel-suspicious-login-rust/v1/customization)

 Testing
=======

###  On this page 

1. [ Fake geolocation ](#content-fake-geolocation)
2. [ Package checks ](#content-package-checks)

Fake geolocation
--------------------------------------------------------------------------------------------------------

- Use the framework HTTP fake and prevent stray requests. Keep its guard alive until assertions finish.
- Run the lookup inside your application's test context. This example creates an isolated application:

```
use laravel::{Application, http::client};
use spatie_suspicious_login::drivers::Geolocation;

let app = Application::configure()
    .for_testing(env!("CARGO_MANIFEST_DIR"))
    .create();
app.scope(async || -> laravel::Result<()> {
    let http = client::fake()
        .with("ipinfo.io/*", serde_json::json!({"country": "BE", "city": "Antwerp"}))
        .prevent_stray_requests();

    let location = Geolocation::default()
        .locate("81.82.83.84".parse()?, None).await?
        .expect("the fake provides a location");

    assert_eq!(location.country, "BE");
    http.assert_sent_count(1);
    Ok(())
}).await?;
```

Package checks
--------------------------------------------------------------------------------------------------

Run these checks from the package directory:

```
cargo fmt --all -- --check
cargo clippy --locked --all-targets --all-features -- -D warnings
cargo test --locked --all-targets --all-features
cargo test --locked --doc --all-features
cargo doc --locked --no-deps --all-features
bash scripts/check-package
```

- Set `RUSTDOCFLAGS` to `-D warnings` for documentation checks. In POSIX shells, prefix commands with `RUSTDOCFLAGS='-D warnings'`. In PowerShell, first run `$env:RUSTDOCFLAGS = '-D warnings'`.
- Clippy enables `all` and `pedantic`. CI rejects warnings; the native async test-hook signature has one documented lint exception.
- README.md and every Markdown guide participate in rustdoc tests. Setup lines prefixed with `# ` execute but are hidden in rustdoc. Assertions check example results.

Check the minimum supported Rust version:

```
rustup toolchain install 1.99.0 --profile minimal
cargo +1.99.0 test --locked --all-targets --all-features
cargo +1.99.0 test --locked --doc --all-features
```

Check security advisories:

```
cargo install cargo-audit --locked
cargo audit
```

- CI runs stable checks on Linux, macOS and Windows, and MSRV and audit checks on Linux.
- The audit requires access to the RustSec advisory database.
- Integration tests use isolated SQLite databases, model-backed users, real session guards, event listeners and mail fakes.
- Geolocation and reputation use local fixtures or HTTP fakes with stray requests blocked. Tests do not query external IP/account APIs or send real mail.
- All-feature compilation does not prove MySQL/PostgreSQL runtime behavior. Check individual feature selections too:

```
cargo check --locked --lib --no-default-features --features sqlite
cargo check --locked --lib --no-default-features --features mysql
cargo check --locked --lib --no-default-features --features postgres
```

- `scripts/check-package` builds an archive from Cargo's selected source files and runs its tests and doctests. It publishes nothing.
- Registry packaging rewrites Git dependencies to crates.io, where package tools is not published; this check retains its pinned Git source.
- Keep README rustdoc inclusion and recursive guide discovery in `build.rs` when adding guides.

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
