-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
510 additions
and
3 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
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,60 @@ | ||
#!/bin/bash | ||
|
||
go build ./cmd/kes/... | ||
|
||
./kes identity new --key=admin.key --cert=admin.crt admin --force | ||
./kes identity new --key=client.key --cert=client.crt client --force | ||
./kes identity new --key private.key --cert public.crt --ip "127.0.0.1" localhost --force | ||
|
||
export KES_UNSEAL_KEY=$(cat /dev/urandom | head -c 32 | base64) | ||
|
||
echo "version: v1" > ./init.yml | ||
echo "address: 0.0.0.0:7373" >> ./init.yml | ||
echo "tls:" >> ./init.yml | ||
echo " key: private.key" >> ./init.yml | ||
echo " cert: public.crt" >> ./init.yml | ||
echo " client:" >> ./init.yml | ||
echo " verify_cert: false" >> ./init.yml | ||
echo "system:" >> ./init.yml | ||
echo " admin:" >> ./init.yml | ||
echo " identity: $(./kes identity of admin.crt)" >> ./init.yml | ||
echo "unseal:" >> ./init.yml | ||
echo " environment:" >> ./init.yml | ||
echo " name: KES_UNSEAL_KEY" >> ./init.yml | ||
echo "enclave:" >> ./init.yml | ||
echo " default:" >> ./init.yml | ||
echo " admin:" >> ./init.yml | ||
echo " identity: $(./kes identity of client.crt)" >> ./init.yml | ||
echo " policy:" >> ./init.yml | ||
echo " minio:" >> ./init.yml | ||
echo " allow:" >> ./init.yml | ||
echo " - /v1/api" >> ./init.yml | ||
echo " - /v1/metrics" >> ./init.yml | ||
echo " - /v1/key/list/*" >> ./init.yml | ||
echo " - /v1/key/create/*" >> ./init.yml | ||
echo " - /v1/key/import/*" >> ./init.yml | ||
echo " - /v1/key/delete/*" >> ./init.yml | ||
echo " - /v1/key/generate/*" >> ./init.yml | ||
echo " - /v1/key/decrypt/*" >> ./init.yml | ||
echo " - /v1/policy/list/*" >> ./init.yml | ||
echo " - /v1/policy/assign/*" >> ./init.yml | ||
echo " - /v1/policy/write/*" >> ./init.yml | ||
echo " - /v1/policy/describe/*" >> ./init.yml | ||
echo " - /v1/policy/read/*" >> ./init.yml | ||
echo " - /v1/policy/delete/*" >> ./init.yml | ||
echo " - /v1/identity/list/*" >> ./init.yml | ||
echo " - /v1/identity/describe/*" >> ./init.yml | ||
echo " - /v1/identity/delete/*" >> ./init.yml | ||
|
||
./kes init --config init.yml ./data --force | ||
./kes server ./data --auth=off & | ||
KES_PID=$! | ||
./kes ui & | ||
KES_UI_PID=$! | ||
|
||
go test ./restapi/integration/... | ||
|
||
rm kes admin.key admin.crt client.key client.crt private.key public.crt init.yml | ||
|
||
kill -9 $KES_PID | ||
kill -9 $KES_UI_PID |
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,68 @@ | ||
// This file is part of MinIO KES | ||
// Copyright (c) 2023 MinIO, Inc. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
package integration | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
type APITestSuite struct { | ||
suite.Suite | ||
assert *assert.Assertions | ||
token string | ||
} | ||
|
||
func (suite *APITestSuite) SetupSuite() { | ||
suite.assert = assert.New(suite.T()) | ||
} | ||
|
||
func (suite *APITestSuite) SetupTest() { | ||
} | ||
|
||
func (suite *APITestSuite) TearDownSuite() { | ||
} | ||
|
||
func (suite *APITestSuite) TearDownTest() { | ||
} | ||
|
||
func (suite *APITestSuite) TestAPI() { | ||
var err error | ||
suite.token, err = login() | ||
suite.assert.NoError(err) | ||
suite.getAPIs() | ||
suite.getMetrics() | ||
} | ||
|
||
func (suite *APITestSuite) getAPIs() { | ||
res, err := makeRequest(nil, "GET", "http://localhost:9393/api/v1/encryption/apis", suite.token) | ||
suite.assert.NoError(err) | ||
suite.assert.Equal(http.StatusOK, res.StatusCode) | ||
} | ||
|
||
func (suite *APITestSuite) getMetrics() { | ||
res, err := makeRequest(nil, "GET", "http://localhost:9393/api/v1/encryption/metrics", suite.token) | ||
suite.assert.NoError(err) | ||
suite.assert.Equal(http.StatusOK, res.StatusCode) | ||
} | ||
|
||
func TestAPI(t *testing.T) { | ||
suite.Run(t, new(APITestSuite)) | ||
} |
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,80 @@ | ||
// This file is part of MinIO KES | ||
// Copyright (c) 2023 MinIO, Inc. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
package integration | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
type KeysTestSuite struct { | ||
suite.Suite | ||
assert *assert.Assertions | ||
testKey string | ||
token string | ||
} | ||
|
||
func (suite *KeysTestSuite) SetupSuite() { | ||
suite.assert = assert.New(suite.T()) | ||
suite.testKey = "test-key" | ||
} | ||
|
||
func (suite *KeysTestSuite) SetupTest() { | ||
} | ||
|
||
func (suite *KeysTestSuite) TearDownSuite() { | ||
} | ||
|
||
func (suite *KeysTestSuite) TearDownTest() { | ||
} | ||
|
||
func (suite *KeysTestSuite) TestKeys() { | ||
var err error | ||
suite.token, err = login() | ||
suite.assert.NoError(err) | ||
suite.createKey() | ||
suite.listKeys() | ||
suite.deleteKey() | ||
} | ||
|
||
func (suite *KeysTestSuite) createKey() { | ||
data := map[string]interface{}{"key": suite.testKey} | ||
res, err := makeRequest(data, "POST", "http://localhost:9393/api/v1/encryption/keys", suite.token) | ||
suite.assert.NoError(err) | ||
suite.assert.Equal(http.StatusCreated, res.StatusCode) | ||
} | ||
|
||
func (suite *KeysTestSuite) listKeys() { | ||
res, err := makeRequest(nil, "GET", "http://localhost:9393/api/v1/encryption/keys", suite.token) | ||
suite.assert.NoError(err) | ||
suite.assert.Equal(http.StatusOK, res.StatusCode) | ||
} | ||
|
||
func (suite *KeysTestSuite) deleteKey() { | ||
url := fmt.Sprintf("http://localhost:9393/api/v1/encryption/keys/%s", suite.testKey) | ||
res, err := makeRequest(nil, "DELETE", url, suite.token) | ||
suite.assert.NoError(err) | ||
suite.assert.Equal(http.StatusOK, res.StatusCode) | ||
} | ||
|
||
func TestKeys(t *testing.T) { | ||
suite.Run(t, new(KeysTestSuite)) | ||
} |
Oops, something went wrong.