@@ -9,16 +9,12 @@ import {
9
9
} from "../../../src/io/common-errors" ;
10
10
import {
11
11
getAllRegistryPackumentsUsing ,
12
- getAuthTokenUsing ,
13
12
getRegistryPackumentUsing ,
14
13
searchRegistryUsing ,
15
14
} from "../../../src/io/registry" ;
16
15
import { buildPackument } from "../../common/data-packument" ;
17
- import { someRegistry , someRegistryUrl } from "../../common/data-registry" ;
18
- import {
19
- mockRegClientAddUserResult ,
20
- mockRegClientGetResult ,
21
- } from "./registry-client.mock" ;
16
+ import { someRegistry } from "../../common/data-registry" ;
17
+ import { mockRegClientGetResult } from "./registry-client.mock" ;
22
18
23
19
jest . mock ( "npm-registry-fetch" ) ;
24
20
jest . mock ( "libnpmsearch" ) ;
@@ -71,92 +67,6 @@ describe("registry io", () => {
71
67
} ) ;
72
68
} ) ;
73
69
74
- describe ( "authenticate user with npm registry" , ( ) => {
75
- function makeDependencies ( ) {
76
- const registryClient : jest . Mocked < RegClient . Instance > = {
77
- adduser : jest . fn ( ) ,
78
- get : jest . fn ( ) ,
79
- } ;
80
-
81
- const authenticateUserWithNpmRegistry = getAuthTokenUsing (
82
- registryClient ,
83
- noopLogger
84
- ) ;
85
- return { authenticateUserWithNpmRegistry, registryClient } as const ;
86
- }
87
- it ( "should give token for valid user" , async ( ) => {
88
- const expected = "some token" ;
89
- const { authenticateUserWithNpmRegistry, registryClient } =
90
- makeDependencies ( ) ;
91
- mockRegClientAddUserResult (
92
- registryClient ,
93
- null ,
94
- {
95
- ok : true ,
96
- token : expected ,
97
- } ,
98
- null
99
- ) ;
100
-
101
- const actual = await authenticateUserWithNpmRegistry (
102
- someRegistryUrl ,
103
- "valid-user" ,
104
-
105
- "valid-password"
106
- ) ;
107
-
108
- expect ( actual ) . toEqual ( expected ) ;
109
- } ) ;
110
-
111
- it ( "should fail for not-ok response" , async ( ) => {
112
- const { authenticateUserWithNpmRegistry, registryClient } =
113
- makeDependencies ( ) ;
114
- mockRegClientAddUserResult (
115
- registryClient ,
116
- null ,
117
- {
118
- ok : false ,
119
- } ,
120
- {
121
- statusMessage : "bad user" ,
122
- statusCode : 401 ,
123
- }
124
- ) ;
125
-
126
- await expect (
127
- authenticateUserWithNpmRegistry (
128
- someRegistryUrl ,
129
- "bad-user" ,
130
-
131
- "bad-password"
132
- )
133
- ) . rejects . toBeInstanceOf ( RegistryAuthenticationError ) ;
134
- } ) ;
135
-
136
- it ( "should fail for error response" , async ( ) => {
137
- const { authenticateUserWithNpmRegistry, registryClient } =
138
- makeDependencies ( ) ;
139
- mockRegClientAddUserResult (
140
- registryClient ,
141
- new Error ( ) ,
142
- { ok : false } ,
143
- {
144
- statusMessage : "bad user" ,
145
- statusCode : 401 ,
146
- }
147
- ) ;
148
-
149
- await expect (
150
- authenticateUserWithNpmRegistry (
151
- someRegistryUrl ,
152
- "bad-user" ,
153
-
154
- "bad-password"
155
- )
156
- ) . rejects . toBeInstanceOf ( Error ) ;
157
- } ) ;
158
- } ) ;
159
-
160
70
describe ( "npm api search" , ( ) => {
161
71
function makeDependencies ( ) {
162
72
const npmApiSearch = searchRegistryUsing ( noopLogger ) ;
0 commit comments