<commit_before>#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.

import datetime
import uuid

from oslo_config import cfg
from oslo_utils import timeutils
import pecan
import pecan.testing

from mistral.tests.unit.api import base


WORKBOOKS = [
    {
        u'name': u'my_workbook',
        u'description': u'My cool Mistral workbook',
        u'scope': None,
        u'tags': [u'deployment', u'demo']
    }
]


PKI_TOKEN_VERIFIED = {
    'token': {
        'methods': ['password'],
        'roles': [{'id': uuid.uuid4().hex,
                   'name': 'admin'}],
        'expires_at': datetime.datetime.isoformat(
            datetime.datetime.utcnow() + datetime.timedelta(seconds=60)
        ),
        'project': {
            'domain': {'id': 'default', 'name': 'Default'},
            'id': uuid.uuid4().hex,
            'name': 'Mistral'
        },
        'catalog': [],
        'extras': {},
        'user': {
            'domain': {'id': 'default', 'name': 'Default'},
            'id': uuid.uuid4().hex,
            'name': 'admin'
        },
        'issued_at': datetime.datetime.isoformat(timeutils.utcnow())
    }
}


class TestKeystoneMiddleware(base.APITest):
    """Test keystone middleware AuthProtocol.

    It checks that keystone middleware AuthProtocol is executed
    when enabled.<commit_msg>Replaces uuid.uuid4 with uuidutils.generate_uuid()<commit_after>#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.

import datetime
from oslo_config import cfg
from oslo_utils import timeutils
from oslo_utils import uuidutils
import pecan
import pecan.testing

from mistral.tests.unit.api import base


WORKBOOKS = [
    {
        u'name': u'my_workbook',
        u'description': u'My cool Mistral workbook',
        u'scope': None,
        u'tags': [u'deployment', u'demo']
    }
]


PKI_TOKEN_VERIFIED = {
    'token': {
        'methods': ['password'],
        'roles': [{'id': uuidutils.generate_uuid(dashed=False),
                   'name': 'admin'}],
        'expires_at': datetime.datetime.isoformat(
            datetime.datetime.utcnow() + datetime.timedelta(seconds=60)
        ),
        'project': {
            'domain': {'id': 'default', 'name': 'Default'},
            'id': uuidutils.generate_uuid(dashed=False),
            'name': 'Mistral'
        },
        'catalog': [],
        'extras': {},
        'user': {
            'domain': {'id': 'default', 'name': 'Default'},
            'id': uuidutils.generate_uuid(dashed=False),
            'name': 'admin'
        },
        'issued_at': datetime.datetime.isoformat(timeutils.utcnow())
    }
}


class TestKeystoneMiddleware(base.APITest):
    """Test keystone middleware AuthProtocol.

    It checks that keystone middleware AuthProtocol is executed
    when enabled.
{'fraction_non_alphanumeric': 0.12204103103629668, 'fraction_numerical': 0.004208311415044713, 'mean_word_length': 2.663776493256262, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4133912', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1113, 'n_words': 334}