|
|
@ -34,6 +34,7 @@ jest.mock("../../web", () => ({ |
|
|
|
.mockReturnValueOnce(false) |
|
|
|
.mockReturnValueOnce(false) |
|
|
|
.mockReturnValueOnce(true) |
|
|
|
.mockReturnValueOnce(true) |
|
|
|
.mockReturnValueOnce(true) |
|
|
|
.mockReturnValueOnce(true) |
|
|
|
|
|
|
|
.mockReturnValueOnce(true) |
|
|
|
.mockReturnValueOnce(false), |
|
|
|
.mockReturnValueOnce(false), |
|
|
|
ListObjects: jest.fn(({ bucketName }) => { |
|
|
|
ListObjects: jest.fn(({ bucketName }) => { |
|
|
|
if (bucketName === "test-deny") { |
|
|
|
if (bucketName === "test-deny") { |
|
|
@ -69,7 +70,14 @@ jest.mock("../../web", () => ({ |
|
|
|
}) |
|
|
|
}) |
|
|
|
.mockImplementationOnce(() => { |
|
|
|
.mockImplementationOnce(() => { |
|
|
|
return Promise.resolve({ token: "test" }) |
|
|
|
return Promise.resolve({ token: "test" }) |
|
|
|
}) |
|
|
|
}), |
|
|
|
|
|
|
|
GetBucketPolicy: jest.fn(({ bucketName, prefix }) => { |
|
|
|
|
|
|
|
if (!bucketName) { |
|
|
|
|
|
|
|
return Promise.reject({ message: "Invalid bucket" }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (bucketName === 'test-public') return Promise.resolve({ policy: 'readonly' }) |
|
|
|
|
|
|
|
return Promise.resolve({}) |
|
|
|
|
|
|
|
}) |
|
|
|
})) |
|
|
|
})) |
|
|
|
|
|
|
|
|
|
|
|
const middlewares = [thunk] |
|
|
|
const middlewares = [thunk] |
|
|
@ -295,7 +303,8 @@ describe("Objects actions", () => { |
|
|
|
type: "objects/SET_SHARE_OBJECT", |
|
|
|
type: "objects/SET_SHARE_OBJECT", |
|
|
|
show: true, |
|
|
|
show: true, |
|
|
|
object: "b.txt", |
|
|
|
object: "b.txt", |
|
|
|
url: "test" |
|
|
|
url: "test", |
|
|
|
|
|
|
|
showExpiryDate: true |
|
|
|
} |
|
|
|
} |
|
|
|
] |
|
|
|
] |
|
|
|
store.dispatch(actionsObjects.showShareObject("b.txt", "test")) |
|
|
|
store.dispatch(actionsObjects.showShareObject("b.txt", "test")) |
|
|
@ -321,14 +330,16 @@ describe("Objects actions", () => { |
|
|
|
it("creates objects/SET_SHARE_OBJECT when object is shared", () => { |
|
|
|
it("creates objects/SET_SHARE_OBJECT when object is shared", () => { |
|
|
|
const store = mockStore({ |
|
|
|
const store = mockStore({ |
|
|
|
buckets: { currentBucket: "bk1" }, |
|
|
|
buckets: { currentBucket: "bk1" }, |
|
|
|
objects: { currentPrefix: "pre1/" } |
|
|
|
objects: { currentPrefix: "pre1/" }, |
|
|
|
|
|
|
|
browser: { serverInfo: {} }, |
|
|
|
}) |
|
|
|
}) |
|
|
|
const expectedActions = [ |
|
|
|
const expectedActions = [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
type: "objects/SET_SHARE_OBJECT", |
|
|
|
type: "objects/SET_SHARE_OBJECT", |
|
|
|
show: true, |
|
|
|
show: true, |
|
|
|
object: "a.txt", |
|
|
|
object: "a.txt", |
|
|
|
url: "https://test.com/bk1/pre1/b.txt" |
|
|
|
url: "https://test.com/bk1/pre1/b.txt", |
|
|
|
|
|
|
|
showExpiryDate: true |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
type: "alert/SET", |
|
|
|
type: "alert/SET", |
|
|
@ -347,10 +358,42 @@ describe("Objects actions", () => { |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it("creates objects/SET_SHARE_OBJECT when object is shared with public link", () => { |
|
|
|
|
|
|
|
const store = mockStore({ |
|
|
|
|
|
|
|
buckets: { currentBucket: "test-public" }, |
|
|
|
|
|
|
|
objects: { currentPrefix: "pre1/" }, |
|
|
|
|
|
|
|
browser: { serverInfo: { info: { domains: ['public.com'] }} }, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
const expectedActions = [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
type: "objects/SET_SHARE_OBJECT", |
|
|
|
|
|
|
|
show: true, |
|
|
|
|
|
|
|
object: "a.txt", |
|
|
|
|
|
|
|
url: "public.com/test-public/pre1/a.txt", |
|
|
|
|
|
|
|
showExpiryDate: false |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
type: "alert/SET", |
|
|
|
|
|
|
|
alert: { |
|
|
|
|
|
|
|
type: "success", |
|
|
|
|
|
|
|
message: "Object shared.", |
|
|
|
|
|
|
|
id: alertActions.alertId |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
return store |
|
|
|
|
|
|
|
.dispatch(actionsObjects.shareObject("a.txt", 1, 0, 0)) |
|
|
|
|
|
|
|
.then(() => { |
|
|
|
|
|
|
|
const actions = store.getActions() |
|
|
|
|
|
|
|
expect(actions).toEqual(expectedActions) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
it("creates alert/SET when shareObject is failed", () => { |
|
|
|
it("creates alert/SET when shareObject is failed", () => { |
|
|
|
const store = mockStore({ |
|
|
|
const store = mockStore({ |
|
|
|
buckets: { currentBucket: "" }, |
|
|
|
buckets: { currentBucket: "" }, |
|
|
|
objects: { currentPrefix: "pre1/" } |
|
|
|
objects: { currentPrefix: "pre1/" }, |
|
|
|
|
|
|
|
browser: { serverInfo: {} }, |
|
|
|
}) |
|
|
|
}) |
|
|
|
const expectedActions = [ |
|
|
|
const expectedActions = [ |
|
|
|
{ |
|
|
|
{ |
|
|
|