Issue #359: create folder feature added. Feature required to finish task #374
This commit is contained in:
parent
6224a92e7a
commit
fe92d7c9db
@ -98,6 +98,21 @@ func (gc *GraphConnector) createService() (*graphService, error) {
|
||||
return &connector, err
|
||||
}
|
||||
|
||||
// createMailFolder will create a mail folder iff a folder of the same name does not exit
|
||||
func createMailFolder(gc graphService, user, folder string) (models.MailFolderable, error) {
|
||||
requestBody := models.NewMailFolder()
|
||||
requestBody.SetDisplayName(&folder)
|
||||
isHidden := false
|
||||
requestBody.SetIsHidden(&isHidden)
|
||||
|
||||
return gc.client.UsersById(user).MailFolders().Post(requestBody)
|
||||
}
|
||||
|
||||
// deleteMailFolder removes the mail folder from the user's M365 Exchange account
|
||||
func deleteMailFolder(gc graphService, user, folderID string) error {
|
||||
return gc.client.UsersById(user).MailFoldersById(folderID).Delete()
|
||||
}
|
||||
|
||||
// setTenantUsers queries the M365 to identify the users in the
|
||||
// workspace. The users field is updated during this method
|
||||
// iff the return value is true
|
||||
|
||||
@ -91,8 +91,20 @@ func (suite *GraphConnectorIntegrationSuite) TestGraphConnector_restoreMessages(
|
||||
assert.NoError(suite.T(), err)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
func (suite *GraphConnectorIntegrationSuite) TestGraphConnector_createDeleteFolder() {
|
||||
user := "lidiah@8qzvrj.onmicrosoft.com"
|
||||
folderName := "createdForTest"
|
||||
aFolder, err := createMailFolder(suite.connector.graphService, user, folderName)
|
||||
assert.NoError(suite.T(), err, support.ConnectorStackErrorTrace(err))
|
||||
if aFolder != nil {
|
||||
err = deleteMailFolder(suite.connector.graphService, user, *aFolder.GetId())
|
||||
assert.NoError(suite.T(), err)
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Disconnected Test Section
|
||||
// -------------------------
|
||||
type DisconnectedGraphConnectorSuite struct {
|
||||
suite.Suite
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user