Giter Site home page Giter Site logo

meituan-dianping / lyrebird Goto Github PK

View Code? Open in Web Editor NEW
1.1K 40.0 244.0 87.52 MB

移动应用插件化测试工作台

Home Page: https://meituan-dianping.github.io/lyrebird/

License: MIT License

HTML 0.14% Python 63.60% Shell 0.12% JavaScript 8.32% Vue 27.59% Dockerfile 0.23% Sass 0.01%
mock proxy python lyrebird testing-tools mobile-testing android-testing ios-testing

lyrebird's Introduction

Lyrebird

Tests Publish CodeQL

PyPI PyPI PyPI - Downloads

pip install lyrebird

Docker Image Version (latest semver) Docker Image Size (latest by date)

docker pull overbridge/lyrebird

Doc Backers on Open Collective Sponsors on Open Collective GitHub


简介

Lyrebird 是一个基于拦截以及模拟 HTTP/HTTPS 网络请求的面向移动应用的插件式测试平台。

Lyrebird 不只提供 UI 操作,也可以通过 API 控制所有功能。

Lyrebird 也可作为服务端接口测试 mock 工具使用。

Lyrebird 可以通过插件扩展能力,实现埋点自动测试、API 覆盖率统计、移动设备及 App 控制和信息记录、自定义检查脚本等一系列功能。

Lyrebird (琴鸟) 不但美丽壮观,且能歌善舞。它不但能模仿各种鸟类的鸣叫声,还能学人间的各种声音。如汽车喇叭声、火车喷气声、斧头伐木声、修路碎石机声及领号人的喊叫声等。歌声婉转动听,舞姿轻盈合拍,是澳洲鸟类中最受人喜爱的珍禽之一。


快速开始

环境要求

  • macOS/Windows
  • Python >= 3.7
# macOS系统中推荐使用Homebrew(https://brew.sh/#install)安装Python3
brew install python3

Windows 需要的额外步骤:

  • 下载并安装编译版 OpenSSL
  • 设置系统环境变量(根据实际路径调整)
    • LIB = C:\Program Files\OpenSSL-Win64\lib
    • INCLUDE = C:\Program Files\OpenSSL-Win64\include

安装

# 安装lyrebird
pip3 install lyrebird

启动

lyrebird

连接移动设备

  • 启动 Lyrebird 后,移动设备需要通过代理的方式将请求数据接入。

  • 将移动设备的代理地址设为当前电脑地址,默认端口为 4272(IP 地址可查看 Lyrebird 启动时输出的日志)

    (注意 ⚠️:4272 端口上使用的 mitmproxy 服务为外置依赖,需要用户自行安装 mitmproxy。如果没有安装 lyrebird 会尝试自动安装该应用)

  • 被测设备上用浏览器打开 http://mitm.it, 选择对应操作系统安装证书

Lyrebird 接入有两种方式:

a. 设置代理

b. 直连

查看及录制数据

现在,可以开始操作移动设备了。Lyrebird 将显示捕获到的 HTTP/HTTPS 请求。

选中请求后,可以将它保存到已激活的 mock 数据组中。

使用 Mock 数据

激活 mock 数据选择器,选择 mock 数据后。经过 Lyrebird 的请求会被 mock,如果 mock 数据中没有匹配的数据,则会代理该请求。

可以在 DataManager 界面管理 mock 数据。

Mock 数据管理

mock 数据可由左边导航栏切换到 DataManager 界面进行编辑管理


插件

文档在建中


基本命令

  • lyrebird

    以缺省参数启动 lyrebird

  • lyrebird -v

    以输出详细日志模式启动 lyrebird

  • lyrebird -b

    启动 lyrebird 不默认打开浏览器

  • lyrebird --mock 9090 --proxy 4272 --data . --config your/config/file

    指定参数启动 lyrebird

    参数:

      --mock 默认9090 , mock服务及前端端口
    
      --proxy 默认4272, 代理服务端口
    
      --data 默认./data, mock数据根目录
    
      --config 默认~/.lyrebird/conf.json, lyrebird启动配置
    

感谢

本工具中的代理功能使用mitmproxy实现。

Contributors

lyrebird's People

Contributors

