<commit_before>import time
import json
import logging
import pytest

from six import StringIO
from six.moves.urllib.parse import urljoin
from jenkinsapi.jenkins import Jenkins
from jenkinsapi.utils.crumb_requester import CrumbRequester
from jenkinsapi_tests.test_utils.random_strings import random_string
from jenkinsapi_tests.systests.job_configs import JOB_WITH_FILE


log = logging.getLogger(__name__)

DEFAULT_JENKINS_PORT = 8080
ENABLE_CRUMBS_CONFIG = {
    '': '0',
    'markupFormatter': {
        'stapler-class': 'hudson.markup.EscapedMarkupFormatter',
        '$class': 'hudson.markup.EscapedMarkupFormatter'
    },
    'hudson-security-csrf-GlobalCrumbIssuerConfiguration': {
        'csrf': {
            'issuer': {
                'value': '0',
                'stapler-class': 'hudson.security.csrf.DefaultCrumbIssuer',
                '$class': 'hudson.security.csrf.DefaultCrumbIssuer',
                'excludeClientIPFromCrumb': False
            }
        }
    },
    'jenkins-model-DownloadSettings': {
        'useBrowser': False
    },
    'core:apply': '',
}

DISABLE_CRUMBS_CONFIG = {
    '': '0',
    'markupFormatter': {
        'stapler-class': 'hudson.markup.EscapedMarkupFormatter',
        '$class': 'hudson.markup.EscapedMarkupFormatter'
    },
    'hudson-security-csrf-GlobalCrumbIssuerConfiguration': {},
    'jenkins-model-DownloadSettings': {
        'useBrowser': False
    },
    'core:apply': ''
}


@pytest.fixture(scope='function')
def crumbed_jenkins(jenkins):<commit_msg>fix security json for 2.x Jenkins (#541)<commit_after>import os
import time
import json
import logging
import pytest

from six import StringIO
from six.moves.urllib.parse import urljoin
from jenkinsapi.jenkins import Jenkins
from jenkinsapi.utils.crumb_requester import CrumbRequester
from jenkinsapi_tests.test_utils.random_strings import random_string
from jenkinsapi_tests.systests.job_configs import JOB_WITH_FILE


log = logging.getLogger(__name__)

DEFAULT_JENKINS_PORT = 8080

ENABLE_CRUMBS_CONFIG = {
    '': '0',
    'markupFormatter': {
        'stapler-class': 'hudson.markup.EscapedMarkupFormatter',
        '$class': 'hudson.markup.EscapedMarkupFormatter'
    },
    'hudson-security-csrf-GlobalCrumbIssuerConfiguration': {
        'csrf': {
            'issuer': {
                'value': '0',
                'stapler-class': 'hudson.security.csrf.DefaultCrumbIssuer',
                '$class': 'hudson.security.csrf.DefaultCrumbIssuer',
                'excludeClientIPFromCrumb': False
            }
        }
    },
    'jenkins-model-DownloadSettings': {
        'useBrowser': False
    },
    'org-jenkinsci-main-modules-sshd-SSHD': {
        'port': {
            'value': '',
            'type': 'random'
        }
    },
    'core:apply': ''
}

DISABLE_CRUMBS_CONFIG = {
    '': '0',
    'markupFormatter': {
        'stapler-class': 'hudson.markup.EscapedMarkupFormatter',
        '$class': 'hudson.markup.EscapedMarkupFormatter'
    },
    'hudson-security-csrf-GlobalCrumbIssuerConfiguration': {},
    'jenkins-model-DownloadSettings': {
        'useBrowser': False
    },
    'core:apply': ''
}

JENKINS2_SSHD_SETTINGS = {
    'org-jenkinsci-main-modules-sshd-SSHD': {
        'port': {
            'value': '',
            'type': 'random'
        }
    }
}

@pytest.fixture(scope='function')
def crumbed_jenkins(jenkins):
    if '2.x' in os.environ.get('JENKINS_VERSION', '1.x'):
        ENABLE_CRUMBS_CONFIG.update(JENKINS2_SSHD_SETTINGS)
        DISABLE_CRUMBS_CONFIG.update(JENKINS2_SSHD_SETTINGS)

{'fraction_non_alphanumeric': 0.12602199041443474, 'fraction_numerical': 0.006484352974344516, 'mean_word_length': 2.9910011248593924, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7314623', 'n_tokens_mistral': 1236, 'n_tokens_neox': 1186, 'n_words': 171}