Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/edda

crates/nornir-identity/tests/sso_feature.rs

//! **Company SSO is the core's default-off `sso` feature** (A34 M-4, IDENTITY-HOST):
//! edda nornir-identity-sso rides behind the core, so a product that names the core's
//! `sso` gets the protocols, rules and memory, and the default core links none of it.
//! Asked of cargo itself (`cargo tree`, offline, against this lock).

use std::process::Command;

fn tree(features: &[&str]) -> String {
    let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".to_owned());
    let manifest = concat!(env!("CARGO_MANIFEST_DIR"), "/Cargo.toml");
    let mut cmd = Command::new(cargo);
    cmd.args(["tree", "--offline", "--manifest-path", manifest, "-p", "nornir-identity", "-e", "normal", "--prefix", "none"]);
    if !features.is_empty() {
        cmd.args(["--features", &features.join(",")]);
    }
    let out = cmd.output().expect("cargo tree runs");
    assert!(out.status.success(), "cargo tree failed: {}", String::from_utf8_lossy(&out.stderr));
    String::from_utf8_lossy(&out.stdout).into_owned()
}

#[test]
fn the_default_core_links_no_company_sso() {
    let t = tree(&[]);
    assert!(t.contains("nornir-identity"), "{t}");
    assert!(!t.contains("nornir-identity-sso"), "the default core links company SSO:\n{t}");
    assert!(!t.contains("jsonwebtoken"), "{t}");
}

#[test]
fn the_sso_core_links_the_shared_sso_crate_and_its_protocols() {
    let t = tree(&["sso"]);
    for name in ["nornir-identity-sso", "nornir-auth-oidc", "nornir-auth-saml"] {
        assert!(t.contains(name), "the sso core lacks {name}:\n{t}");
    }
}