-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch teams query to nais-api spec (#151)
Co-authored-by: Frode Sundby <[email protected]> Co-authored-by: Johnny Horvi <[email protected]>
- Loading branch information
1 parent
d96e3be
commit 43cfceb
Showing
3 changed files
with
98 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,18 +12,23 @@ describe("NaisTeams", () => { | |
const expectedUser: User = { | ||
name: "John Doe", | ||
email: "[email protected]", | ||
teams: [ | ||
{ | ||
role: "admin", | ||
team: { | ||
slug: "team-a", | ||
teams: { | ||
nodes: [ | ||
{ | ||
role: "admin", | ||
team: { | ||
slug: "team-a", | ||
}, | ||
}, | ||
], | ||
pageInfo: { | ||
hasNextPage: false, | ||
}, | ||
], | ||
}, | ||
}; | ||
const mockResponse = { | ||
data: { | ||
userByEmail: expectedUser, | ||
user: expectedUser, | ||
}, | ||
}; | ||
jest.spyOn(global, "fetch").mockResolvedValueOnce({ | ||
|
@@ -52,7 +57,7 @@ describe("NaisTeams", () => { | |
const email = "[email protected]"; | ||
const mockResponse = { | ||
data: { | ||
userByEmail: null, | ||
user: null, | ||
}, | ||
}; | ||
jest.spyOn(global, "fetch").mockResolvedValueOnce({ | ||
|
@@ -99,21 +104,24 @@ describe("NaisTeams", () => { | |
describe("authorize", () => { | ||
it("should return status true and user object when user is authorized", async () => { | ||
const email = "[email protected]"; | ||
const expectedUser = { | ||
const expectedUser: User = { | ||
name: "John Doe", | ||
email: "[email protected]", | ||
teams: [ | ||
{ | ||
role: "admin", | ||
team: { | ||
slug: "team-a", | ||
teams: { | ||
nodes: [ | ||
{ | ||
role: "admin", | ||
team: { | ||
slug: "team-a", | ||
}, | ||
}, | ||
}, | ||
], | ||
], | ||
pageInfo: { hasNextPage: false }, | ||
}, | ||
}; | ||
const mockResponse = { | ||
data: { | ||
userByEmail: expectedUser, | ||
user: expectedUser, | ||
}, | ||
}; | ||
jest.spyOn(global, "fetch").mockResolvedValueOnce({ | ||
|
@@ -142,7 +150,7 @@ describe("NaisTeams", () => { | |
const email = "[email protected]"; | ||
const mockResponse = { | ||
data: { | ||
userByEmail: null, | ||
user: null, | ||
}, | ||
}; | ||
jest.spyOn(global, "fetch").mockResolvedValueOnce({ | ||
|
@@ -169,21 +177,24 @@ describe("NaisTeams", () => { | |
|
||
it("should return status false and null user when user is not in allowed teams", async () => { | ||
const email = "[email protected]"; | ||
const user = { | ||
const user: User = { | ||
name: "John Doe", | ||
email: "[email protected]", | ||
teams: [ | ||
{ | ||
role: "admin", | ||
team: { | ||
slug: "team-c", | ||
teams: { | ||
nodes: [ | ||
{ | ||
role: "admin", | ||
team: { | ||
slug: "team-c", | ||
}, | ||
}, | ||
}, | ||
], | ||
], | ||
pageInfo: { hasNextPage: false }, | ||
}, | ||
}; | ||
const mockResponse = { | ||
data: { | ||
userByEmail: user, | ||
user: user, | ||
}, | ||
}; | ||
jest.spyOn(global, "fetch").mockResolvedValueOnce({ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { KeyObject } from "crypto"; | ||
import { TeamsService, User } from "nais-teams"; | ||
import nock from "nock"; | ||
import request from "supertest"; | ||
import { IUnleash } from "unleash-server"; | ||
import naisleash from "./server"; | ||
import Cache from "./cache"; | ||
import request from "supertest"; | ||
import { IAP_AUDIENCE, IAP_JWT_HEADER, IAP_JWT_ISSUER } from "./google-iap"; | ||
import naisleash from "./server"; | ||
import { newSignedToken } from "./utils"; | ||
import nock from "nock"; | ||
import { KeyObject } from "crypto"; | ||
import { IAP_JWT_HEADER, IAP_JWT_ISSUER, IAP_AUDIENCE } from "./google-iap"; | ||
import { TeamsService, User } from "nais-teams"; | ||
|
||
let mockTeamsService: TeamsService; | ||
let server: IUnleash; | ||
|
@@ -130,14 +130,19 @@ describe("Unleash server", () => { | |
const mockUser: User = { | ||
name: "test", | ||
email: "[email protected]", | ||
teams: [ | ||
{ | ||
role: "admin", | ||
team: { | ||
slug: "team", | ||
teams: { | ||
nodes: [ | ||
{ | ||
role: "admin", | ||
team: { | ||
slug: "team", | ||
}, | ||
}, | ||
], | ||
pageInfo: { | ||
hasNextPage: false, | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
jest.spyOn(mockTeamsService, "authorize").mockResolvedValueOnce({ | ||
|
@@ -172,14 +177,19 @@ describe("Unleash server", () => { | |
const mockUser: User = { | ||
name: "test", | ||
email: "[email protected]", | ||
teams: [ | ||
{ | ||
role: "member", | ||
team: { | ||
slug: "team", | ||
teams: { | ||
nodes: [ | ||
{ | ||
role: "member", | ||
team: { | ||
slug: "team", | ||
}, | ||
}, | ||
], | ||
pageInfo: { | ||
hasNextPage: false, | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
jest.spyOn(mockTeamsService, "authorize").mockResolvedValueOnce({ | ||
|