Skip to content

Commit

Permalink
Replicate auth initialization for FS and OS
Browse files Browse the repository at this point in the history
Signed-off-by: Ondrej Vasko <ondrej.vaskoo@gmail.com>
  • Loading branch information
Lirt committed Apr 6, 2024
1 parent c7b264f commit a6ce769
Showing 9 changed files with 207 additions and 59 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -149,7 +149,7 @@ Recommended way of using this plugin with restic is to use authentication with e

```bash
# test and build code
go test -v ./...
go test -v -count 1 ./...
go mod tidy
go build

8 changes: 4 additions & 4 deletions docs/installation-using-cli.md
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ spec:
cloud: ""
# optional Region:
# in case multiple regions exist in a single cloud, select which region
# will be used for backups.
# will be used for cinder volume backups.
region: ""
# optional snapshot method:
# * "snapshot" is a default cinder snapshot method
@@ -98,12 +98,12 @@ spec:
provider: community.openstack.org/openstack-manila
config:
# optional Cloud:
# in case clouds.yaml is used as authentication method, cloud allows
# user to select which cloud from the clouds.yaml to use for volume backups
# in case clouds.yaml is used as authentication method, cloud allows user
# to select which cloud from the clouds.yaml to use for manila share backups
cloud: ""
# optional Region:
# in case multiple regions exist in a single cloud, select which region
# will be used for backups.
# will be used for manila share backups.
region: ""
# optional snapshot method:
# * "snapshot" is a default manila snapshot method
8 changes: 4 additions & 4 deletions docs/installation-using-helm.md
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ configuration:
cloud: ""
# optional Region:
# in case multiple regions exist in a single cloud, select which region
# will be used for backups.
# will be used for cinder volume backups.
region: ""
# optional snapshot method:
# * "snapshot" is a default cinder snapshot method
@@ -70,12 +70,12 @@ configuration:
provider: community.openstack.org/openstack-manila
config:
# optional Cloud:
# in case clouds.yaml is used as authentication method, cloud allows
# user to select which cloud from the clouds.yaml to use for volume backups
# in case clouds.yaml is used as authentication method, cloud allows user
# to select which cloud from the clouds.yaml to use for manila share backups
cloud: ""
# optional Region:
# in case multiple regions exist in a single cloud, select which region
# will be used for backups.
# will be used for manila share backups.
region: ""
# optional snapshot method:
# * "snapshot" is a default manila snapshot method
32 changes: 10 additions & 22 deletions src/cinder/block_store_test.go
Original file line number Diff line number Diff line change
@@ -36,8 +36,8 @@ const tokenResp = `{
"url": "http://localhost:35357"
}
],
"id": "854d03ceed4611ee82b09cb6d0fbac9d",
"type": "identity",
"id": "854d03ceed4611ee82b09cb6d0fbac9d",
"type": "identity",
"name": "keystone"
},
{
@@ -106,10 +106,10 @@ const tokenResp = `{
"project": {
"domain": {
"id": "8789d1",
"name": "example.com"
"name": "domain"
},
"id": "263fa9",
"name": "project-y"
"id": "04982538-f42b-11ee-a412-9cb6d0fbac9d",
"name": "project"
},
"roles": [
{
@@ -121,25 +121,13 @@ const tokenResp = `{
"name": "member"
}
],
"service_providers": [
{
"auth_url":"https://example.com:5000/v3/OS-FEDERATION/identity_providers/acme/protocols/saml2/auth",
"id": "sp1",
"sp_url": "https://example.com:5000/Shibboleth.sso/SAML2/ECP"
},
{
"auth_url":"https://other.example.com:5000/v3/OS-FEDERATION/identity_providers/acme/protocols/saml2/auth",
"id": "sp2",
"sp_url": "https://other.example.com:5000/Shibboleth.sso/SAML2/ECP"
}
],
"user": {
"domain": {
"id": "8789d1",
"name": "example.com"
"name": "domain"
},
"id": "0ca8f6",
"name": "Jane",
"id": "cf78e694-f42a-11ee-bfcc-9cb6d0fbac9d",
"name": "user",
"password_expires_at": "2026-11-06T15:32:17.000000"
}
}
@@ -148,9 +136,9 @@ const tokenResp = `{
// TestInit performs standard block store initialization
// which includes creation of auth client, authentication and
// creation of block storage client.
// In this test we use simple clouds.yaml and don't override
// In this test we use simple clouds.yaml and not override
// any option.
func TestInit(t *testing.T) {
func TestSimpleBlockStorageInit(t *testing.T) {
// Basic structs
log := logrus.New()
config := map[string]string{
2 changes: 1 addition & 1 deletion src/cinder/clouds.yaml
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
clouds:
myCloud:
auth:
user_domain_name: users
user_domain_name: domain
auth_url: http://127.0.0.1:32498/v3
username: user
password: pass
2 changes: 1 addition & 1 deletion src/manila/clouds.yaml
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ clouds:
myCloud:
auth:
user_domain_name: users
auth_url: http://127.0.0.1:32498/v3
auth_url: http://127.0.0.1:32499/v3
username: user
password: pass
project_name: project
40 changes: 14 additions & 26 deletions src/manila/fs_store_test.go
Original file line number Diff line number Diff line change
@@ -36,8 +36,8 @@ const tokenResp = `{
"url": "http://localhost:35357"
}
],
"id": "854d03ceed4611ee82b09cb6d0fbac9d",
"type": "identity",
"id": "854d03ceed4611ee82b09cb6d0fbac9d",
"type": "identity",
"name": "keystone"
},
{
@@ -106,10 +106,10 @@ const tokenResp = `{
"project": {
"domain": {
"id": "8789d1",
"name": "example.com"
"name": "domain"
},
"id": "263fa9",
"name": "project-y"
"id": "04982538-f42b-11ee-a412-9cb6d0fbac9d",
"name": "project"
},
"roles": [
{
@@ -121,36 +121,24 @@ const tokenResp = `{
"name": "member"
}
],
"service_providers": [
{
"auth_url":"https://example.com:5000/v3/OS-FEDERATION/identity_providers/acme/protocols/saml2/auth",
"id": "sp1",
"sp_url": "https://example.com:5000/Shibboleth.sso/SAML2/ECP"
},
{
"auth_url":"https://other.example.com:5000/v3/OS-FEDERATION/identity_providers/acme/protocols/saml2/auth",
"id": "sp2",
"sp_url": "https://other.example.com:5000/Shibboleth.sso/SAML2/ECP"
}
],
"user": {
"domain": {
"id": "8789d1",
"name": "example.com"
"name": "domain"
},
"id": "0ca8f6",
"name": "Jane",
"id": "cf78e694-f42a-11ee-bfcc-9cb6d0fbac9d",
"name": "user",
"password_expires_at": "2026-11-06T15:32:17.000000"
}
}
}`

// TestInit performs standard block store initialization
// TestInit performs standard file share store initialization
// which includes creation of auth client, authentication and
// creation of block storage client.
// In this test we use simple clouds.yaml and don't override
// any option.
func TestInit(t *testing.T) {
// creation of shared filesystem client.
// In this test we use simple clouds.yaml and not override
// any options.
func TestSimpleSharedFilesystemInit(t *testing.T) {
// Basic structs
log := logrus.New()
config := map[string]string{
@@ -161,7 +149,7 @@ func TestInit(t *testing.T) {
// Create fake provider client for authentication,
// prepare handler for authentication and redirect
// provider endpoint to fake client.
th.SetupPersistentPortHTTP(t, 32498)
th.SetupPersistentPortHTTP(t, 32499)
defer th.TeardownHTTP()
fakeClient.ServiceClient()
fs.provider = fakeClient.ServiceClient().ProviderClient
12 changes: 12 additions & 0 deletions src/swift/clouds.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file is only to perform unit test with clouds.yaml for which the path cannot be changed
clouds:
myCloud:
auth:
user_domain_name: users
auth_url: http://127.0.0.1:32500/v3
username: user
password: pass
project_name: project
project_domain_name: domain
# region_name: myRegion
identity_api_version: 3
Loading

0 comments on commit a6ce769

Please sign in to comment.