addisongao avatar chenchaoyi avatar codefly67 avatar dependabot[bot] avatar dodosophia avatar duxiao1997 avatar duyanguang avatar echoyang7 avatar happylemon233 avatar huihuilong avatar kevinsj avatar liu2333333 avatar liyilun2019 avatar monkeywithacupcake avatar noo0ooo0ob avatar npmmirror avatar rena-yuan avatar springrx avatar xulz avatar youngfreefjs avatar yumiguan avatar yury-awesome avatar zhaoyangyang0403 avatar zhaoye avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lyrebird's Issues

操作通知时出错

version: 1.4.0
steps:

  1. 点击一条通知的删除按钮,此时通知消失
  2. 刷新页面后,已删除的通知出现
  3. 再次删除该条通知,报错

如何二次代理

你好,假如 app的api是需要翻墙访问的, 我将MAC机 安装了lyrebird , 然后MAC机使用SS 全局翻墙, app api 无法正常访问,请问lyrebird如何配置二次代理.

request url 正则表达式修改后不生效

Describe the bug
修改接口正则匹配规则,再次发起请求,没有生效

To Reproduce
Steps to reproduce the behavior:

  1. 进入 Data Manager
  2. 修改 request url
  3. 再次触发接口

Expected behavior
匹配规则生效

小米手机设置代理和访问mitm.it 无法下载pem.crt

hello 我根据help 已经部署启动了lyrebird
我本机是ubuntu18.04 用的公司无线wifi dhcp获得IP 手机是连接的公司同一wifi

mitmproxy start on ×××.×××.×××.×××:4272 请在被测设备上设置代理服务器地址

设置小米手机代理
https://jingyan.baidu.com/article/1974b2895cb780f4b1f774b5.html

被测设备上用浏览器打开 http://mitm.it ​ 选择Android 提示下载pem.crt

从手机的 下载管理 里 看 是下载失败的

这是下载管理中 点击重新下载后的 日志

DEBUG - [connectionpool] - Starting new HTTP connection (1): api.tw06.xlmc.sec.miui.com:80 DEBUG - [connectionpool] - http://api.tw06.xlmc.sec.miui.com:80 "POST /api/configure/get HTTP/1.1" 200 None INFO - [mock_server] - 200 proxy POST http://api.tw06.xlmc.sec.miui.com/api/configure/get INFO - [mock_server] - 200 GET http://localhost:9090/api/flow INFO - [proxy_flow] - https://stats.jpush.cn/v2/report INFO - [proxy_flow] - Redirect-> http://localhost:9090/mock/https://stats.jpush.cn/v2/report DEBUG - [connectionpool] - Starting new HTTPS connection (1): stats.jpush.cn:443 DEBUG - [connectionpool] - https://stats.jpush.cn:443 "POST /v2/report HTTP/1.1" 200 None INFO - [mock_server] - 200 proxy POST https://stats.jpush.cn/v2/report INFO - [mock_server] - 200 GET http://localhost:9090/api/flow INFO - [proxy_flow] - https://stats.jpush.cn/v2/report INFO - [proxy_flow] - Redirect-> http://localhost:9090/mock/https://stats.jpush.cn/v2/report DEBUG - [connectionpool] - Starting new HTTPS connection (1): stats.jpush.cn:443 DEBUG - [connectionpool] - https://stats.jpush.cn:443 "POST /v2/report HTTP/1.1" 200 None INFO - [mock_server] - 200 proxy POST https://stats.jpush.cn/v2/report INFO - [mock_server] - 200 GET http://localhost:9090/api/flow

新建 Mock 数据组后并激活,Mock 失败

Describe the bug
新建一组 Mock 数据并保存,激活对应数据组,该数据组包含的接口 Mock 失败,状态为 Proxy

To Reproduce
Steps to reproduce the behavior:

  1. 勾选一个接口,点击保存新建数据组,填写组名,创建
  2. 在 DataManager 中编辑 Mock 数据
  3. 返回 Inspector 激活对应数据组
  4. 重新触发接口

Expected behavior
接口成功被 Mock 返回

Screenshots

Desktop (please complete the following information):

  • OS: macOS
  • Browser Chrome
  • Version 1.6.0

Smartphone (please complete the following information):

  • Device: N/A
  • OS: N/A
  • Browser N/A
  • Version N/A

Additional context

插件接入机制更新

  • 增加新版接入点
  • 接入插件配置:支持自定义API,自定义UI入口,自定义后台程序

Finish in #128

lyrebrid 日志中报错

Describe the bug
启动lyrebird后,正常使用APP,lyrebird后台报错

To Reproduce
Steps to reproduce the behavior:
1.启动lyrebird
2.操作手机连接上代理
3.正常操作APP
4.实际结果:lyrebird后台报错

