mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	This commit asserts that parse_user_agent never returns None. The RegEx will match any string, so that `match` is never None. This brings test coverage of lib/user_agent.py to 100%. Changes were also made in test/test_decorators.py and views/compatibility.py to reflect that parse_user_agent cannot return None. Improves: #7089. Fixes: #8779.
		
			
				
	
	
		
			13 lines
		
	
	
		
			460 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			13 lines
		
	
	
		
			460 B
		
	
	
	
		
			Python
		
	
	
	
	
	
 | 
						|
from django.http import HttpResponse, HttpRequest
 | 
						|
from typing import Any, List, Dict, Optional, Text
 | 
						|
 | 
						|
from zerver.lib.response import json_error, json_success
 | 
						|
from zerver.lib.user_agent import parse_user_agent
 | 
						|
 | 
						|
def check_compatibility(request: HttpRequest) -> HttpResponse:
 | 
						|
    user_agent = parse_user_agent(request.META["HTTP_USER_AGENT"])
 | 
						|
    if user_agent['name'] == "ZulipInvalid":
 | 
						|
        return json_error("Client is too old")
 | 
						|
    return json_success()
 |