Skip to content

Commit

Permalink
[HWORKS-1001][HWORKS-973] Share default project (#1516)
Browse files Browse the repository at this point in the history
* HWORKS-1001 and HWORKS-973

* remove ee test
  • Loading branch information
ErmiasG authored Apr 15, 2024
1 parent 1fa5705 commit a5f5d5d
Show file tree
Hide file tree
Showing 11 changed files with 1,014 additions and 884 deletions.
449 changes: 0 additions & 449 deletions hopsworks-IT/src/test/ruby/spec/featuregroup_spec.rb

Large diffs are not rendered by default.

830 changes: 830 additions & 0 deletions hopsworks-IT/src/test/ruby/spec/featurestore_share_spec.rb

Large diffs are not rendered by default.

207 changes: 0 additions & 207 deletions hopsworks-IT/src/test/ruby/spec/featureview_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -846,212 +846,5 @@
end
end
end

describe "shared permissions" do
before :all do
# Create users
@user1_params = {email: "user1_#{random_id}@email.com", first_name: "User", last_name: "1", password: "Pass123"}
@user1 = create_user(@user1_params)
pp "user email: #{@user1[:email]}" if defined?(@debugOpt) && @debugOpt
@user2_params = {email: "user2_#{random_id}@email.com", first_name: "User", last_name: "2", password: "Pass123"}
@user2 = create_user(@user2_params)
pp "user email: #{@user2[:email]}" if defined?(@debugOpt) && @debugOpt
@user_data_scientist_params = {email: "data_scientist_#{random_id}@email.com", first_name: "User", last_name: "data_scientist", password: "Pass123"}
@user_data_scientist = create_user(@user_data_scientist_params)
pp "user email: #{@user_data_scientist[:email]}" if defined?(@debugOpt) && @debugOpt
@user_data_owner_params = {email: "data_owner_#{random_id}@email.com", first_name: "User", last_name: "data_owner", password: "Pass123"}
@user_data_owner = create_user(@user_data_owner_params)
pp "user email: #{@user_data_owner[:email]}" if defined?(@debugOpt) && @debugOpt

# Create base project
create_session(@user1[:email], @user1_params[:password])
@project1 = create_project
pp @project1[:projectname] if defined?(@debugOpt) && @debugOpt

# Create shared with projects
create_session(@user2[:email], @user2_params[:password])
@project_read_only = create_project
pp @project_read_only[:projectname] if defined?(@debugOpt) && @debugOpt

# Add members to projects
add_member_to_project(@project_read_only, @user_data_owner_params[:email], "Data owner")
add_member_to_project(@project_read_only, @user_data_scientist_params[:email], "Data scientist")

# Share projects
create_session(@user1[:email], @user1_params[:password])
share_dataset_checked(@project1, "#{@project1[:projectname].downcase}_featurestore.db", @project_read_only[:projectname], datasetType: "FEATURESTORE")

# Accept shared projects
create_session(@user2[:email], @user2_params[:password])
accept_dataset_checked(@project_read_only, "#{@project1[:projectname]}::#{@project1[:projectname].downcase}_featurestore.db", datasetType: "FEATURESTORE")
end

context "shared feature view permissions" do

# create

it 'data owner should not be able to create fv with read only permission' do
create_session(@user1[:email], @user1_params[:password])
fs = get_featurestore(@project1[:id])
json_result, fg_name = create_cached_featuregroup(@project1[:id], fs["featurestoreId"], online:true)
parsed_json = JSON.parse(json_result)
expect_status_details(201)

create_session(@user_data_owner[:email], @user_data_owner_params[:password])
create_feature_view_from_feature_group(@project_read_only[:id], fs["featurestoreId"], parsed_json)
parsed_json = JSON.parse(json_result)
expect_status_details(403)
end

it 'data scientist should not be able to create fv with read only permission' do
create_session(@user1[:email], @user1_params[:password])
fs = get_featurestore(@project1[:id])
json_result, fg_name = create_cached_featuregroup(@project1[:id], fs["featurestoreId"], online:true)
parsed_json = JSON.parse(json_result)
expect_status_details(201)

create_session(@user_data_scientist[:email], @user_data_scientist_params[:password])
create_feature_view_from_feature_group(@project_read_only[:id], fs["featurestoreId"], parsed_json)
parsed_json = JSON.parse(json_result)
expect_status_details(403)
end

# get

it 'data owner should be able to get fv with read only permission' do
create_session(@user1[:email], @user1_params[:password])
fs = get_featurestore(@project1[:id])
json_result, fg_name = create_cached_featuregroup(@project1[:id], fs["featurestoreId"], online:true)
parsed_json = JSON.parse(json_result)
expect_status_details(201)

json_result = create_feature_view_from_feature_group(@project1[:id], fs["featurestoreId"], parsed_json)
parsed_json = JSON.parse(json_result)
expect_status_details(201)

create_session(@user_data_owner[:email], @user_data_owner_params[:password])
json_result = get_feature_view_by_name_and_version(@project_read_only[:id], fs["featurestoreId"], parsed_json["name"], parsed_json["version"])
parsed_json = JSON.parse(json_result)
expect_status_details(200)
end

it 'data scientist should be able to get fv with read only permission' do
create_session(@user1[:email], @user1_params[:password])
fs = get_featurestore(@project1[:id])
json_result, fg_name = create_cached_featuregroup(@project1[:id], fs["featurestoreId"], online:true)
parsed_json = JSON.parse(json_result)
expect_status_details(201)

json_result = create_feature_view_from_feature_group(@project1[:id], fs["featurestoreId"], parsed_json)
parsed_json = JSON.parse(json_result)
expect_status_details(201)

create_session(@user_data_scientist[:email], @user_data_scientist_params[:password])
json_result = get_feature_view_by_name_and_version(@project_read_only[:id], fs["featurestoreId"], parsed_json["name"], parsed_json["version"])
parsed_json = JSON.parse(json_result)
expect_status_details(200)
end

# update

it 'data owner should not be able to update fv with read only permission' do
create_session(@user1[:email], @user1_params[:password])
fs = get_featurestore(@project1[:id])
json_result, fg_name = create_cached_featuregroup(@project1[:id], fs["featurestoreId"], online:true)
parsed_json = JSON.parse(json_result)
expect_status_details(201)

json_result = create_feature_view_from_feature_group(@project1[:id], fs["featurestoreId"], parsed_json)
parsed_json = JSON.parse(json_result)
expect_status_details(201)

create_session(@user_data_owner[:email], @user_data_owner_params[:password])
description = parsed_json["description"]

json_data = {
name: "new_testfeatureviewname",
version: parsed_json["version"],
type: "featureViewDTO",
description: "temp desc"
}
json_result = update_feature_view(@project_read_only[:id], fs["featurestoreId"], json_data, parsed_json["name"], parsed_json["version"])
expect_status_details(403)

json_result = get_feature_view_by_name_and_version(@project_read_only[:id], fs["featurestoreId"], parsed_json["name"], parsed_json["version"])
parsed_json = JSON.parse(json_result)
expect_status_details(200)
expect(parsed_json["description"]).to eql(description)
end

it 'data scientist should not be able to update fv with read only permission' do
create_session(@user1[:email], @user1_params[:password])
fs = get_featurestore(@project1[:id])
json_result, fg_name = create_cached_featuregroup(@project1[:id], fs["featurestoreId"], online:true)
parsed_json = JSON.parse(json_result)
expect_status_details(201)

json_result = create_feature_view_from_feature_group(@project1[:id], fs["featurestoreId"], parsed_json)
parsed_json = JSON.parse(json_result)
expect_status_details(201)

create_session(@user_data_scientist[:email], @user_data_scientist_params[:password])
description = parsed_json["description"]

json_data = {
name: "new_testfeatureviewname",
version: parsed_json["version"],
type: "featureViewDTO",
description: "temp desc"
}
json_result = update_feature_view(@project_read_only[:id], fs["featurestoreId"], json_data, parsed_json["name"], parsed_json["version"])
expect_status_details(403)

json_result = get_feature_view_by_name_and_version(@project_read_only[:id], fs["featurestoreId"], parsed_json["name"], parsed_json["version"])
parsed_json = JSON.parse(json_result)
expect_status_details(200)
expect(parsed_json["description"]).to eql(description)
end

# delete

it 'data owner should not be able to delete fv with read only permission' do
create_session(@user1[:email], @user1_params[:password])
fs = get_featurestore(@project1[:id])
json_result, fg_name = create_cached_featuregroup(@project1[:id], fs["featurestoreId"], online:true)
parsed_json = JSON.parse(json_result)
expect_status_details(201)

json_result = create_feature_view_from_feature_group(@project1[:id], fs["featurestoreId"], parsed_json)
parsed_json = JSON.parse(json_result)
expect_status_details(201)

create_session(@user_data_owner[:email], @user_data_owner_params[:password])
delete_feature_view(@project_read_only["id"], parsed_json["name"], feature_store_id: fs["featurestoreId"], expected_status: 403)

json_result = get_feature_view_by_name_and_version(@project_read_only[:id], fs["featurestoreId"], parsed_json["name"], parsed_json["version"])
parsed_json = JSON.parse(json_result)
expect_status_details(200)
end

it 'data scientist should not be able to delete fv with read only permission' do
create_session(@user1[:email], @user1_params[:password])
fs = get_featurestore(@project1[:id])
json_result, fg_name = create_cached_featuregroup(@project1[:id], fs["featurestoreId"], online:true)
parsed_json = JSON.parse(json_result)
expect_status_details(201)

json_result = create_feature_view_from_feature_group(@project1[:id], fs["featurestoreId"], parsed_json)
parsed_json = JSON.parse(json_result)
expect_status_details(201)

create_session(@user_data_scientist[:email], @user_data_scientist_params[:password])
delete_feature_view(@project_read_only["id"], parsed_json["name"], feature_store_id: fs["featurestoreId"], expected_status: 403)

json_result = get_feature_view_by_name_and_version(@project_read_only[:id], fs["featurestoreId"], parsed_json["name"], parsed_json["version"])
parsed_json = JSON.parse(json_result)
expect_status_details(200)
end
end
end
end
end
25 changes: 24 additions & 1 deletion hopsworks-IT/src/test/ruby/spec/helpers/dataset_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def delete_dir(project, path, dataset_type: "DATASET")
end

def delete_dir_checked(project, path, dataset_type: "DATASET")
delete_dir(project, path, dataset_type)
delete_dir(project, path, dataset_type: dataset_type)
expect_status_details(204)
end

Expand Down Expand Up @@ -847,4 +847,27 @@ def query_dataset(project, path, dataset_type: "DATASET", action: "stat", expand
pp "get #{path}" if defined?(@debugOpt) && @debugOpt
get path
end

def test_feature_store_shared(project1, project2)
featurestore = "#{project1[:projectname]}::#{project1[:projectname].downcase}_featurestore.db"
trainingDataset = "#{project1[:projectname]}::#{project1[:projectname]}_Training_Datasets"
statisticsDataset = "#{project1[:projectname]}::Statistics"
dataValidationDataset = "#{project1[:projectname]}::DataValidation"

get_dataset_stat(project2, featurestore, datasetType: "&type=FEATURESTORE")
shared_ds = json_body
expect("#{shared_ds[:name]}").to eq(featurestore)

get_dataset_stat(project2, trainingDataset, datasetType: "&type=DATASET")
shared_ds = json_body
expect("#{shared_ds[:name]}").to eq(trainingDataset)

get_dataset_stat(project2, statisticsDataset, datasetType: "&type=DATASET")
shared_ds = json_body
expect("#{shared_ds[:name]}").to eq(statisticsDataset)

get_dataset_stat(project2, dataValidationDataset, datasetType: "&type=DATASET")
shared_ds = json_body
expect("#{shared_ds[:name]}").to eq(dataValidationDataset)
end
end
13 changes: 13 additions & 0 deletions hopsworks-IT/src/test/ruby/spec/helpers/variables_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,19 @@ def setVar (id, value)
variables
end

def create_var(id, value)
variables = Variables.find_by(id: id)
if variables.nil?
Variables.create(id: id, value: value)
variables = Variables.find_by(id: id)
else
variables.value = value
variables.save
end
refresh_variables
variables
end

def kubernetes_installed
getVar("kubernetes_installed").value.eql? "true"
end
Expand Down
Loading

0 comments on commit a5f5d5d

Please sign in to comment.