-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support authorization #259
Conversation
6642eaa
to
fdccd89
Compare
能否 rebase 一下 master 分支?然后补充一下单元测试? |
好古老的 pr...因为当时合并到 bnpm 去了,这里就没管了...有需求的话我来弄下 |
Codecov Report
@@ Coverage Diff @@
## master #259 +/- ##
==========================================
+ Coverage 90.04% 90.06% +0.01%
==========================================
Files 27 28 +1
Lines 1849 1882 +33
Branches 310 321 +11
==========================================
+ Hits 1665 1695 +30
- Misses 184 187 +3
Continue to review full report at Codecov.
|
99fd9d1
to
d5a987f
Compare
4884159
to
d0bd1f2
Compare
@hyj1991 readme 增加一下使用方式。 |
@@ -0,0 +1,3 @@ | |||
registry=https://registry-mock.org/ | |||
//registry-mock.org/:always-auth=true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
没有 :username
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mock 数据少写了个 username,其实这里只要看下 auth 的时候 header 里面有没有 basic auth 信息就行了,我补充下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已经在 mock 数据中补充了 username 信息
|
||
} | ||
|
||
createConfigs(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createConfigs 做成 lazy load,在第一次 get 的时候才调用。然后单元测试里面就容易 mock 了。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里要测试下 .cnpmrc 的实际解析,感觉 mock 掉 process.env.Home 指向预设的内容,再调用下 get 方法看下 basic auth 有没有设置到 header 里面去比较好
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里会导致不需要这个功能的用户强制生成了 .cnpmrc 文件。
使用方式其实就是 cnpm login 后,这个 pr 会给 cnpm install 操作会带上用户账号信息,这样 cnpm server 上如果开启了 alwaysAuth 配置,那么未登录的账号就无法再安装模块了 |
This change is![Reviewable](https://camo.githubusercontent.com/23b05f5fb48215c989e92cc44cf6512512d083132bd3daf689867c8d9d386888/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)