Skip to content

Commit

Permalink
fix validation logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Maciej Wójcik committed Jan 7, 2025
1 parent 08e103f commit c98c178
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/enterprise/license.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ pub(crate) fn validate_license(
if license.is_max_overdue() {
return Err(LicenseError::LicenseExpired);
}
if !counts.validate_license_limits(license) {
if counts.is_over_license_limits(license) {
return Err(LicenseError::LicenseLimitsExceeded);
}
Ok(())
Expand Down Expand Up @@ -736,7 +736,10 @@ mod test {
Some(Utc::now() + TimeDelta::days(1)),
None,
);
assert!(validate_license(Some(&license), &counts).is_ok());
// assert!(validate_license(Some(&license), &counts).is_ok());
let result = validate_license(Some(&license), &counts);
println!("{result:#?}");
assert!(result.is_ok());

// No expiry date, non-subscription license
let license = License::new("test".to_string(), false, None, None);
Expand Down
4 changes: 2 additions & 2 deletions src/enterprise/limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl Counts {
match &*maybe_license {
Some(license) => {
debug!("Cached license found. Validating license limits...");
self.validate_license_limits(license)
self.is_over_license_limits(license)
}
// free tier
None => {
Expand All @@ -112,7 +112,7 @@ impl Counts {
}
}

pub(crate) fn validate_license_limits(&self, license: &License) -> bool {
pub(crate) fn is_over_license_limits(&self, license: &License) -> bool {
let limits = &license.limits;
match limits {
Some(limits) => {
Expand Down

0 comments on commit c98c178

Please sign in to comment.