Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Icerzack committed Jul 26, 2024
1 parent 5d8023a commit 97fe7f7
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 37 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ You can use this library to work with the following objects of the Selectel IAM
* [serviceusers](https://pkg.go.dev/github.com/selectel/iam-go/service/serviceusers)
* [groups](https://pkg.go.dev/github.com/selectel/iam-go/service/groups)
* [s3credentials](https://pkg.go.dev/github.com/selectel/iam-go/service/s3credentials)
* [federations (saml)](https://pkg.go.dev/github.com/selectel/iam-go/service/federations/saml)

### Installation

Expand Down
6 changes: 3 additions & 3 deletions examples/federation-with-user/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"os"

"github.com/selectel/iam-go"
"github.com/selectel/iam-go/service/federations/certificates"
"github.com/selectel/iam-go/service/federations/saml"
"github.com/selectel/iam-go/service/federations/saml/certificates"
"github.com/selectel/iam-go/service/roles"
"github.com/selectel/iam-go/service/users"
)
Expand Down Expand Up @@ -44,8 +44,8 @@ func main() {
return
}

federationsAPI := iamClient.Federations
federationsCertificatesAPI := iamClient.FederationsCertificates
federationsAPI := iamClient.SAMLFederations
federationsCertificatesAPI := federationsAPI.Certificates
usersAPI := iamClient.Users

ctx := context.Background()
Expand Down
13 changes: 4 additions & 9 deletions iam.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"github.com/selectel/iam-go/iamerrors"
baseclient "github.com/selectel/iam-go/internal/client"
"github.com/selectel/iam-go/service/federations/certificates"
"github.com/selectel/iam-go/service/federations/saml"
"github.com/selectel/iam-go/service/groups"
"github.com/selectel/iam-go/service/s3credentials"
Expand Down Expand Up @@ -60,12 +59,9 @@ type Client struct {
// S3Credentials instance is used to make requests against Selectel IAM API and manage S3 Credentials.
S3Credentials *s3credentials.Service

// Federations instance is used to make requests against Selectel IAM API and manage Federations.
Federations *saml.Service

// FederationsCertificates instance is used to make requests against Selectel IAM API
// and manage Federations Certificates.
FederationsCertificates *certificates.Service
// SAMLFederations instance is used to make requests against Selectel IAM API and manage SAML Federations.
// It also contains Certificates service, which is used to manage certificates.
SAMLFederations *saml.Service
}

type AuthOpts struct {
Expand Down Expand Up @@ -137,8 +133,7 @@ func New(opts ...Option) (*Client, error) {
c.ServiceUsers = serviceusers.New(c.baseClient)
c.Groups = groups.New(c.baseClient)
c.S3Credentials = s3credentials.New(c.baseClient)
c.Federations = saml.New(c.baseClient)
c.FederationsCertificates = certificates.New(c.baseClient)
c.SAMLFederations = saml.New(c.baseClient)

return c, nil
}
Expand Down
40 changes: 18 additions & 22 deletions iam_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/selectel/iam-go/iamerrors"
baseclient "github.com/selectel/iam-go/internal/client"
"github.com/selectel/iam-go/service/federations/certificates"
"github.com/selectel/iam-go/service/federations/saml"
"github.com/selectel/iam-go/service/groups"
"github.com/selectel/iam-go/service/s3credentials"
Expand Down Expand Up @@ -59,13 +58,12 @@ func TestNew(t *testing.T) {
authOpts: &AuthOpts{
KeystoneToken: testToken,
},
baseClient: baseClient,
Users: users.New(baseClient),
ServiceUsers: serviceusers.New(baseClient),
Groups: groups.New(baseClient),
S3Credentials: s3credentials.New(baseClient),
Federations: saml.New(baseClient),
FederationsCertificates: certificates.New(baseClient),
baseClient: baseClient,
Users: users.New(baseClient),
ServiceUsers: serviceusers.New(baseClient),
Groups: groups.New(baseClient),
S3Credentials: s3credentials.New(baseClient),
SAMLFederations: saml.New(baseClient),
}
},
expectedError: nil,
Expand Down Expand Up @@ -103,13 +101,12 @@ func TestNew(t *testing.T) {
authOpts: &AuthOpts{
KeystoneToken: testToken,
},
baseClient: baseClient,
Users: users.New(baseClient),
ServiceUsers: serviceusers.New(baseClient),
Groups: groups.New(baseClient),
S3Credentials: s3credentials.New(baseClient),
Federations: saml.New(baseClient),
FederationsCertificates: certificates.New(baseClient),
baseClient: baseClient,
Users: users.New(baseClient),
ServiceUsers: serviceusers.New(baseClient),
Groups: groups.New(baseClient),
S3Credentials: s3credentials.New(baseClient),
SAMLFederations: saml.New(baseClient),
}
},
expectedError: nil,
Expand Down Expand Up @@ -140,13 +137,12 @@ func TestNew(t *testing.T) {
authOpts: &AuthOpts{
KeystoneToken: testToken,
},
baseClient: baseClient,
Users: users.New(baseClient),
ServiceUsers: serviceusers.New(baseClient),
Groups: groups.New(baseClient),
S3Credentials: s3credentials.New(baseClient),
Federations: saml.New(baseClient),
FederationsCertificates: certificates.New(baseClient),
baseClient: baseClient,
Users: users.New(baseClient),
ServiceUsers: serviceusers.New(baseClient),
Groups: groups.New(baseClient),
S3Credentials: s3credentials.New(baseClient),
SAMLFederations: saml.New(baseClient),
}
},
expectedError: nil,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/selectel/iam-go/iamerrors"
"github.com/selectel/iam-go/internal/client"
"github.com/selectel/iam-go/service/federations/certificates/testdata"
"github.com/selectel/iam-go/service/federations/saml/certificates/testdata"
)

const (
Expand Down
File renamed without changes.
7 changes: 5 additions & 2 deletions service/federations/saml/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,22 @@ import (

"github.com/selectel/iam-go/iamerrors"
"github.com/selectel/iam-go/internal/client"
"github.com/selectel/iam-go/service/federations/saml/certificates"
)

const apiVersion = "v1"

// Service is used to communicate with the Federations API.
type Service struct {
baseClient *client.BaseClient
Certificates *certificates.Service
baseClient *client.BaseClient
}

// New Initialises Service with the given client.
func New(baseClient *client.BaseClient) *Service {
return &Service{
baseClient: baseClient,
Certificates: certificates.New(baseClient),
baseClient: baseClient,
}
}

Expand Down

0 comments on commit 97fe7f7

Please sign in to comment.