Screenshots
If applicable, add screenshots to help explain your problem.
image

Additional context
lyrebrid version 1.6.3

增加DB记录功能开关

增加命令行和配置开关,支持设置是否记录事件到DB。默认值是True(记录)。

有些APP使用 lyrebird 接口会加载超时

Describe the bug
IOS 上打开“泰然金融”APP,无法展示“转让专区”的数据(接口访问失败)。

To Reproduce

  1. Go to “出借”页面(底部按钮:出借)
  2. Click on “转让专区”
  3. 转让数据接口加载超时,提示加载失败
  4. 使用美团外卖、微贷网等APP正常。

Expected behavior
转让专区的转让数据可以正常展示。

Screenshots

APP 报错截图:
image

Lyrebird 控制台报错信息:

[2019-03-27 11:27:29,818] ERROR in app: Exception on /mock/http://::ffff:180.163.26.112/mmcrhead/oY4BHYs3iav1iaF215sYzJE7JickqzLY5G5ync5lLTJqiaZH9ZQfoO9az7pEphvoY9mdvz3ChbdsBOJLfuvmN93BAvVyJLEC31E3/0 [GET]
Traceback (most recent call last):
  File "d:\program\python37-32\lib\site-packages\flask\app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "d:\program\python37-32\lib\site-packages\flask\app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "d:\program\python37-32\lib\site-packages\flask_restful\__init__.py", line 269, in error_router
    return original_handler(e)
  File "d:\program\python37-32\lib\site-packages\flask\app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "d:\program\python37-32\lib\site-packages\flask\_compat.py", line 35, in reraise
    raise value
  File "d:\program\python37-32\lib\site-packages\flask\app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "d:\program\python37-32\lib\site-packages\flask\app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "d:\program\python37-32\lib\site-packages\lyrebird\mock\blueprints\api_mock.py", line 25, in index
    req_context = HandlerContext(request, path)
  File "d:\program\python37-32\lib\site-packages\lyrebird\mock\handlers\handler_context.py", line 40, in __init__
    self._parse_request()
  File "d:\program\python37-32\lib\site-packages\lyrebird\mock\handlers\handler_context.py", line 47, in _parse_request
    request_info = self._read_origin_request_info_from_url()
  File "d:\program\python37-32\lib\site-packages\lyrebird\mock\handlers\handler_context.py", line 84, in _read_origin_request_info_from_url
    port=parsed_path.port if parsed_path.port else '80',
  File "d:\program\python37-32\lib\urllib\parse.py", line 169, in port
    port = int(port, 10)
ValueError: invalid literal for int() with base 10: ':ffff:180.163.26.112'

Smartphone:

  • Device: iPhone6
  • OS: iOS12.1.4
  • App: 泰然金融
  • Version: V6.6.4

lyrebird
IP 10.200.4.26
MOCK.PORT 9090
PROXY.PORT 4272
VERSION 1.6.0

Additional context
其他APP,如:LinkedIn、铜板街、唯品会 也会加载超时。

LinkedIn:
image

铜板街:
image

唯品会:
image

录制mock数据时,新建数据组第一次保存不成功

Describe the bug
录制mock数据时,新建数据组第一次保存不成功

To Reproduce
Steps to reproduce the behavior:

  1. 选择要录制的数据(未选择数据组)
  2. 点击保存按钮
  3. 填写新建数据组名称
  4. 点击完成按钮
  5. 数据没有被正确保存

Expected behavior
数据保存于新建数据组中

Desktop (please complete the following information):

  • OS: macOS
  • Browser chrome
  • Version v1.6.0

使用lyrebird代理访问https://m.trc.com,显示空白页

iOS手机上访问网址 https://m.trc.com ,期望能正常打开,实际显示空白页。

已尝试的方案:
1、桌面版mitmproxy(exe安装包)可以正常访问 该网站
2、mitmdump -s addons.py命令启动自己编写addons.py , 也可以正常访问 该网址
3、windows 和 mac 都出现如上同样问题

调试现象:
访问该地址,请求没有进入 api_mock.py接口内。

有没有详细一些的使用文档?

看了开发者大会上的文档,感觉高大上的一个工具!但是,不会用。自己研究了一下,还是不会用!
所以还请描述一下如何使用.Thanks!

Record提示可以优化下

页面左上角点红色和黑色录制按钮鼠标放上去都是Record提示,看是否可以优化下,在不同情况下显示不同都提示

