Skip to content

Commit 2913cfe

Browse files
committed
refactor(sdk-auth): to use querystring under test
1 parent d15aca5 commit 2913cfe

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

packages/sdk-auth/test/client-password-flow.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import nock from 'nock'
2-
import { encode } from 'qss'
2+
import querystring from 'querystring'
33
import Auth from '../src/auth'
44
import config from './resources/sample-config'
55
import response from './resources/sample-response.json'
@@ -14,7 +14,7 @@ describe('Client Password flow', () => {
1414
const scope = nock(config.host)
1515
.post(
1616
`/oauth/token`,
17-
encode({
17+
querystring.encode({
1818
grant_type: 'password',
1919
scope: `manage_project:${config.projectKey}`,
2020
username: 'user123',
@@ -44,7 +44,7 @@ describe('Client Password flow', () => {
4444
.post(
4545
`/oauth/token`,
4646
// expected body
47-
encode({
47+
querystring.encode({
4848
grant_type: 'password',
4949
scope: `manage_project:${config.projectKey}`,
5050
username: userCredentials.username,
@@ -70,7 +70,7 @@ describe('Client Password flow', () => {
7070
const scope = nock(config.host)
7171
.post(
7272
`/oauth/token`,
73-
encode({
73+
querystring.encode({
7474
grant_type: 'password',
7575
refresh_token: false,
7676
scope: `manage_project:${config.projectKey}`,

packages/sdk-auth/test/common.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import nock from 'nock'
22
import fetch from 'node-fetch'
3-
import { encode } from 'qss'
3+
import querystring from 'querystring'
44
import { getErrorByCode } from '@commercetools/sdk-middleware-http'
55
import Auth from '../src/auth'
66
import config from './resources/sample-config'
@@ -15,7 +15,7 @@ describe('Common processes', () => {
1515
const request = {
1616
basicAuth,
1717
uri: 'https://auth.commercetools.com/api-endpoint',
18-
body: encode({
18+
body: querystring.encode({
1919
grant_type: 'client_credentials',
2020
scope: 'manage_project:project-key',
2121
}),
@@ -224,7 +224,7 @@ describe('Common processes', () => {
224224
basicAuth,
225225
authType: 'Basic',
226226
uri: 'https://auth.commercetools.com/api-endpoint',
227-
body: encode({
227+
body: querystring.encode({
228228
grant_type: 'client_credentials',
229229
scope: 'view_products:sample-project manage_types:sample-project',
230230
}),

packages/sdk-auth/test/customer-password-flow.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import nock from 'nock'
2-
import { encode } from 'qss'
2+
import querystring from 'querystring'
33
import Auth from '../src/auth'
44
import config from './resources/sample-config'
55
import response from './resources/sample-response.json'
@@ -14,7 +14,7 @@ describe('Customer Password flow', () => {
1414
const scope = nock(config.host)
1515
.post(
1616
`/oauth/${config.projectKey}/customers/token`,
17-
encode({
17+
querystring.encode({
1818
grant_type: 'password',
1919
scope: `manage_project:${config.projectKey}`,
2020
username: 'user123',
@@ -43,7 +43,7 @@ describe('Customer Password flow', () => {
4343
const scope = nock(config.host)
4444
.post(
4545
`/oauth/${config.projectKey}/customers/token`,
46-
encode({
46+
querystring.encode({
4747
grant_type: 'password',
4848
scope: `manage_project:${config.projectKey}`,
4949
username: userCredentials.username,

packages/sdk-auth/test/token-introspection.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import nock from 'nock'
2-
import { encode } from 'qss'
2+
import querystring from 'querystring'
33
import Auth from '../src/auth'
44
import config from './resources/sample-config'
55

@@ -18,7 +18,7 @@ describe('Token Introspection', () => {
1818
const scope = nock(config.host)
1919
.post(
2020
'/oauth/introspect',
21-
encode({
21+
querystring.encode({
2222
grant_type: 'client_credentials',
2323
scope: 'manage_project:sample-project',
2424
token: 'tokenValue',

0 commit comments

Comments
 (0)