def test_feature_available_self_hosted_license_expired(self, patch_post): with freeze_time( "2070-01-01T12:00:00.000Z" ): # LicensedTestMixin enterprise license expires in 2038 sync_all_organization_available_features( ) # This is normally ran every hour self.organization.refresh_from_db() self.assertFalse( self.organization.is_feature_available("whatever"))
def test_feature_available_self_hosted_license_expired(self, patch_post): from ee.models.license import License mock = Mock() mock.json.return_value = {"plan": "enterprise", "valid_until": "2012-01-14T12:00:00.000Z"} patch_post.return_value = mock License.objects.create(key="key") with freeze_time("2012-01-19T12:00:00.000Z"): sync_all_organization_available_features() # This is normally ran every hour self.organization.refresh_from_db() self.assertFalse(self.organization.is_feature_available("whatever"))
def ready(self): posthoganalytics.api_key = "sTMFPsFhdP1Ssg" posthoganalytics.personal_api_key = os.environ.get( "POSTHOG_PERSONAL_API_KEY") if settings.TEST or os.environ.get("OPT_OUT_CAPTURE", False): posthoganalytics.disabled = True elif settings.DEBUG: # log development server launch to posthog if os.getenv("RUN_MAIN") == "true": # Sync all organization.available_features once on launch, in case plans changed from posthog.celery import sync_all_organization_available_features sync_all_organization_available_features() posthoganalytics.capture( get_machine_id(), "development server launched", { "posthog_version": VERSION, "git_rev": get_git_commit(), "git_branch": get_git_branch(), }, ) if SELF_CAPTURE: posthoganalytics.api_key = get_self_capture_api_token(None) else: posthoganalytics.disabled = True if not settings.SKIP_SERVICE_VERSION_REQUIREMENTS: for service_version_requirement in settings.SERVICE_VERSION_REQUIREMENTS: in_range, version = service_version_requirement.is_service_in_accepted_version( ) if not in_range: print( f"\033[91mService {service_version_requirement.service} is in version {version}. Expected range: {str(service_version_requirement.supported_version)}. PostHog may not work correctly with the current version. To continue anyway, add SKIP_SERVICE_VERSION_REQUIREMENTS=1 as an environment variable\033[0m", ) exit(1) from posthog.async_migrations.setup import setup_async_migrations if SKIP_ASYNC_MIGRATIONS_SETUP: print_warning([ "Skipping async migrations setup. This is unsafe in production!" ]) else: setup_async_migrations()
def license_saved(sender, instance, created, raw, using, **kwargs): sync_all_organization_available_features()