KeyError: 'Session is disconnected'

Describe the bug
Traceback (most recent call last):
File "/Users/yurree/.lyrebird/tools/venv/lib/python3.7/site-packages/werkzeug/serving.py", line 302, in run_wsgi
execute(self.server.app)
File "/Users/yurree/.lyrebird/tools/venv/lib/python3.7/site-packages/werkzeug/serving.py", line 290, in execute
application_iter = app(environ, start_response)
File "/Users/yurree/.lyrebird/tools/venv/lib/python3.7/site-packages/flask/app.py", line 2309, in call
return self.wsgi_app(environ, start_response)
File "/Users/yurree/.lyrebird/tools/venv/lib/python3.7/site-packages/flask_socketio/init.py", line 44, in call
start_response)
File "/Users/yurree/.lyrebird/tools/venv/lib/python3.7/site-packages/engineio/middleware.py", line 59, in call
return self.engineio_app.handle_request(environ, start_response)
File "/Users/yurree/.lyrebird/tools/venv/lib/python3.7/site-packages/socketio/server.py", line 428, in handle_request
return self.eio.handle_request(environ, start_response)
File "/Users/yurree/.lyrebird/tools/venv/lib/python3.7/site-packages/engineio/server.py", line 337, in handle_request
socket = self._get_socket(sid)
File "/Users/yurree/.lyrebird/tools/venv/lib/python3.7/site-packages/engineio/server.py", line 521, in _get_socket
raise KeyError('Session is disconnected')
KeyError: 'Session is disconnected'

To Reproduce
Steps to reproduce the behavior:

  1. 控制台输入的日志显示如上错误

lyrebird后台报错

Describe the bug
启动lyrebird后,正常使用APP,lyrebird后台报错
To Reproduce
Steps to reproduce the behavior:

  1. 启动lyrebird
  2. 操作手机连接上代理
  3. 正常操作APP
  4. 实际结果:lyrebird后台报错

Screenshots
If applicable, add screenshots to help explain your problem.
image

Desktop (please complete the following information):

  • Version 1.5.0

Windows 安装报错

Traceback (most recent call last):
  File "c:\programdata\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\programdata\anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\ProgramData\Anaconda3\Scripts\lyrebird.exe\__main__.py", line 9, in <module>
  File "c:\programdata\anaconda3\lib\site-packages\lyrebird\manager.py", line 219, in run
    fire.Fire(CommandLine, 'v start')
  File "c:\programdata\anaconda3\lib\site-packages\fire\core.py", line 127, in Fire
    component_trace = _Fire(component, args, context, name)
  File "c:\programdata\anaconda3\lib\site-packages\fire\core.py", line 366, in _Fire
    component, remaining_args)
  File "c:\programdata\anaconda3\lib\site-packages\fire\core.py", line 542, in _CallCallable
    result = fn(*varargs, **kwargs)
  File "c:\programdata\anaconda3\lib\site-packages\lyrebird\manager.py", line 159, in __init__
    self.server = Server()
  File "c:\programdata\anaconda3\lib\site-packages\lyrebird\manager.py", line 48, in __init__
    init_logger_settings()
  File "c:\programdata\anaconda3\lib\site-packages\lyrebird\mock\logger_helper.py", line 42, in init_logger_settings
    disable_existing_loggers=False)
  File "c:\programdata\anaconda3\lib\logging\config.py", line 84, in fileConfig
    handlers = _install_handlers(cp, formatters)
  File "c:\programdata\anaconda3\lib\logging\config.py", line 147, in _install_handlers
    args = eval(args, vars(logging))
  File "<string>", line 1
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

看起来像是没有对windows目录进行转义

数据切换时,不要默认回到request页面,仍保留在当前tab

Is your feature request related to a problem? Please describe.
数据管理界面切换到新一条数据时。详情展示页tab跳回到request。

Describe the solution you'd like
希望tab页维持现在位置。有助于连续的数据操作。

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

支持Checker页面级白名单

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

lyrebird可以用来测试埋点么?

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

mitmproxy 也是支持win或mac下代理的么?

我是想,这个mitmproxy 可以支持部署到window10 或mac 系统硬件下的么(不是手机ios android wp这种系统设备下)?

部署后,可以支持代理捕获 windows或mac下 客户端程序的请求么?

如果 支持 该怎么配置  配置后lyrebird界面是否可以正常操作

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.