Users bugfixes + tests (#19)

Co-authored-by: Asim Aslam <asim@aslam.me>
This commit is contained in:
Janos Dobronszki
2020-10-26 17:49:03 +01:00
committed by GitHub
parent 9601ad952c
commit 0e356aef01
9 changed files with 416 additions and 106 deletions

View File

@@ -94,8 +94,9 @@ func (m *User) GetUpdated() int64 {
type Session struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"`
Created int64 `protobuf:"varint,3,opt,name=created,proto3" json:"created,omitempty"`
Expires int64 `protobuf:"varint,4,opt,name=expires,proto3" json:"expires,omitempty"`
Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"`
Created int64 `protobuf:"varint,4,opt,name=created,proto3" json:"created,omitempty"`
Expires int64 `protobuf:"varint,5,opt,name=expires,proto3" json:"expires,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@@ -140,6 +141,13 @@ func (m *Session) GetUsername() string {
return ""
}
func (m *Session) GetEmail() string {
if m != nil {
return m.Email
}
return ""
}
func (m *Session) GetCreated() int64 {
if m != nil {
return m.Created
@@ -155,8 +163,10 @@ func (m *Session) GetExpires() int64 {
}
type CreateRequest struct {
User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"`
Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"`
Password string `protobuf:"bytes,4,opt,name=password,proto3" json:"password,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@@ -187,11 +197,25 @@ func (m *CreateRequest) XXX_DiscardUnknown() {
var xxx_messageInfo_CreateRequest proto.InternalMessageInfo
func (m *CreateRequest) GetUser() *User {
func (m *CreateRequest) GetId() string {
if m != nil {
return m.User
return m.Id
}
return nil
return ""
}
func (m *CreateRequest) GetUsername() string {
if m != nil {
return m.Username
}
return ""
}
func (m *CreateRequest) GetEmail() string {
if m != nil {
return m.Email
}
return ""
}
func (m *CreateRequest) GetPassword() string {
@@ -381,7 +405,9 @@ func (m *ReadResponse) GetUser() *User {
}
type UpdateRequest struct {
User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"`
Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@@ -412,11 +438,25 @@ func (m *UpdateRequest) XXX_DiscardUnknown() {
var xxx_messageInfo_UpdateRequest proto.InternalMessageInfo
func (m *UpdateRequest) GetUser() *User {
func (m *UpdateRequest) GetId() string {
if m != nil {
return m.User
return m.Id
}
return nil
return ""
}
func (m *UpdateRequest) GetUsername() string {
if m != nil {
return m.Username
}
return ""
}
func (m *UpdateRequest) GetEmail() string {
if m != nil {
return m.Email
}
return ""
}
type UpdateResponse struct {
@@ -454,7 +494,7 @@ type UpdatePasswordRequest struct {
UserId string `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty"`
OldPassword string `protobuf:"bytes,2,opt,name=oldPassword,proto3" json:"oldPassword,omitempty"`
NewPassword string `protobuf:"bytes,3,opt,name=newPassword,proto3" json:"newPassword,omitempty"`
ConfirmPassword string `protobuf:"bytes,4,opt,name=confirmPassword,proto3" json:"confirmPassword,omitempty"`
ConfirmPassword string `protobuf:"bytes,4,opt,name=confirm_password,json=confirmPassword,proto3" json:"confirm_password,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@@ -911,46 +951,48 @@ func init() {
proto.RegisterType((*LogoutResponse)(nil), "LogoutResponse")
}
func init() { proto.RegisterFile("proto/users.proto", fileDescriptor_b1c161a4c7514913) }
func init() {
proto.RegisterFile("proto/users.proto", fileDescriptor_b1c161a4c7514913)
}
var fileDescriptor_b1c161a4c7514913 = []byte{
// 605 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0x4f, 0x6f, 0xd3, 0x4e,
0x10, 0xb5, 0xe3, 0x38, 0x69, 0x27, 0xb1, 0xdd, 0xdf, 0x36, 0xbf, 0x60, 0x0c, 0x88, 0x68, 0x25,
0xa4, 0x00, 0xea, 0x20, 0xa5, 0x27, 0xb8, 0x16, 0x21, 0x21, 0x71, 0xa8, 0x52, 0xf5, 0xc6, 0xc5,
0xc4, 0x1b, 0xb0, 0x94, 0x78, 0x83, 0xd7, 0x51, 0x39, 0xf0, 0x55, 0xf8, 0x22, 0x7c, 0x3a, 0xb4,
0xff, 0x12, 0xdb, 0x6d, 0x80, 0x72, 0xcb, 0xcc, 0xbc, 0xdd, 0x79, 0x3b, 0xf3, 0x9e, 0x03, 0xff,
0x6d, 0x4a, 0x5e, 0xf1, 0x57, 0x5b, 0xc1, 0x4a, 0x81, 0xea, 0x37, 0xfd, 0x0e, 0xdd, 0x6b, 0xc1,
0x4a, 0x12, 0x42, 0x27, 0xcf, 0x62, 0x77, 0xe2, 0x4e, 0x8f, 0xe7, 0x9d, 0x3c, 0x23, 0x09, 0x1c,
0x49, 0x58, 0x91, 0xae, 0x59, 0xdc, 0x51, 0xd9, 0x5d, 0x4c, 0x46, 0xe0, 0xb3, 0x75, 0x9a, 0xaf,
0x62, 0x4f, 0x15, 0x74, 0x40, 0x62, 0xe8, 0x2f, 0x4a, 0x96, 0x56, 0x2c, 0x8b, 0xbb, 0x13, 0x77,
0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, 0x0a, 0xac, 0x95, 0x42, 0x42, 0x6c, 0x68, 0x34, 0x89, 0xb0, 0x29, 0x21, 0xea, 0x90, 0x0b,
0xeb, 0xc9, 0x9d, 0x3b, 0xc6, 0x78, 0xa7, 0x23, 0x93, 0x07, 0x78, 0xc0, 0x0a, 0x0e, 0x99, 0x82,
0xaf, 0xf6, 0x43, 0x02, 0xac, 0xab, 0x20, 0x09, 0xb1, 0xb1, 0x36, 0xcd, 0x4d, 0x4f, 0x99, 0xa8,
0xda, 0x7e, 0x3b, 0x49, 0x84, 0xcd, 0xf1, 0x53, 0x87, 0xbc, 0xd1, 0x5f, 0x29, 0xfb, 0x85, 0x3e,
0xc5, 0xdb, 0x8a, 0x4e, 0x46, 0x78, 0x87, 0x64, 0xa9, 0xf3, 0xa9, 0xa7, 0xfe, 0x5e, 0xce, 0x7f,
0x05, 0x00, 0x00, 0xff, 0xff, 0x41, 0x5e, 0x5d, 0x7f, 0x73, 0x06, 0x00, 0x00,
// 600 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xb4, 0x55, 0xcf, 0x6e, 0xd3, 0x4e,
0x10, 0x4e, 0xe2, 0x38, 0x69, 0x27, 0x71, 0xda, 0xdf, 0xb6, 0xbf, 0x60, 0x0c, 0x88, 0x6a, 0x25,
0xa4, 0x56, 0xa8, 0x8b, 0x94, 0x9e, 0xe0, 0x5a, 0x2e, 0x48, 0x1c, 0xc0, 0x55, 0x6f, 0x48, 0xc8,
0x24, 0x1b, 0xb0, 0x14, 0x7b, 0x8d, 0xd7, 0x51, 0x39, 0x20, 0xf1, 0x26, 0x3c, 0x08, 0x4f, 0xc7,
0xec, 0xbf, 0xc4, 0x36, 0x8d, 0x04, 0xa8, 0xdc, 0x3c, 0x33, 0xdf, 0xec, 0x7c, 0x3b, 0x33, 0xdf,
0x1a, 0xfe, 0x2b, 0x4a, 0x51, 0x89, 0x67, 0x6b, 0xc9,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a7, 0x30, 0x30, 0xda, 0x24, 0x13, 0xd6, 0x78, 0x13,
0xa2, 0x03, 0xd6, 0x12, 0x6d, 0x87, 0x3c, 0x81, 0xbe, 0xea, 0x22, 0x19, 0xb3, 0x9a, 0x14, 0xa3,
0x80, 0xd5, 0x95, 0x87, 0x30, 0x3c, 0xd3, 0xac, 0x16, 0x9e, 0xd9, 0x50, 0x1a, 0x9e, 0xd9, 0x92,
0x89, 0x06, 0x1b, 0xa5, 0x23, 0xb8, 0xf1, 0x26, 0x20, 0xb8, 0xf5, 0x04, 0x68, 0xb0, 0xd9, 0x14,
0x04, 0x37, 0x76, 0x14, 0xc1, 0xcd, 0x15, 0x42, 0xf0, 0xa5, 0x13, 0xe5, 0x46, 0x1e, 0x53, 0x76,
0xab, 0x24, 0xa3, 0x7b, 0x6c, 0x87, 0x14, 0x3a, 0xe4, 0x14, 0x7c, 0x3d, 0x1f, 0x12, 0xb0, 0xfa,
0x16, 0x44, 0x13, 0xd6, 0x18, 0x9b, 0xe1, 0x66, 0xba, 0x4c, 0x74, 0x6c, 0x3b, 0x1d, 0xe4, 0xd6,
0x6c, 0x3f, 0x82, 0x5f, 0x98, 0xd7, 0xcc, 0xfd, 0x06, 0x8e, 0xd8, 0xaf, 0x1b, 0x1d, 0x1d, 0xb3,
0x5b, 0x56, 0x96, 0x76, 0x3e, 0x0c, 0xf4, 0x3f, 0xec, 0xe2, 0x67, 0x00, 0x00, 0x00, 0xff, 0xff,
0xc7, 0x99, 0xc1, 0x0c, 0xd8, 0x06, 0x00, 0x00,
}

View File

@@ -21,15 +21,18 @@ message User {
}
message Session {
string id = 1;
string username = 2;
int64 created = 3; // unix
int64 expires = 4; // unix
string id = 1;
string username = 2;
string email = 3;
int64 created = 4; // unix
int64 expires = 5; // unix
}
message CreateRequest {
User user = 1;
string password = 2;
string id = 1; // uuid
string username = 2; // alphanumeric user or org
string email = 3;
string password = 4;
}
message CreateResponse {
@@ -51,17 +54,19 @@ message ReadResponse {
}
message UpdateRequest {
User user = 1;
string id = 1; // uuid
string username = 2; // alphanumeric user or org
string email = 3;
}
message UpdateResponse {
}
message UpdatePasswordRequest {
string userId = 1;
string oldPassword = 2;
string newPassword = 3;
string confirmPassword = 4;
string userId = 1;
string oldPassword = 2;
string newPassword = 3;
string confirm_password = 4;
}
message UpdatePasswordResponse {
@@ -79,25 +84,25 @@ message SearchResponse {
}
message ReadSessionRequest {
string sessionId = 1;
string sessionId = 1;
}
message ReadSessionResponse {
Session session = 1;
Session session = 1;
}
message LoginRequest {
string username = 1;
string email = 2;
string password = 3;
string username = 1;
string email = 2;
string password = 3;
}
message LoginResponse {
Session session = 1;
Session session = 1;
}
message LogoutRequest {
string sessionId = 1;
string sessionId = 1;
}
message LogoutResponse {