Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Enterprise License tests #5822

Merged
merged 29 commits into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
99d8a0f
applying expired license
Jun 29, 2020
3d8f7a0
applying expired license
Jun 29, 2020
40736bd
EP license unit test
Jul 2, 2020
5d60159
added unit test and invalid key
Jul 6, 2020
5765a5b
moved file
Jul 6, 2020
9ed6cb1
removed integration test
Jul 6, 2020
1c9c229
added integration test
Jul 10, 2020
3488093
added integration test
Jul 10, 2020
583b395
added integration test
Jul 13, 2020
9460301
removed p and w directory
Jul 13, 2020
9986e52
public key from var to const
Jul 13, 2020
d4915e7
updated the test
Jul 14, 2020
9695b75
addressed comments
Jul 15, 2020
318338b
addressed comments
Jul 15, 2020
59b1519
removed a comment
Jul 15, 2020
f42f378
checking user information after applying license
Jul 16, 2020
73b66d1
changed the name of the test file
Jul 16, 2020
26a52aa
moved the test file to systest folder as this is an integration test
Jul 16, 2020
ff76f4c
added http in front of address
Jul 16, 2020
a13358c
removed extra t.Log()
Jul 16, 2020
9176b00
created a new directory for the test
Jul 16, 2020
28bae01
changed the struct for errors and checking the errors for json.unmars…
Jul 16, 2020
49b1a3a
checking if the test is running or not
Jul 16, 2020
bd043bc
checking if the test is running or not
Jul 16, 2020
e6bf88c
checking if the test is running
Jul 16, 2020
1869f97
added dgraph license at the top of the file
Jul 16, 2020
bd91ab0
fix typo
Jul 16, 2020
7636f85
Merge branch 'master' into neeraj/LicenseTesting
Jul 16, 2020
2d9989f
changed offset for docker to 100
Jul 16, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions dgraph/cmd/zero/enterpriseExperiedKey.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-----BEGIN PGP MESSAGE-----
owEBwgI9/ZANAwAKAXomeeH3SyppAax7YgxsaWNlbnNlLmpzb25etF5+ewogICJ1
c2VyIjogIkRncmFwaCBUZXN0IEtleSIsCiAgIm1heF9ub2RlcyI6IDE4NDQ2NzQ0
MDczNzA5NTUxNjE1LAogICJleHBpcnkiOiAiMTk3MC0wMS0wMVQwMDowMDowMFoi
Cn0KiQIzBAABCgAdFiEED3lYS97wtaMT1MW+eiZ54fdLKmkFAl60Xn4ACgkQeiZ5
4fdLKmlVYQ//afX0H7Seb0ukxCMAcM8uqlBEGCEFv3K34avk1g8XRa6y4q/Ys0uU
DSaaDWdQ8IS5Q9SNlZBbJuqO6Pf1R01dEPTYQizWkDjYIBsY9xJnMZKEaA+F3bkn
8TXqI588+AvbqxHosz8cvh/nG+Ajk451rI9c2bqKB/FvH/zI6XyfUjqN+PvrqH0E
POA7nqSrWDemW4cMgNR4PhXehB/n2i3G6cPpwgCUd+N00N1f1mir/LmL6G5T4PrG
BmVz9fOdEr+U85PbMF9vOke9LkLQYdnF1hEV+7++t2/uoaLDYbxYhUnXpJZxwCBX
DQTievpyQF47HzuifvqUyxDSEsYiSGhhap1e/tvf1VaZoFUuTYQQpiV7+9K3UrL0
SnJ5TRWS7cEKBLyZszrakGpqVakvEUlWO4wG0Fp4kUa4YXw8t58oqHRn9aAtoqJd
UOLnq2semUttaySR4DHhjneO3/RoVm79/aaqMi/QNJzc9Tt9nY0AgcYlA3bVXmAZ
nM9Rgi6SaO5DxnRdhFzZyYQMb4onFDI0eYMOhPm+NmKWplkFXB+mKPKj5o/pcEb4
SWHt8fUAWDLsmcooIixDmSay14aBmF08hQ1vtJkY7/jo3hlK36GrLnNdN4IODqk/
I8mUd/jcj3NZtGWFoxKq4laK/ruoeoHnWMznJyMm75nzcU5QZU9yEEI=
=2lFm
-----END PGP MESSAGE-----
18 changes: 18 additions & 0 deletions dgraph/cmd/zero/enterpriseInvalidKey.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-----BEGIN PGP MESSAGE-----
owEBwgI9/ZANAwAKAXomeeH3SyppAax7YgxsaWNlbnNlLmpzb25etF5+ewogICJ1
c2VyIjogIkRncmFwaCBUZXN0IEtleSIsCiAgIm1heF9ub2RlcyI6IDE4NDQ2NzQ0
MDczNzA5NTUxNjE1LAogICJleHBpcnkiOiAiMTk3MC0wMS0wMVQwMDowaaawMFoi
Cn0KiQIzBAABCgAdFiEED3lYS97wtaMT1MW+eiZ54fdLKmkFAl60Xn4ACgkQeiZ5
4fdLKmlVYQ//afX0H7Seb0ukxCMAcM8uqlBEGCEFv3K34avk1g8XRaaa4q/Ys0uU
DSaaDWdQ8IS5Q9SNlZBbJuqO6Pf1R01dEPTYQizWkDjYIBsY9xJnMZKEaA+F3bkn
8TXqI588+AvbqxHosz8cvh/nG+Ajk451rI9c2bqKB/FvH/zI6XyfUjqN+PvrqH0E
POA7nqSrWDemW4cMgNR4PhXehB/n2i3G6cPpwgCUd+N00N1f1mir/LmL6G5T4PrG
BmVz9fOdEr+U85aaaF9vOke9LkLQYdnF1hEV+7++t2/uoaLDYbxYaaaXpJZxwCBX
DQTievpyQF47HzuifvqUyxDSEsYiSGhhap1e/tvf1VaZoFUuTYQQaaa7+9K3UrL0
SnJ5TRWS7cEKBLyZszrakGpqVakvEUlWO4wG0Fp4kUa4YXw8t58oqHRn9aAtoqJd
UOLnq2semUttayaaaDHhjneO3/RoVm79/aaqMi/QNJzc9Ttaaa0AgcYlA3bVXmAZ
nM9Rgi6SaO5DxnRdhFzZyYQMb4onFDI0eYMOhPm+NmKWplkFXB+mKPKj5o/pcEb4
SWHt8fUAWDLsmaaaIixDmSay14aBmF08hQ1vtaaa7/jo3hlK36GrLnNdN4IODqk/
I8mUd/jcj3NZtGWFoxKq4laK/ruoeoHnWMznJyMm75nzcU5QZU9yEEI=
=2lFm
-----END PGP MESSAGE-----
50 changes: 50 additions & 0 deletions dgraph/cmd/zero/enterpriseUnit_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package zero

