Best Python code snippet using playwright-python
test_util.py
Source:test_util.py  
...82class Test_does_tree_import(support.TestCase):83    def _find_bind_rec(self, name, node):84        # Search a tree for a binding -- used to find the starting85        # point for these tests.86        c = fixer_util.find_binding(name, node)87        if c: return c88        for child in node.children:89            c = self._find_bind_rec(name, child)90            if c: return c91    def does_tree_import(self, package, name, string):92        node = parse(string)93        # Find the binding of start -- that's what we'll go from94        node = self._find_bind_rec('start', node)95        return fixer_util.does_tree_import(package, name, node)96    def try_with(self, string):97        failing_tests = (("a", "a", "from a import b"),98                         ("a.d", "a", "from a.d import b"),99                         ("d.a", "a", "from d.a import b"),100                         (None, "a", "import b"),101                         (None, "a", "import b, c, d"))102        for package, name, import_ in failing_tests:103            n = self.does_tree_import(package, name, import_ + "\n" + string)104            self.assertFalse(n)105            n = self.does_tree_import(package, name, string + "\n" + import_)106            self.assertFalse(n)107        passing_tests = (("a", "a", "from a import a"),108                         ("x", "a", "from x import a"),109                         ("x", "a", "from x import b, c, a, d"),110                         ("x.b", "a", "from x.b import a"),111                         ("x.b", "a", "from x.b import b, c, a, d"),112                         (None, "a", "import a"),113                         (None, "a", "import b, c, a, d"))114        for package, name, import_ in passing_tests:115            n = self.does_tree_import(package, name, import_ + "\n" + string)116            self.assertTrue(n)117            n = self.does_tree_import(package, name, string + "\n" + import_)118            self.assertTrue(n)119    def test_in_function(self):120        self.try_with("def foo():\n\tbar.baz()\n\tstart=3")121class Test_find_binding(support.TestCase):122    def find_binding(self, name, string, package=None):123        return fixer_util.find_binding(name, parse(string), package)124    def test_simple_assignment(self):125        self.assertTrue(self.find_binding("a", "a = b"))126        self.assertTrue(self.find_binding("a", "a = [b, c, d]"))127        self.assertTrue(self.find_binding("a", "a = foo()"))128        self.assertTrue(self.find_binding("a", "a = foo().foo.foo[6][foo]"))129        self.assertFalse(self.find_binding("a", "foo = a"))130        self.assertFalse(self.find_binding("a", "foo = (a, b, c)"))131    def test_tuple_assignment(self):132        self.assertTrue(self.find_binding("a", "(a,) = b"))133        self.assertTrue(self.find_binding("a", "(a, b, c) = [b, c, d]"))134        self.assertTrue(self.find_binding("a", "(c, (d, a), b) = foo()"))135        self.assertTrue(self.find_binding("a", "(a, b) = foo().foo[6][foo]"))136        self.assertFalse(self.find_binding("a", "(foo, b) = (b, a)"))137        self.assertFalse(self.find_binding("a", "(foo, (b, c)) = (a, b, c)"))138    def test_list_assignment(self):139        self.assertTrue(self.find_binding("a", "[a] = b"))140        self.assertTrue(self.find_binding("a", "[a, b, c] = [b, c, d]"))141        self.assertTrue(self.find_binding("a", "[c, [d, a], b] = foo()"))142        self.assertTrue(self.find_binding("a", "[a, b] = foo().foo[a][foo]"))143        self.assertFalse(self.find_binding("a", "[foo, b] = (b, a)"))144        self.assertFalse(self.find_binding("a", "[foo, [b, c]] = (a, b, c)"))145    def test_invalid_assignments(self):146        self.assertFalse(self.find_binding("a", "foo.a = 5"))147        self.assertFalse(self.find_binding("a", "foo[a] = 5"))148        self.assertFalse(self.find_binding("a", "foo(a) = 5"))149        self.assertFalse(self.find_binding("a", "foo(a, b) = 5"))150    def test_simple_import(self):151        self.assertTrue(self.find_binding("a", "import a"))152        self.assertTrue(self.find_binding("a", "import b, c, a, d"))153        self.assertFalse(self.find_binding("a", "import b"))154        self.assertFalse(self.find_binding("a", "import b, c, d"))155    def test_from_import(self):156        self.assertTrue(self.find_binding("a", "from x import a"))157        self.assertTrue(self.find_binding("a", "from a import a"))158        self.assertTrue(self.find_binding("a", "from x import b, c, a, d"))159        self.assertTrue(self.find_binding("a", "from x.b import a"))160        self.assertTrue(self.find_binding("a", "from x.b import b, c, a, d"))161        self.assertFalse(self.find_binding("a", "from a import b"))162        self.assertFalse(self.find_binding("a", "from a.d import b"))163        self.assertFalse(self.find_binding("a", "from d.a import b"))164    def test_import_as(self):165        self.assertTrue(self.find_binding("a", "import b as a"))166        self.assertTrue(self.find_binding("a", "import b as a, c, a as f, d"))167        self.assertFalse(self.find_binding("a", "import a as f"))168        self.assertFalse(self.find_binding("a", "import b, c as f, d as e"))169    def test_from_import_as(self):170        self.assertTrue(self.find_binding("a", "from x import b as a"))171        self.assertTrue(self.find_binding("a", "from x import g as a, d as b"))172        self.assertTrue(self.find_binding("a", "from x.b import t as a"))173        self.assertTrue(self.find_binding("a", "from x.b import g as a, d"))174        self.assertFalse(self.find_binding("a", "from a import b as t"))175        self.assertFalse(self.find_binding("a", "from a.d import b as t"))176        self.assertFalse(self.find_binding("a", "from d.a import b as t"))177    def test_simple_import_with_package(self):178        self.assertTrue(self.find_binding("b", "import b"))179        self.assertTrue(self.find_binding("b", "import b, c, d"))180        self.assertFalse(self.find_binding("b", "import b", "b"))181        self.assertFalse(self.find_binding("b", "import b, c, d", "c"))182    def test_from_import_with_package(self):183        self.assertTrue(self.find_binding("a", "from x import a", "x"))184        self.assertTrue(self.find_binding("a", "from a import a", "a"))185        self.assertTrue(self.find_binding("a", "from x import *", "x"))186        self.assertTrue(self.find_binding("a", "from x import b, c, a, d", "x"))187        self.assertTrue(self.find_binding("a", "from x.b import a", "x.b"))188        self.assertTrue(self.find_binding("a", "from x.b import *", "x.b"))189        self.assertTrue(self.find_binding("a", "from x.b import b, c, a, d", "x.b"))190        self.assertFalse(self.find_binding("a", "from a import b", "a"))191        self.assertFalse(self.find_binding("a", "from a.d import b", "a.d"))192        self.assertFalse(self.find_binding("a", "from d.a import b", "a.d"))193        self.assertFalse(self.find_binding("a", "from x.y import *", "a.b"))194    def test_import_as_with_package(self):195        self.assertFalse(self.find_binding("a", "import b.c as a", "b.c"))196        self.assertFalse(self.find_binding("a", "import a as f", "f"))197        self.assertFalse(self.find_binding("a", "import a as f", "a"))198    def test_from_import_as_with_package(self):199        # Because it would take a lot of special-case code in the fixers200        # to deal with from foo import bar as baz, we'll simply always201        # fail if there is an "from ... import ... as ..."202        self.assertFalse(self.find_binding("a", "from x import b as a", "x"))203        self.assertFalse(self.find_binding("a", "from x import g as a, d as b", "x"))204        self.assertFalse(self.find_binding("a", "from x.b import t as a", "x.b"))205        self.assertFalse(self.find_binding("a", "from x.b import g as a, d", "x.b"))206        self.assertFalse(self.find_binding("a", "from a import b as t", "a"))207        self.assertFalse(self.find_binding("a", "from a import b as t", "b"))208        self.assertFalse(self.find_binding("a", "from a import b as t", "t"))209    def test_function_def(self):210        self.assertTrue(self.find_binding("a", "def a(): pass"))211        self.assertTrue(self.find_binding("a", "def a(b, c, d): pass"))212        self.assertTrue(self.find_binding("a", "def a(): b = 7"))213        self.assertFalse(self.find_binding("a", "def d(b, (c, a), e): pass"))214        self.assertFalse(self.find_binding("a", "def d(a=7): pass"))215        self.assertFalse(self.find_binding("a", "def d(a): pass"))216        self.assertFalse(self.find_binding("a", "def d(): a = 7"))217        s = """218            def d():219                def a():220                    pass"""221        self.assertFalse(self.find_binding("a", s))222    def test_class_def(self):223        self.assertTrue(self.find_binding("a", "class a: pass"))224        self.assertTrue(self.find_binding("a", "class a(): pass"))225        self.assertTrue(self.find_binding("a", "class a(b): pass"))226        self.assertTrue(self.find_binding("a", "class a(b, c=8): pass"))227        self.assertFalse(self.find_binding("a", "class d: pass"))228        self.assertFalse(self.find_binding("a", "class d(a): pass"))229        self.assertFalse(self.find_binding("a", "class d(b, a=7): pass"))230        self.assertFalse(self.find_binding("a", "class d(b, *a): pass"))231        self.assertFalse(self.find_binding("a", "class d(b, **a): pass"))232        self.assertFalse(self.find_binding("a", "class d: a = 7"))233        s = """234            class d():235                class a():236                    pass"""237        self.assertFalse(self.find_binding("a", s))238    def test_for(self):239        self.assertTrue(self.find_binding("a", "for a in r: pass"))240        self.assertTrue(self.find_binding("a", "for a, b in r: pass"))241        self.assertTrue(self.find_binding("a", "for (a, b) in r: pass"))242        self.assertTrue(self.find_binding("a", "for c, (a,) in r: pass"))243        self.assertTrue(self.find_binding("a", "for c, (a, b) in r: pass"))244        self.assertTrue(self.find_binding("a", "for c in r: a = c"))245        self.assertFalse(self.find_binding("a", "for c in a: pass"))246    def test_for_nested(self):247        s = """248            for b in r:249                for a in b:250                    pass"""251        self.assertTrue(self.find_binding("a", s))252        s = """253            for b in r:254                for a, c in b:255                    pass"""256        self.assertTrue(self.find_binding("a", s))257        s = """258            for b in r:259                for (a, c) in b:260                    pass"""261        self.assertTrue(self.find_binding("a", s))262        s = """263            for b in r:264                for (a,) in b:265                    pass"""266        self.assertTrue(self.find_binding("a", s))267        s = """268            for b in r:269                for c, (a, d) in b:270                    pass"""271        self.assertTrue(self.find_binding("a", s))272        s = """273            for b in r:274                for c in b:275                    a = 7"""276        self.assertTrue(self.find_binding("a", s))277        s = """278            for b in r:279                for c in b:280                    d = a"""281        self.assertFalse(self.find_binding("a", s))282        s = """283            for b in r:284                for c in a:285                    d = 7"""286        self.assertFalse(self.find_binding("a", s))287    def test_if(self):288        self.assertTrue(self.find_binding("a", "if b in r: a = c"))289        self.assertFalse(self.find_binding("a", "if a in r: d = e"))290    def test_if_nested(self):291        s = """292            if b in r:293                if c in d:294                    a = c"""295        self.assertTrue(self.find_binding("a", s))296        s = """297            if b in r:298                if c in d:299                    c = a"""300        self.assertFalse(self.find_binding("a", s))301    def test_while(self):302        self.assertTrue(self.find_binding("a", "while b in r: a = c"))303        self.assertFalse(self.find_binding("a", "while a in r: d = e"))304    def test_while_nested(self):305        s = """306            while b in r:307                while c in d:308                    a = c"""309        self.assertTrue(self.find_binding("a", s))310        s = """311            while b in r:312                while c in d:313                    c = a"""314        self.assertFalse(self.find_binding("a", s))315    def test_try_except(self):316        s = """317            try:318                a = 6319            except:320                b = 8"""321        self.assertTrue(self.find_binding("a", s))322        s = """323            try:324                b = 8325            except:326                a = 6"""327        self.assertTrue(self.find_binding("a", s))328        s = """329            try:330                b = 8331            except KeyError:332                pass333            except:334                a = 6"""335        self.assertTrue(self.find_binding("a", s))336        s = """337            try:338                b = 8339            except:340                b = 6"""341        self.assertFalse(self.find_binding("a", s))342    def test_try_except_nested(self):343        s = """344            try:345                try:346                    a = 6347                except:348                    pass349            except:350                b = 8"""351        self.assertTrue(self.find_binding("a", s))352        s = """353            try:354                b = 8355            except:356                try:357                    a = 6358                except:359                    pass"""360        self.assertTrue(self.find_binding("a", s))361        s = """362            try:363                b = 8364            except:365                try:366                    pass367                except:368                    a = 6"""369        self.assertTrue(self.find_binding("a", s))370        s = """371            try:372                try:373                    b = 8374                except KeyError:375                    pass376                except:377                    a = 6378            except:379                pass"""380        self.assertTrue(self.find_binding("a", s))381        s = """382            try:383                pass384            except:385                try:386                    b = 8387                except KeyError:388                    pass389                except:390                    a = 6"""391        self.assertTrue(self.find_binding("a", s))392        s = """393            try:394                b = 8395            except:396                b = 6"""397        self.assertFalse(self.find_binding("a", s))398        s = """399            try:400                try:401                    b = 8402                except:403                    c = d404            except:405                try:406                    b = 6407                except:408                    t = 8409                except:410                    o = y"""411        self.assertFalse(self.find_binding("a", s))412    def test_try_except_finally(self):413        s = """414            try:415                c = 6416            except:417                b = 8418            finally:419                a = 9"""420        self.assertTrue(self.find_binding("a", s))421        s = """422            try:423                b = 8424            finally:425                a = 6"""426        self.assertTrue(self.find_binding("a", s))427        s = """428            try:429                b = 8430            finally:431                b = 6"""432        self.assertFalse(self.find_binding("a", s))433        s = """434            try:435                b = 8436            except:437                b = 9438            finally:439                b = 6"""440        self.assertFalse(self.find_binding("a", s))441    def test_try_except_finally_nested(self):442        s = """443            try:444                c = 6445            except:446                b = 8447            finally:448                try:449                    a = 9450                except:451                    b = 9452                finally:453                    c = 9"""454        self.assertTrue(self.find_binding("a", s))455        s = """456            try:457                b = 8458            finally:459                try:460                    pass461                finally:462                    a = 6"""463        self.assertTrue(self.find_binding("a", s))464        s = """465            try:466                b = 8467            finally:468                try:469                    b = 6470                finally:471                    b = 7"""472        self.assertFalse(self.find_binding("a", s))473class Test_touch_import(support.TestCase):474    def test_after_docstring(self):475        node = parse('"""foo"""\nbar()')476        fixer_util.touch_import(None, "foo", node)477        self.assertEqual(str(node), '"""foo"""\nimport foo\nbar()\n\n')478    def test_after_imports(self):479        node = parse('"""foo"""\nimport bar\nbar()')480        fixer_util.touch_import(None, "foo", node)481        self.assertEqual(str(node), '"""foo"""\nimport bar\nimport foo\nbar()\n\n')482    def test_beginning(self):483        node = parse('bar()')484        fixer_util.touch_import(None, "foo", node)485        self.assertEqual(str(node), 'import foo\nbar()\n\n')486    def test_from_import(self):...mex.py
Source:mex.py  
1#------------------------------------------------------------------------------2#3# Copyright (c) Microsoft Corporation. 4# All rights reserved.5# 6# This code is licensed under the MIT License.7# 8# Permission is hereby granted, free of charge, to any person obtaining a copy9# of this software and associated documentation files(the "Software"), to deal10# in the Software without restriction, including without limitation the rights11# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell12# copies of the Software, and to permit persons to whom the Software is13# furnished to do so, subject to the following conditions :14# 15# The above copyright notice and this permission notice shall be included in16# all copies or substantial portions of the Software.17# 18# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR19# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,20# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE21# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER22# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,23# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN24# THE SOFTWARE.25#26#------------------------------------------------------------------------------2728try:29    from urllib.parse import urlparse30except ImportError:31    from urlparse import urlparse # pylint: disable=import-error3233try:34    from xml.etree import cElementTree as ET35except ImportError:36    from xml.etree import ElementTree as ET3738import requests3940from . import log41from . import util42from . import xmlutil43from .constants import XmlNamespaces, WSTrustVersion44from .adal_error import AdalError4546TRANSPORT_BINDING_XPATH = 'wsp:ExactlyOne/wsp:All/sp:TransportBinding'47TRANSPORT_BINDING_2005_XPATH = 'wsp:ExactlyOne/wsp:All/sp2005:TransportBinding' #pylint: disable=invalid-name4849SOAP_ACTION_XPATH = 'wsdl:operation/soap12:operation'50RST_SOAP_ACTION_13 = 'http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Issue'51RST_SOAP_ACTION_2005 = 'http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue' #pylint: disable=invalid-name52SOAP_TRANSPORT_XPATH = 'soap12:binding'53SOAP_HTTP_TRANSPORT_VALUE = 'http://schemas.xmlsoap.org/soap/http'5455PORT_XPATH = 'wsdl:service/wsdl:port'56ADDRESS_XPATH = 'wsa10:EndpointReference/wsa10:Address'5758def _url_is_secure(endpoint_url):59    parsed = urlparse(endpoint_url)60    return parsed.scheme == 'https'6162class Mex(object):6364    def __init__(self, call_context, url):6566        self._log = log.Logger("MEX", call_context.get('log_context'))67        self._call_context = call_context68        self._url = url69        self._dom = None70        self._parents = None71        self._mex_doc = None72        self.username_password_policy = {}73        self._log.debug("Mex created with url: %s", self._url)7475    def discover(self):76        self._log.debug("Retrieving mex at: %s", self._url)77        options = util.create_request_options(self, {'headers': {'Content-Type': 'application/soap+xml'}})7879        try:80            operation = "Mex Get"81            resp = requests.get(self._url, headers=options['headers'],82                                verify=self._call_context.get('verify_ssl', None))83            util.log_return_correlation_id(self._log, operation, resp)84        except Exception:85            self._log.info("%s request failed", operation)86            raise8788        if not util.is_http_success(resp.status_code):89            return_error_string = u"{} request returned http error: {}".format(operation, resp.status_code)90            error_response = ""91            if resp.text:92                return_error_string = u"{} and server response: {}".format(return_error_string, resp.text)93                try:94                    error_response = resp.json()95                except ValueError:96                    pass97            raise AdalError(return_error_string, error_response)98        else:99            try:100                self._mex_doc = resp.text101                #options = {'errorHandler':self._log.error}102                self._dom = ET.fromstring(self._mex_doc)103                self._parents = {c:p for p in self._dom.iter() for c in p}104                self._parse()105            except Exception:106                self._log.info('Failed to parse mex response in to DOM')107                raise108109    def _check_policy(self, policy_node):110        policy_id = policy_node.attrib["{{{}}}Id".format(XmlNamespaces.namespaces['wsu'])]111        112        # Try with Transport Binding XPath113        transport_binding_nodes = xmlutil.xpath_find(policy_node, TRANSPORT_BINDING_XPATH)114        115        # If unsuccessful, try again with 2005 XPath116        if not transport_binding_nodes:117            transport_binding_nodes = xmlutil.xpath_find(policy_node, TRANSPORT_BINDING_2005_XPATH)118119        # If we did not find any binding, this is potentially bad.120        if not transport_binding_nodes:121            self._log.debug(122                "Potential policy did not match required transport binding: %s", 123                policy_id)124        else:125            self._log.debug("Found matching policy id: %s", policy_id)126127        return policy_id128129    def _select_username_password_polices(self, xpath):130131        policies = {}132        username_token_nodes = xmlutil.xpath_find(self._dom, xpath)133        if not username_token_nodes:134            self._log.warn("No username token policy nodes found.")135            return136137        for node in username_token_nodes:138            policy_node = self._parents[self._parents[self._parents[self._parents[self._parents[self._parents[self._parents[node]]]]]]]139            policy_id = self._check_policy(policy_node)140            if policy_id:141                id_ref = '#' + policy_id142                policies[id_ref] = {id:id_ref}143144        return policies if policies else None145146    def _check_soap_action_and_transport(self, binding_node):147148        soap_action = ""149        soap_transport = ""150        name = binding_node.get('name')151152        soap_transport_attributes = ""153        soap_action_attributes = xmlutil.xpath_find(binding_node, SOAP_ACTION_XPATH)[0].attrib['soapAction']154155        if soap_action_attributes:156            soap_action = soap_action_attributes157            soap_transport_attributes = xmlutil.xpath_find(binding_node, SOAP_TRANSPORT_XPATH)[0].attrib['transport']158159        if soap_transport_attributes:160            soap_transport = soap_transport_attributes161162        if soap_transport == SOAP_HTTP_TRANSPORT_VALUE:163            if soap_action == RST_SOAP_ACTION_13:164                self._log.debug('found binding matching Action and Transport: %s', name)165                return WSTrustVersion.WSTRUST13166            elif soap_action == RST_SOAP_ACTION_2005:167                self._log.debug('found binding matching Action and Transport: %s', name)168                return WSTrustVersion.WSTRUST2005169170        self._log.debug('binding node did not match soap Action or Transport: %s', name)171        return WSTrustVersion.UNDEFINED172173    def _get_matching_bindings(self, policies):174175        bindings = {}176        binding_policy_ref_nodes = xmlutil.xpath_find(self._dom, 'wsdl:binding/wsp:PolicyReference')177178        for node in binding_policy_ref_nodes:179            uri = node.get('URI')180            policy = policies.get(uri)181            if policy:182                binding_node = self._parents[node]183                binding_name = binding_node.get('name')184185                version = self._check_soap_action_and_transport(binding_node)186                if version != WSTrustVersion.UNDEFINED:                  187                    bindings[binding_name] = {188                        'url': uri,189                        'version': version190                        }191192        return bindings if bindings else None193194    def _get_ports_for_policy_bindings(self, bindings, policies):195196        port_nodes = xmlutil.xpath_find(self._dom, PORT_XPATH)197        if not port_nodes:198            self._log.warn("No ports found")199200        for node in port_nodes:201            binding_id = node.get('binding')202            binding_id = binding_id.split(':')[-1]203204            trust_policy = bindings.get(binding_id)205            if trust_policy:206                binding_policy = policies.get(trust_policy.get('url'))207                if binding_policy and not binding_policy.get('url', None):208                    binding_policy['version'] = trust_policy['version']209                    address_node = node.find(ADDRESS_XPATH, XmlNamespaces.namespaces)210                    if address_node is None:211                        raise AdalError("No address nodes on port")212213                    address = xmlutil.find_element_text(address_node)214                    if _url_is_secure(address):215                        binding_policy['url'] = address216                    else:217                        self._log.warn("Skipping insecure endpoint: %s", 218                                       address)219220    def _select_single_matching_policy(self, policies):221222        matching_policies = [p for p in policies.values() if p.get('url')]223        if not matching_policies:224            self._log.warn("No policies found with a url.")225            return226227        wstrust13_policy = None228        wstrust2005_policy = None229        for policy in matching_policies:230            version = policy.get('version', None)231            if  version == WSTrustVersion.WSTRUST13:232                wstrust13_policy = policy233            elif version == WSTrustVersion.WSTRUST2005:234                wstrust2005_policy = policy235236        if wstrust13_policy is None and wstrust2005_policy is None:237            self._log.warn('No policies found for either wstrust13 or wstrust2005')238239        self.username_password_policy = wstrust13_policy or wstrust2005_policy240241    def _parse(self):242        policies = self._select_username_password_polices(243            'wsp:Policy/wsp:ExactlyOne/wsp:All/sp:SignedEncryptedSupportingTokens/wsp:Policy/sp:UsernameToken/wsp:Policy/sp:WssUsernameToken10')244245        xpath2005 = 'wsp:Policy/wsp:ExactlyOne/wsp:All/sp2005:SignedSupportingTokens/wsp:Policy/sp2005:UsernameToken/wsp:Policy/sp2005:WssUsernameToken10'       246        if policies:247            policies2005 = self._select_username_password_polices(xpath2005)248            if policies2005:249                policies.update(policies2005)250        else:251            policies = self._select_username_password_polices(xpath2005)252253        if not policies:254            raise AdalError("No matching policies.")255            256257        bindings = self._get_matching_bindings(policies)258        if not bindings:259            raise AdalError("No matching bindings.")260261        self._get_ports_for_policy_bindings(bindings, policies)262        self._select_single_matching_policy(policies)263264        if not self._url:
...gl.gyp
Source:gl.gyp  
1# Copyright (c) 2012 The Chromium Authors. All rights reserved.2# Use of this source code is governed by a BSD-style license that can be3# found in the LICENSE file.4{5  'variables': {6    'chromium_code': 1,7  },8  'targets': [9    {10      'target_name': 'gl',11      'type': '<(component)',12      'product_name': 'gl_wrapper',  # Avoid colliding with OS X's libGL.dylib13      'dependencies': [14        '<(DEPTH)/base/base.gyp:base',15        '<(DEPTH)/base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',16        '<(DEPTH)/gpu/command_buffer/command_buffer.gyp:gles2_utils',17        '<(DEPTH)/skia/skia.gyp:skia',18        '<(DEPTH)/ui/ui.gyp:ui',19      ],20      'variables': {21        'gl_binding_output_dir': '<(SHARED_INTERMEDIATE_DIR)/ui/gfx/gl',22      },23      'defines': [24        'GL_IMPLEMENTATION',25      ],26      'include_dirs': [27        '<(DEPTH)/third_party/swiftshader/include',28        '<(DEPTH)/third_party/mesa/MesaLib/include',29        '<(gl_binding_output_dir)',30      ],31      'direct_dependent_settings': {32        'include_dirs': [33          '<(DEPTH)/third_party/mesa/MesaLib/include',34          '<(gl_binding_output_dir)',35        ],36      },37     'sources': [38        'gl_bindings.h',39        'gl_bindings_skia_in_process.cc',40        'gl_bindings_skia_in_process.h',41        'gl_context.cc',42        'gl_context.h',43        'gl_context_android.cc',44        'gl_context_linux.cc',45        'gl_context_mac.mm',46        'gl_context_osmesa.cc',47        'gl_context_osmesa.h',48        'gl_context_stub.cc',49        'gl_context_stub.h',50        'gl_context_win.cc',51        'gl_export.h',52        'gl_fence.cc',53        'gl_fence.h',54        'gl_implementation.cc',55        'gl_implementation.h',56        'gl_implementation_android.cc',57        'gl_implementation_linux.cc',58        'gl_implementation_mac.cc',59        'gl_implementation_win.cc',60        'gl_interface.cc',61        'gl_interface.h',62        'gl_share_group.cc',63        'gl_share_group.h',64        'gl_surface.cc',65        'gl_surface.h',66        'gl_surface_android.cc',67        'gl_surface_android.h',68        'gl_surface_linux.cc',69        'gl_surface_mac.cc',70        'gl_surface_stub.cc',71        'gl_surface_stub.h',72        'gl_surface_win.cc',73        'gl_surface_osmesa.cc',74        'gl_surface_osmesa.h',75        'gl_switches.cc',76        'gl_switches.h',77        'native_window_interface_android.h',78        'scoped_make_current.cc',79        'scoped_make_current.h',80        '<(gl_binding_output_dir)/gl_bindings_autogen_gl.cc',81        '<(gl_binding_output_dir)/gl_bindings_autogen_gl.h',82        '<(gl_binding_output_dir)/gl_bindings_autogen_mock.cc',83        '<(gl_binding_output_dir)/gl_bindings_autogen_osmesa.cc',84        '<(gl_binding_output_dir)/gl_bindings_autogen_osmesa.h',85      ],86      # hard_dependency is necessary for this target because it has actions87      # that generate header files included by dependent targets. The header88      # files must be generated before the dependents are compiled. The usual89      # semantics are to allow the two targets to build concurrently.90      'hard_dependency': 1,91      'actions': [92        {93          'action_name': 'generate_gl_bindings',94          'inputs': [95            'generate_bindings.py',96            '<(DEPTH)/third_party/khronos/GLES2/gl2ext.h',97            '<(DEPTH)/third_party/khronos/EGL/eglext.h',98            '<(DEPTH)/third_party/mesa/MesaLib/include/GL/glext.h',99            '<(DEPTH)/third_party/mesa/MesaLib/include/GL/glxext.h',100            '<(DEPTH)/third_party/mesa/MesaLib/include/GL/wglext.h',101          ],102          'outputs': [103            '<(gl_binding_output_dir)/gl_bindings_autogen_egl.cc',104            '<(gl_binding_output_dir)/gl_bindings_autogen_egl.h',105            '<(gl_binding_output_dir)/gl_bindings_autogen_gl.cc',106            '<(gl_binding_output_dir)/gl_bindings_autogen_gl.h',107            '<(gl_binding_output_dir)/gl_bindings_autogen_glx.cc',108            '<(gl_binding_output_dir)/gl_bindings_autogen_glx.h',109            '<(gl_binding_output_dir)/gl_bindings_autogen_mock.cc',110            '<(gl_binding_output_dir)/gl_bindings_autogen_osmesa.cc',111            '<(gl_binding_output_dir)/gl_bindings_autogen_osmesa.h',112            '<(gl_binding_output_dir)/gl_bindings_autogen_wgl.cc',113            '<(gl_binding_output_dir)/gl_bindings_autogen_wgl.h',114          ],115          'action': [116            'python',117            'generate_bindings.py',118            '<(gl_binding_output_dir)',119          ],120        },121      ],122      'conditions': [123        ['OS != "mac"', {124          'sources': [125            'egl_util.cc',126            'egl_util.h',127            'gl_context_egl.cc',128            'gl_context_egl.h',129            'gl_surface_egl.cc',130            'gl_surface_egl.h',131            '<(gl_binding_output_dir)/gl_bindings_autogen_egl.cc',132            '<(gl_binding_output_dir)/gl_bindings_autogen_egl.h',133          ],134          'include_dirs': [135            '<(DEPTH)/third_party/angle/include',136          ],137        }],138        ['use_x11 == 1 and use_wayland != 1', {139          'sources': [140            'gl_context_glx.cc',141            'gl_context_glx.h',142            'gl_surface_glx.cc',143            'gl_surface_glx.h',144            '<(gl_binding_output_dir)/gl_bindings_autogen_glx.cc',145            '<(gl_binding_output_dir)/gl_bindings_autogen_glx.h',146          ],147          'all_dependent_settings': {148            'defines': [149              'GL_GLEXT_PROTOTYPES',150            ],151          },152        }],153        ['OS=="win"', {154          'sources': [155            'gl_context_wgl.cc',156            'gl_context_wgl.h',157            'gl_surface_wgl.cc',158            'gl_surface_wgl.h',159            '<(gl_binding_output_dir)/gl_bindings_autogen_wgl.cc',160            '<(gl_binding_output_dir)/gl_bindings_autogen_wgl.h',161          ],162        }],163        ['OS=="mac"', {164          'sources': [165            'gl_context_cgl.cc',166            'gl_context_cgl.h',167            'gl_surface_cgl.cc',168            'gl_surface_cgl.h',169          ],170          'link_settings': {171            'libraries': [172              '$(SDKROOT)/System/Library/Frameworks/OpenGL.framework',173            ],174          },175        }],176        ['OS=="mac" and use_aura == 1', {177          'sources': [178            'gl_context_nsview.mm',179            'gl_context_nsview.h',180            'gl_surface_nsview.mm',181            'gl_surface_nsview.h',182          ],183        }],184        ['OS=="android"', {185          'sources!': [            186            '<(gl_binding_output_dir)/gl_bindings_autogen_osmesa.cc',187            '<(gl_binding_output_dir)/gl_bindings_autogen_osmesa.h',188            'system_monitor_posix.cc',189          ],190          'defines': [191            'GL_GLEXT_PROTOTYPES',192            'EGL_EGLEXT_PROTOTYPES',193          ],194        }],195      ],196    },197  ],...LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!
