Add versioning to auth methods and accounts (#249)

This commit is contained in:
Jeff Mitchell authored and GitHub committed 2020-08-11 11:19:29 -04:00
1 parent a7c467bd68
commit 565059ed63
23 files changed
+640 -444

No files matched your search

@@ -47,6 +47,7 @@ func TestGet(t *testing.T) {
"min_password_length": structpb.NewNumberValue(8),
"min_user_name_length": structpb.NewNumberValue(3),
}},
Version: 1,
Scope: &scopes.ScopeInfo{
Id: o.GetPublicId(),
Type: o.GetType(),
@@ -122,6 +123,7 @@ func TestList(t *testing.T) {
CreatedTime: am.GetCreateTime().GetTimestamp(),
UpdatedTime: am.GetUpdateTime().GetTimestamp(),
Scope: &scopes.ScopeInfo{Id: oWithAuthMethods.GetPublicId(), Type: scope.Org.String()},
Version: 1,
Type: "password",
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
"min_password_length": structpb.NewNumberValue(8),
@@ -137,6 +139,7 @@ func TestList(t *testing.T) {
CreatedTime: aa.GetCreateTime().GetTimestamp(),
UpdatedTime: aa.GetUpdateTime().GetTimestamp(),
Scope: &scopes.ScopeInfo{Id: oWithOtherAuthMethods.GetPublicId(), Type: scope.Org.String()},
Version: 1,
Type: "password",
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
"min_password_length": structpb.NewNumberValue(8),
@@ -310,6 +313,7 @@ func TestCreate(t *testing.T) {
Name: &wrapperspb.StringValue{Value: "name"},
Description: &wrapperspb.StringValue{Value: "desc"},
Scope: &scopes.ScopeInfo{Id: o.GetPublicId(), Type: scope.Org.String()},
Version: 1,
Type: "password",
Attributes: &structpb.Struct{Fields: map[string]*structpb.Value{
"min_password_length": structpb.NewNumberValue(8),
@@ -673,6 +677,8 @@ func TestUpdate(t *testing.T) {
am, cleanup := freshAuthMethod()
defer cleanup()
tc.req.Version = 1
if tc.req.GetId() == "" {
tc.req.Id = am.GetId()
}
@@ -702,6 +708,9 @@ func TestUpdate(t *testing.T) {
// Clear all values which are hard to compare against.
got.Item.UpdatedTime, tc.res.Item.UpdatedTime = nil, nil
assert.EqualValues(2, got.Item.Version)
tc.res.Item.Version = 2
}
assert.Empty(cmp.Diff(got, tc.res, protocmp.Transform()), "UpdateAuthMethod(%q) got response %q, wanted %q", tc.req, got, tc.res)
})