import (
"testing"

"github.com/dgraph-io/dgraph/protos/pb"
"github.com/stretchr/testify/require"
)

func TestEnterpriseLicenseUnit(t *testing.T) {

expiredKey := "enterpriseExperiedKey.Key"
invalidKey := "enterpriseInvalidKey.Key"

var tests = []struct {
name string
licenseKeyPath string
expectError bool
expectedOutput string
}{
{
"Using expired entrerprised license key should return an error",
expiredKey,
true,
`while extracting enterprise details from the license: while decoding license file: EOF`,
},
{
"Using invalid entrerprised license key should return an error",
invalidKey,
true,
`while extracting enterprise details from the license: while decoding license file: EOF`,
},
}
server := &Server{
state: &pb.MembershipState{
Groups: map[uint32]*pb.Group{1: {Members: map[uint64]*pb.Member{}}},
},
}
for _, tt := range tests {
t.Logf("Running: %s\n", tt.name)
err := server.applyLicenseFileReturnError(expiredKey)
if tt.expectError {
require.Error(t, err)
continue
}

require.NoError(t, err)
}

}
14 changes: 14 additions & 0 deletions dgraph/cmd/zero/license_ee.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,17 @@ func (s *Server) applyLicenseFile(path string) {
glog.Infof("Unable to apply license at %v due to error %v", path, err)
}
}

func (s *Server) applyLicenseFileReturnError(path string) error {
content, err := ioutil.ReadFile(path)
if err != nil {
glog.Infof("Unable to apply license at %v due to error %v", path, err)
return err
}
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()
if err = s.applyLicense(ctx, bytes.NewReader(content)); err != nil {
glog.Infof("Unable to apply license at %v due to error %v", path, err)
}
return err
}