我正在尝试测试 axios 请求,并且需要使用身份验证令牌才能访问端点,但是我的测试失败,因为我收到“Bearer null”并将其输入到我的 headers.Authorization 中。下面是我的实际代码
我正在测试的文件:
this.$axios.get(url, { headers: { Authorization: `Bearer ${localStorage.getItem("access-token")}` } })
.then((response) => {
this.loading = true;
// Get latest barcode created and default it to our "from" input
this.barcodeFrom = response.data.data[response.data.data.length - 1]['i_end_uid'] + 1;
this.barcodeTo = this.barcodeFrom + 1;
this.barcodeRanges = response.data.data;
// Here we add to the data array to make printed barcodes more obvious for the user
this.barcodeRanges.map(item => item['range'] = `${item['i_start_uid']} - ${item['i_end_uid']}`);
// Make newest barcodes appear at the …Run Code Online (Sandbox Code Playgroud) 我正在尝试将我的 GitHub 操作的 IP 地址列入白名单,因为目前工作流程因我的 Azure Web 应用程序的防火墙阻止来自非白名单 IP 地址的请求而失败。看来Github提供的这个API中有一个CIDR格式的IP地址列表: https: //api.github.com/meta
但是,我是 Azure 新手,不知道如何通过 Azure UI 中的 API 将如此大量的 IP 地址列入白名单。当我转到 Azure 应用程序的“网络”页面,转到“访问限制”并单击“配置访问限制”时,有一个非常好的 GUI 可以将单个 IP 地址列入白名单,但似乎没有办法要访问 API,我想知道是否有人知道我应该如何尝试从上面链接的 GitHub API 页面访问“操作”:[IP1、IP2 等],并将该 IP 数组纳入我的访问限制配置,理想情况下这应该是动态的,因为显然 Github 有时会更新此页面......
任何建议表示赞赏!提前致谢。
我正在尝试对我的 Nuxt/Vue 组件方法进行测试,以检查是否存在错误。
所以我所做的就是为这个感兴趣的方法创建一个“间谍” const spyGetNumberOfResults = jest.spyOn(SearchTable.methods, 'getNumberOfResults'),然后我期待它expect(spyGetNumberOfResults).not.toThrowError(),但是我收到一个奇怪的错误,它说我感兴趣的方法中的一个变量是未定义的。这是错误:
TypeError: Cannot set property 'countLoading' of undefined
571 | async getNumberOfResults () {
572 | // Kick off loader to signal retrieving counts
> 573 | this.countLoading = true;
| ^
574 |
575 | // Initialize count
576 | this.count = '';
at getNumberOfResults (components/core/SearchTable.vue:573:1)
at Object.<anonymous> (node_modules/expect/build/toThrowMatchers.js:81:11)
at Object.toThrowError (node_modules/expect/build/index.js:342:33)
at Object.<anonymous> (test/SearchTable.spec.js:150:57)
Run Code Online (Sandbox Code Playgroud)
这是我的测试代码:
test(`GET /${MODEL[1][MAIN_MODULES[i]].subModules[j].backEndFilters.mainModule}/${MODEL[1][MAIN_MODULES[i]].subModules[j].backEndFilters.subModule}/`, async () => {
const API_ENDPOINT = process.env.NODE_ENV;
// Initialize …Run Code Online (Sandbox Code Playgroud)