forked from cheelim1/terraform-provider-jumpcloud
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
better user group read, noop update for now
- Loading branch information
1 parent
ae13951
commit b74fd8d
Showing
4 changed files
with
134 additions
and
46 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
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package jumpcloud | ||
|
||
import ( | ||
"net/http" | ||
"net/http/httptest" | ||
"testing" | ||
|
||
jcapiv2 "github.com/TheJumpCloud/jcapi-go/v2" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
type ResourceUserGroupSuite struct { | ||
suite.Suite | ||
A *assert.Assertions | ||
TestHTTPServer *httptest.Server | ||
} | ||
|
||
func (s *ResourceUserGroupSuite) SetupSuite() { | ||
s.A = assert.New(s.Suite.T()) | ||
} | ||
|
||
func (s *ResourceUserGroupSuite) TestTrueUserGroupRead() { | ||
cases := []struct { | ||
ResponseStatus int | ||
UserGroupNil bool | ||
OK bool | ||
ErrorNil bool | ||
Payload []byte | ||
}{ | ||
{http.StatusNotFound, true, false, true, []byte("irrelevant")}, | ||
{http.StatusOK, false, true, true, []byte("{}")}, | ||
} | ||
|
||
for _, c := range cases { | ||
testServer := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { | ||
rw.WriteHeader(c.ResponseStatus) | ||
rw.Write(c.Payload) | ||
})) | ||
|
||
config := &jcapiv2.Configuration{ | ||
BasePath: testServer.URL, | ||
} | ||
|
||
ug, ok, err := trueUserGroupRead(config, "id") | ||
s.A.Equal(c.OK, ok) | ||
s.A.Equal(c.UserGroupNil, ug == nil) | ||
s.A.Equal(c.ErrorNil, err == nil) | ||
testServer.Close() | ||
} | ||
} | ||
|
||
func TestResourceUserGroup(t *testing.T) { | ||
suite.Run(t, new(ResourceUserGroupSuite)) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package jumpcloud | ||
|
||
import jcapiv2 "github.com/TheJumpCloud/jcapi-go/v2" | ||
|
||
type UserGroup struct { | ||
// ObjectId uniquely identifying a User Group. | ||
Id string `json:"id,omitempty"` | ||
|
||
// The type of the group. | ||
Type_ string `json:"type,omitempty"` | ||
|
||
// Display name of a User Group. | ||
Name string `json:"name,omitempty"` | ||
Attributes Attributes `json:"attributes,omitempty"` | ||
} | ||
|
||
type Attributes struct { | ||
LDAPGroups []LDAPGroup `json:"ldapGroups,omitempty"` | ||
POSIXGroups []jcapiv2.UserGroupPostAttributesPosixGroups `json:"posixGroups,omitempty"` | ||
// SambaEnabled bool `json:"sambaEnable,omitempty"` | ||
} | ||
|
||
type LDAPGroup struct { | ||
Name string `json:"name,omitempty"` | ||
} |