Skip to content

Commit

Permalink
Update to 0.8.4 (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbyiliev authored Jul 18, 2024
1 parent 73c32c9 commit 2917d9d
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 48 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
CHANGELOG
=========
## 0.3.4 - 2024-07-16
Update to Terraform Provider [0.8.4](https://github.com/MaterializeInc/terraform-provider-materialize/releases/tag/v0.8.4).

## 0.3.3 - 2024-07-08
Update to Terraform Provider [0.8.3](https://github.com/MaterializeInc/terraform-provider-materialize/releases/tag/v0.8.3).

Expand Down
46 changes: 46 additions & 0 deletions examples/mocks/frontegg/mock_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ func (app *App) routes() {
app.Router.HandleFunc("/identity/resources/users/v2", app.handleUserRequest).Methods("POST")
app.Router.HandleFunc("/identity/resources/roles/v2", app.handleRolesRequest).Methods("GET")
app.Router.HandleFunc("/identity/resources/users/v3", app.handleUserV3Request).Methods("GET")
app.Router.HandleFunc("/frontegg/team/resources/members/v1", app.handleUpdateUserRoles).Methods("PUT")
app.Router.HandleFunc("/frontegg/team/resources/sso/v1/configurations", app.handleSSOConfigRequest).Methods("GET", "POST")
app.Router.HandleFunc("/frontegg/team/resources/sso/v1/configurations/{id}", app.handleSSOConfigAndDomainRequest).Methods("GET", "PATCH", "DELETE")
app.Router.HandleFunc("/frontegg/team/resources/sso/v1/configurations/{id}/domains", app.handleDomainRequests).Methods("GET", "POST")
Expand All @@ -227,6 +228,7 @@ func (app *App) routes() {
app.Router.HandleFunc("/frontegg/team/resources/sso/v1/configurations/{id}/groups/{groupId}", app.handleGroupMappingRequests).Methods("GET", "PATCH", "DELETE")
app.Router.HandleFunc("/frontegg/team/resources/sso/v1/configurations/{id}/roles", app.handleDefaultRolesRequests).Methods("GET", "PUT", "DELETE")
app.Router.HandleFunc("/frontegg/identity/resources/groups/v1", app.handleSCIMGroupsRequest).Methods("GET", "POST")
app.Router.HandleFunc("/frontegg/identity/resources/groups/v1/{id}/", app.handleSCIMGroupsParamRequest).Methods("GET")
app.Router.HandleFunc("/frontegg/identity/resources/groups/v1/{id}", app.handleSCIMGroupsParamRequest).Methods("GET", "PATCH", "DELETE")
app.Router.HandleFunc("/frontegg/identity/resources/groups/v1/{id}/roles", app.handleAddRolesToGroup).Methods("POST", "DELETE")
app.Router.HandleFunc("/frontegg/identity/resources/groups/v1/{id}/users", app.handleAddUsersToGroup).Methods("POST", "DELETE")
Expand Down Expand Up @@ -318,6 +320,10 @@ func (app *App) handleUserV3Request(w http.ResponseWriter, r *http.Request) {
app.getUsersV3(w, r)
}

func (app *App) handleUpdateUserRoles(w http.ResponseWriter, r *http.Request) {
app.updateUserRoles(w, r)
}

func (app *App) handleRolesRequest(w http.ResponseWriter, r *http.Request) {
roles := []FronteggRole{
{ID: "1", Name: "Organization Admin"},
Expand Down Expand Up @@ -699,6 +705,46 @@ func (app *App) getUsersV3(w http.ResponseWriter, r *http.Request) {
sendJSONResponse(w, http.StatusOK, response)
}

func (app *App) updateUserRoles(w http.ResponseWriter, r *http.Request) {
var req struct {
ID string `json:"id"`
Email string `json:"email"`
RoleIDs []string `json:"roleIds"`
}

if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}

app.Store.Mu.Lock()
defer app.Store.Mu.Unlock()

user, exists := app.Store.Users[req.ID]
if !exists {
http.Error(w, "User not found", http.StatusNotFound)
return
}

user.Roles = []FronteggRole{}
for _, roleID := range req.RoleIDs {
roleName := ""
switch roleID {
case "1":
roleName = "Organization Admin"
case "2":
roleName = "Organization Member"
default:
roleName = "Unknown Role"
}
user.Roles = append(user.Roles, FronteggRole{ID: roleID, Name: roleName})
}

app.Store.Users[req.ID] = user

sendJSONResponse(w, http.StatusOK, user)
}

func (app *App) createSSOConfig(w http.ResponseWriter, r *http.Request) {
var newConfig SSOConfig
if err := json.NewDecoder(r.Body).Decode(&newConfig); err != nil {
Expand Down
Loading

0 comments on commit 2917d9d

Please sign in to comment.