MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / test_license_validation

Function test_license_validation

rust/tests/initialization.rs:13–36  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11
12#[test]
13fn test_license_validation() {
14 // Release floating license if we already have one, otherwise the failure will succeed.
15 release_license();
16 // Make sure we properly report invalid license.
17 let options = InitializationOptions::default()
18 .with_license_checkout(false)
19 .with_license("blah blag");
20 match init_with_opts(options) {
21 Ok(_) => panic!("Expected license validation to fail, but it succeeded!"),
22 Err(InitializationError::InvalidLicense) => {}
23 Err(e) => panic!("Unexpected error: {:?}", e),
24 }
25 // Reset the license so that it actually can validate license.
26 set_license::<String>(None);
27 // Actually make sure we can initialize.
28 init().expect("Failed to initialize, make sure you have a license before trying to run tests!");
29 // Open an empty binary and make sure it succeeds.
30 let view = BinaryView::from_data(&FileMetadata::new(), &[]);
31 assert!(
32 view.is_ok(),
33 "Failed to open empty binary, core initialization failed!"
34 );
35 shutdown();
36}

Callers

nothing calls this directly

Calls 6

init_with_optsFunction · 0.85
initFunction · 0.85
with_licenseMethod · 0.80
with_license_checkoutMethod · 0.80
release_licenseFunction · 0.50
shutdownFunction · 0.50

Tested by

no test coverage detected